diff --git a/Makefile.in b/Makefile.in index 0a94756..b9f9993 100644 --- a/Makefile.in +++ b/Makefile.in @@ -300,32 +300,24 @@ endif # enable GM if configure detected it ifdef BUILD_GM - CFLAGS += -I @GM_HOME@/include -I @GM_HOME@/include/gm - CFLAGS += -D__STATIC_METHOD_BMI_GM__ - # TODO: later on we will want the ability to modify this at configure - # time - CFLAGS += -DENABLE_GM_BUFPOOL - LDFLAGS += -L@GM_HOME@/lib - SERVER_LDFLAGS += -L@GM_HOME@/lib - LIBS += -lgm - LIBS_THREADED += -lgm - SERVERLIBS += -lgm + # other settings in bmi_gm/module.mk.in + CFLAGS += -D__STATIC_METHOD_BMI_GM__ + GMLIBS := -L@GM_LIBDIR@ -lgm + LIBS += $(GMLIBS) + LIBS_THREADED += $(GMLIBS) + SERVERLIBS += $(GMLIBS) endif ################################################################ # enable MX if configure detected it ifdef BUILD_MX - CFLAGS += -I @MX_HOME@/include - CFLAGS += -D__STATIC_METHOD_BMI_MX__ - # TODO: later on we will want the ability to modify this at configure - # time - CFLAGS += -g -O0 - LDFLAGS += -L@MX_HOME@/lib - SERVER_LDFLAGS += -L@MX_HOME@/lib - LIBS += -lmyriexpress -lpthread - LIBS_THREADED += -lmyriexpress -lpthread - SERVERLIBS += -lmyriexpress -lpthread + # other settings in bmi_mx/module.mk.in + CFLAGS += -D__STATIC_METHOD_BMI_MX__ + MXLIBS := -L@MX_LIBDIR@ -lmyriexpress -lpthread + LIBS += $(MXLIBS) + LIBS_THREADED += $(MXLIBS) + SERVERLIBS += $(MXLIBS) endif ##################################### @@ -402,6 +394,8 @@ ADMINSRC_SERVER := LIBSRC := # SERVERSRC is souce code for the pvfs2 server SERVERSRC := +# SERVERBINSRC is source files that don't get added to the server library but must be added to the server binary +SERVERBINSRC := # DOCSRC is source code for documentation DOCSRC := # VISSRC is the source code for visualization tools @@ -413,8 +407,7 @@ VISMISCSRC := KARMASRC := # userland helper programs for kernel drivers KERNAPPSRC := -# -KERNAPPSTHRSRC := +KERNAPPTHRSRC := # MISCSRC are sources that don't fall into the other categories MISCSRC := # c files generated from state machines @@ -432,18 +425,18 @@ SERVER_STUB := src/server/pvfs2-server-stub SERVER := src/server/pvfs2-server endif -# LIBRARIES is a list of the pvfs2 client libraries +# LIBRARIES is a list of the pvfs2 client libraries that will be installed LIBRARIES := LIBRARIES_THREADED := ifeq ($(build_shared),yes) LIBRARIES_SHARED = lib/libpvfs2.so LIBRARIES += $(LIBRARIES_SHARED) +LIBRARIES_THREADED += lib/libpvfs2-threaded.so endif ifeq ($(build_static),yes) LIBRARIES_STATIC = lib/libpvfs2.a LIBRARIES += $(LIBRARIES_STATIC) -LIBRARIES_THREADED_STATIC = lib/libpvfs2-threaded.a -LIBRARIES_THREADED += $(LIBRARIES_THREADED_STATIC) +LIBRARIES_THREADED += lib/libpvfs2-threaded.a endif ################################################################ @@ -494,6 +487,9 @@ ifdef BUILD_SERVER SERVEROBJS := $(patsubst %.c,%-server.o, $(filter %.c,$(SERVERSRC))) # SERVERDEPENDS is a list of dependency files for the server SERVERDEPENDS := $(patsubst %.c,%.d, $(filter %.c,$(SERVERSRC))) + # SERVERBINOBJS is a list of objects not in SERVEROBJS to put into the server + SERVERBINOBJS := $(patsubst %.c,%-server.o, $(filter %.c,$(SERVERBINSRC))) + SERVERBINDEPENDS := $(patsubst %.c,%.d, $(filter %.c,$(SERVERBINSRC))) endif # MISCOBJS is a list of misc. objects not in the above categories @@ -502,14 +498,21 @@ MISCOBJS := $(patsubst %.c,%.o, $(filter %.c,$(MISCSRC))) MISCDEPENDS := $(patsubst %.c,%.d, $(filter %.c,$(MISCSRC))) # KERNAPPOBJS is a list of kernel driver userland objects -KERNAPPOBJS := $(patsubst %.c,%.o, $(filter %.c,$(KERNAPPSRC))) +KERNAPPOBJS := $(patsubst %.c,%.o, $(filter %.c,$(KERNAPPSRC))) \ + $(patsubst %.c,%-threaded.o, $(filter %.c,$(KERNAPPTHRSRC))) # KERNAPPS is a list of kernel driver userland executables KERNAPPS := $(patsubst %.c,%, $(filter %.c, $(KERNAPPSRC))) +KERNAPPSTHR := $(patsubst %.c,%, $(filter %.c, $(KERNAPPTHRSRC))) # KERNAPPDEPENDS is a list of dependency files for kernel driver userland # objects -KERNAPPDEPENDS := $(patsubst %.c,%.d, $(filter %.c,$(KERNAPPSRC))) - -KERNAPPSTHR := $(patsubst %.c,%-threaded, $(filter %.c, $(KERNAPPSTHRSRC))) +KERNAPPDEPENDS := $(patsubst %.c,%.d, $(filter %.c,$(KERNAPPSRC) $(KERNAPPTHRSRC))) +# Be sure to build/install the threaded lib too; just pick the shared +# one if configure asked for both. +ifneq (,$(KERNAPPSTHR)) +ifeq (,$(filter $(firstword $(LIBRARIES_THREADED)),$(LIBRARIES))) +LIBRARIES += $(firstword $(LIBRARIES_THREADED)) +endif +endif # VISOBJS is a list of visualization program objects VISOBJS := $(patsubst %.c,%.o, $(filter %.c,$(VISSRC))) @@ -546,7 +549,8 @@ DOCSCRUFT += $(patsubst %.tex,%.toc, $(filter %.tex,$(DOCSRC))) # DEPENDS is a global list of all of our dependency files. # NOTE: sort is just a trick to remove duplicates; the order # doesn't matter at all. -DEPENDS := $(sort $(LIBDEPENDS) $(SERVERDEPENDS) $(MISCDEPENDS) \ +DEPENDS := $(sort $(LIBDEPENDS) $(SERVERDEPENDS) $(SERVERBINDEPENDS) \ + $(MISCDEPENDS) \ $(ADMINDEPENDS) $(ADMINDEPENDS_SERVER) $(KERNAPPDEPENDS) $(VISDEPENDS) \ $(VISMISCDEPENDS) $(KARMADEPENDS) $(STATECOMPDEPS)) @@ -562,6 +566,9 @@ admintools: $(ADMINTOOLS) $(ADMINTOOLS_SERVER) # target for building kernel driver userland programs kernapps: $(KERNAPPS) +# this is needed for the make dist +statecompgen: $(STATECOMPGEN) + # Build linux-2.6 kernel module if requested. # Can't use the actual file target since we don't know how to figure out # dependencies---only the kernel source tree can do that. @@ -610,7 +617,7 @@ SERVERLIBS += -Wl,-whole-archive ../stgt/libstgt.a -Wl,-no-whole-archive \ endif # rule for building the pvfs2 server -$(SERVER): src/server/pvfs2-server-server.o lib/libpvfs2-server.a +$(SERVER): $(SERVERBINOBJS) lib/libpvfs2-server.a $(Q) " LD $@" $(E)$(LD) $^ -o $@ $(SERVER_LDFLAGS) $(SERVERLIBS) @@ -724,8 +731,11 @@ $(VISS): %: %.o $(VISMISCOBJS) $(LIBRARIES) # all applications depend on the pvfs2 library $(ADMINTOOLS): %: %.o $(LIBRARIES) $(ADMINTOOLS_SERVER): %: %.o $(LIBRARIES) lib/libpvfs2-server.a + $(KERNAPPS): %: %.o $(LIBRARIES) $(KERNAPPSTHR): %: %.o $(LIBRARIES_THREADED) + $(Q) " LD $@" + $(E)$(LD) -o $@ $(LDFLAGS) $< $(LIBS_THREADED) $(call modldflags,$<) # special rules to build state machine compiler using build host compiler $(STATECOMPOBJS): %.o: %.c @@ -776,7 +786,8 @@ docsclean: # top rule for cleaning up tree clean:: $(Q) " CLEAN" - $(E)rm -f $(LIBOBJS) $(LIBTHREADEDOBJS) $(SERVEROBJS) $(MISCOBJS) \ + $(E)rm -f $(LIBOBJS) $(LIBTHREADEDOBJS) \ + $(SERVEROBJS) $(SERVERBINOBJS) $(MISCOBJS) \ $(LIBRARIES) $(LIBRARIES_THREADED) $(DEPENDS) $(SERVER) \ $(ADMINOBJS) $(ADMINOBJS_SERVER) $(ADMINTOOLS)\ $(ADMINTOOLS_SERVER) lib/libpvfs2-server.a\ @@ -952,7 +963,7 @@ just_kmod_install: just_kmod .PHONY: kmod_install kmod_install: kmod kernapps just_kmod_install install -d $(prefix)/sbin - install -m 755 $(KERNAPPS) $(prefix)/sbin + install -m 755 $(KERNAPPS) $(KERNAPPSTHR) $(prefix)/sbin endif ifneq (,$(LINUX24_KERNEL_SRC)) @@ -973,7 +984,7 @@ just_kmod24_install: just_kmod24 .PHONY: kmod24_install kmod24_install: kmod24 kernapps just_kmod24_install install -d $(prefix)/sbin - install -m 755 $(KERNAPPS) $(prefix)/sbin + install -m 755 $(KERNAPPS) $(KERNAPPSTHR) $(prefix)/sbin install -m 755 src/apps/kernel/linux/mount.pvfs2 $(prefix)/sbin @echo "" @echo "For improved linux-2.4 support," diff --git a/configure b/configure index de4401f..ad281da 100755 --- a/configure +++ b/configure @@ -692,6 +692,7 @@ build_static REDHAT_RELEASE NPTL_WORKAROUND MISC_TROVE_FLAGS +THREADED_KMOD_HELPER LINUX_KERNEL_SRC LINUX24_KERNEL_SRC LINUX24_KERNEL_MINOR_VER @@ -712,10 +713,12 @@ NEEDS_LIBRT TARGET_OS_DARWIN TARGET_OS_LINUX BUILD_BMI_TCP -GM_HOME BUILD_GM -MX_HOME +GM_INCDIR +GM_LIBDIR BUILD_MX +MX_INCDIR +MX_LIBDIR BUILD_IB IB_INCDIR IB_LIBDIR @@ -1331,6 +1334,7 @@ Optional Features: --disable-aio-threaded-callbacks Disable use of AIO threaded callbacks --disable-kernel-aio Forcibly disable kernel aio --enable-kernel-sendfile Forcibly enable kernel sendfile + --enable-threaded-kmod-helper Use threads in the kernel helper application --enable-fast Disable optional debugging, enable optimizations. --enable-strict Turn on strict compiler warnings --enable-verbose-build Enables full output during build process @@ -1357,8 +1361,12 @@ Optional Packages: --with-valgrind= Use valgrind annotations for debugging. --with-db= Location of installed DB package (default=/usr) --without-bmi-tcp Disable BMI TCP method - --with-gm= Location of the GM installation (default no GM) - --with-mx= Location of the MX installation (default no MX) + --with-gm= Location of the GM install (default no GM) + --with-gm-includes= Location of the GM includes + --with-gm-libs= Location of the GM libraries + --with-mx= Location of the MX install (default no MX) + --with-mx-includes= Location of the MX includes + --with-mx-libs= Location of the MX libraries --with-ib= Location of the IB installation (default no IB) --with-ib-includes= Location of the IB includes --with-ib-libs= Location of the IB libraries @@ -5962,6 +5970,58 @@ fi +# +# Threading options. +# +# Client - thread-safe or not +# --disable-thread-safety : chooses null or posix locking mechanism +# For applications that know they are not multi-threaded, or choose +# to handle locking themselves, this configure option can be used to +# slightly decrease library-induced latency by removing the locking. +# +# Client - job threading +# libpvfs2-threaded.{so,a} with __PVFS2_JOB_THREADED__ +# This option causes the client library to spawn an extra thread +# to handle network communications. In this way, it is possible +# that the library can handle new and completed requests from +# the application while also interacting with the network. +# +# These separate libraries can not be built using the existing +# configure mechanism. They are only built if required by the +# kernel module helper. +# +# Server - three options: +# trove +# (hack Makefile.in) +# job +# (hack Makefile.in) +# aio +# --disable-aio-threaded-callbacks +# +# Trove (storage) and job threading in the server are implemented +# using #defines, but not exported through the configure mechanism. +# AIO threaded callbacks are a separate thread used in conjunction +# with trove, and can be disabled through a configure option as +# AIO has been found to be buggy on many systems. +# +# +# Kernel module helper - job threading +# --enable-threaded-kmod-helper +# +# This is a special client that "helps" applications that access PVFS +# through the kernel using normal VFS calls (e.g. "ls"). This +# configure options builds it using __PVFS2_JOB_THREADED__ as described +# above. That enables a thread for the network layer and a thread +# for the kernel interface. This has the potential to increase the +# rate at which concurrent operations are processed, but has the potential +# drawback of somewhat higher overhead for a single operation and lack +# of testing. +# +# Enabling this options causes one of libpvfs2-threaded.{so,a} to be +# built, depending on --enable-shared and --enable-static. If both are +# enabled, the shared library takes precedence. +# + { echo "$as_me:$LINENO: checking for client library thread safety support" >&5 echo $ECHO_N "checking for client library thread safety support... $ECHO_C" >&6; } # Check whether --enable-thread-safety was given. @@ -7027,7 +7087,7 @@ int main () { - struct aiocb; + struct aiocb aiocb; aiocb.__error_code = 0; ; @@ -7085,7 +7145,7 @@ int main () { - struct aiocb; + struct aiocb aiocb; aiocb.__return_value = 0; ; @@ -8003,6 +8063,9 @@ if test -n "$lk_src" ; then CFLAGS="$USR_CFLAGS $NOSTDINCFLAGS -I$lk_src/include -I$lk_src/include/asm/mach-default -DKBUILD_STR(s)=#s -DKBUILD_BASENAME=KBUILD_STR(empty) -DKBUILD_MODNAME=KBUILD_STR(empty) -imacros $lk_src/include/linux/autoconf.h" + if test -n "${ARCH}" ; then + CFLAGS="$CFLAGS -I$lk_src/arch/${ARCH}/include" + fi { echo "$as_me:$LINENO: checking for i_size_write in kernel" >&5 echo $ECHO_N "checking for i_size_write in kernel... $ECHO_C" >&6; } @@ -11744,6 +11807,64 @@ echo "${ECHO_T}no" >&6; } fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + { echo "$as_me:$LINENO: checking if kernel super_operations contains read_inode field" >&5 +echo $ECHO_N "checking if kernel super_operations contains read_inode field... $ECHO_C" >&6; } + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + + #define __KERNEL__ + #include + +int +main () +{ + + struct super_operations sops; + sops.read_inode(NULL); + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + +cat >>confdefs.h <<\_ACEOF +#define HAVE_READ_INODE 1 +_ACEOF + +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } + +fi + rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext CFLAGS=$oldcflags @@ -11755,6 +11876,16 @@ _ACEOF fi +# Check whether --enable-threaded-kmod-helper was given. +if test "${enable_threaded_kmod_helper+set}" = set; then + enableval=$enable_threaded_kmod_helper; if test "x$enableval" = "xyes" ; then + THREADED_KMOD_HELPER=yes + fi + +fi + + + BUILD_ABSOLUTE_TOP=`pwd` SRC_RELATIVE_TOP=$srcdir SRC_ABSOLUTE_TOP=`cd $srcdir ; pwd` @@ -12019,7 +12150,61 @@ fi if test "${enable_segv_backtrace+set}" = set; then enableval=$enable_segv_backtrace; else - PVFS2_SEGV_BACKTRACE=1 + { echo "$as_me:$LINENO: checking if segv backtrace capable" >&5 +echo $ECHO_N "checking if segv backtrace capable... $ECHO_C" >&6; } + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +#include +#define __USE_GNU +#include +#if !defined(REG_EIP) && !defined(REG_RIP) + choke me +#endif + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + PVFS2_SEGV_BACKTRACE=1 +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + fi @@ -14387,24 +14572,62 @@ fi -GM_HOME= + + gm_home= # Check whether --with-gm was given. if test "${with_gm+set}" = set; then withval=$with_gm; if test -z "$withval" -o "$withval" = yes ; then - { { echo "$as_me:$LINENO: error: Option --with-gm requires the path to your GM tree." >&5 + { { echo "$as_me:$LINENO: error: Option --with-gm requires the path to your GM tree." >&5 echo "$as_me: error: Option --with-gm requires the path to your GM tree." >&2;} { (exit 1); exit 1; }; } - elif test "$withval" != no ; then - GM_HOME="$withval" - fi + elif test "$withval" != no ; then + gm_home="$withval" + fi fi -if test -n "$GM_HOME" ; then - save_cppflags="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS -I ${GM_HOME}/include -I ${GM_HOME}/include/gm" - if test "${ac_cv_header_gm_h+set}" = set; then + +# Check whether --with-gm-includes was given. +if test "${with_gm_includes+set}" = set; then + withval=$with_gm_includes; if test -z "$withval" -o "$withval" = yes ; then + { { echo "$as_me:$LINENO: error: Option --with-gm-includes requires path to GM headers." >&5 +echo "$as_me: error: Option --with-gm-includes requires path to GM headers." >&2;} + { (exit 1); exit 1; }; } + elif test "$withval" != no ; then + GM_INCDIR="$withval" + fi + +fi + + +# Check whether --with-gm-libs was given. +if test "${with_gm_libs+set}" = set; then + withval=$with_gm_libs; if test -z "$withval" -o "$withval" = yes ; then + { { echo "$as_me:$LINENO: error: Option --with-gm-libs requires path to GM libraries." >&5 +echo "$as_me: error: Option --with-gm-libs requires path to GM libraries." >&2;} + { (exit 1); exit 1; }; } + elif test "$withval" != no ; then + GM_LIBDIR="$withval" + fi + +fi + + if test -n "$gm_home" ; then + if test -z "$GM_INCDIR"; then + GM_INCDIR=$gm_home/include + fi + if test -z "$GM_LIBDIR"; then + GM_LIBDIR=$gm_home/lib64 + if test ! -d "$GM_LIBDIR" ; then + GM_LIBDIR=$gm_home/lib + fi + fi + fi + if test -n "$GM_INCDIR$GM_LIBDIR" ; then + save_cppflags="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS -I$GM_INCDIR -I$GM_INCDIR/gm" + if test "${ac_cv_header_gm_h+set}" = set; then { echo "$as_me:$LINENO: checking for gm.h" >&5 echo $ECHO_N "checking for gm.h... $ECHO_C" >&6; } if test "${ac_cv_header_gm_h+set}" = set; then @@ -14538,29 +14761,77 @@ echo "$as_me: error: Header gm.h not found." >&2;} fi - BUILD_GM=1 - CPPFLAGS="$save_cppflags" -fi + if test ! -f $GM_LIBDIR/libgm.so ; then + if test ! -f $GM_LIBDIR/libgm.a ; then + { { echo "$as_me:$LINENO: error: Neither GM library libgm.so or libgm.a found." >&5 +echo "$as_me: error: Neither GM library libgm.so or libgm.a found." >&2;} + { (exit 1); exit 1; }; } + fi + fi + BUILD_GM=1 + CPPFLAGS="$save_cppflags" + fi + -MX_HOME= + + + mx_home= # Check whether --with-mx was given. if test "${with_mx+set}" = set; then withval=$with_mx; if test -z "$withval" -o "$withval" = yes ; then - { { echo "$as_me:$LINENO: error: Option --with-mx requires the path to your MX tree." >&5 + { { echo "$as_me:$LINENO: error: Option --with-mx requires the path to your MX tree." >&5 echo "$as_me: error: Option --with-mx requires the path to your MX tree." >&2;} { (exit 1); exit 1; }; } - elif test "$withval" != no ; then - MX_HOME="$withval" - fi + elif test "$withval" != no ; then + mx_home="$withval" + fi + +fi + + +# Check whether --with-mx-includes was given. +if test "${with_mx_includes+set}" = set; then + withval=$with_mx_includes; if test -z "$withval" -o "$withval" = yes ; then + { { echo "$as_me:$LINENO: error: Option --with-mx-includes requires path to MX headers." >&5 +echo "$as_me: error: Option --with-mx-includes requires path to MX headers." >&2;} + { (exit 1); exit 1; }; } + elif test "$withval" != no ; then + MX_INCDIR="$withval" + fi + +fi + + +# Check whether --with-mx-libs was given. +if test "${with_mx_libs+set}" = set; then + withval=$with_mx_libs; if test -z "$withval" -o "$withval" = yes ; then + { { echo "$as_me:$LINENO: error: Option --with-mx-libs requires path to MX libraries." >&5 +echo "$as_me: error: Option --with-mx-libs requires path to MX libraries." >&2;} + { (exit 1); exit 1; }; } + elif test "$withval" != no ; then + MX_LIBDIR="$withval" + fi fi -if test -n "$MX_HOME" ; then - CPPFLAGS="$CPPFLAGS -I ${MX_HOME}/include" - if test "${ac_cv_header_myriexpress_h+set}" = set; then + if test -n "$mx_home" ; then + if test -z "$MX_INCDIR"; then + MX_INCDIR=$mx_home/include + fi + if test -z "$MX_LIBDIR"; then + MX_LIBDIR=$mx_home/lib64 + if test ! -d "$MX_LIBDIR" ; then + MX_LIBDIR=$mx_home/lib + fi + fi + fi + if test -n "$MX_INCDIR$MX_LIBDIR" ; then + save_cppflags="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS -I$MX_INCDIR -I$MX_INCDIR/mx" + if test "${ac_cv_header_myriexpress_h+set}" = set; then { echo "$as_me:$LINENO: checking for myriexpress.h" >&5 echo $ECHO_N "checking for myriexpress.h... $ECHO_C" >&6; } if test "${ac_cv_header_myriexpress_h+set}" = set; then @@ -14694,13 +14965,18 @@ echo "$as_me: error: Header myriexpress.h not found." >&2;} fi - BUILD_MX=1 - CPPFLAGS="$CPPFLAGS_OLD" - CFLAGS="${CFLAGS} -I${MX_HOME}/include" - LDFLAGS="$LDFLAGS -L${MX_HOME}/lib" - SERVER_LDFLAGS="$SERVER_LDFLAGS -L${MX_HOME}/lib" - LIBS="$LIBS -lmyriexpress" -fi + if test ! -f $MX_LIBDIR/libmyriexpress.so ; then + if test ! -f $MX_LIBDIR/libmyriexpress.a ; then + { { echo "$as_me:$LINENO: error: Neither MX library libmyriexpress.so or libmyriexpress.a found." >&5 +echo "$as_me: error: Neither MX library libmyriexpress.so or libmyriexpress.a found." >&2;} + { (exit 1); exit 1; }; } + fi + fi + BUILD_MX=1 + CPPFLAGS="$save_cppflags" + fi + + @@ -15351,7 +15627,7 @@ fi CPPFLAGS="$CPPFLAGS $PORTALS_INCS" PORTALS_LIBS="$libs" - LIBS="$LIBS $PORTALS_LIBS" + LIBS="$save_libs $PORTALS_LIBS" { echo "$as_me:$LINENO: checking for portals3.h header" >&5 echo $ECHO_N "checking for portals3.h header... $ECHO_C" >&6; } @@ -15458,7 +15734,7 @@ rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ if test "$ok" = no ; then PORTALS_LIBS="$libs -lportals" - LIBS="$LIBS $PORTALS_LIBS" + LIBS="$save_libs $PORTALS_LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -15506,7 +15782,7 @@ rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ if test "$ok" = no ; then PORTALS_LIBS="$libs -lp3api -lp3lib -lp3utcp -lp3rt -lpthread" - LIBS="$LIBS $PORTALS_LIBS" + LIBS="$save_libs $PORTALS_LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -18316,6 +18592,7 @@ build_static!$build_static$ac_delim REDHAT_RELEASE!$REDHAT_RELEASE$ac_delim NPTL_WORKAROUND!$NPTL_WORKAROUND$ac_delim MISC_TROVE_FLAGS!$MISC_TROVE_FLAGS$ac_delim +THREADED_KMOD_HELPER!$THREADED_KMOD_HELPER$ac_delim LINUX_KERNEL_SRC!$LINUX_KERNEL_SRC$ac_delim LINUX24_KERNEL_SRC!$LINUX24_KERNEL_SRC$ac_delim LINUX24_KERNEL_MINOR_VER!$LINUX24_KERNEL_MINOR_VER$ac_delim @@ -18333,7 +18610,6 @@ GNUC!$GNUC$ac_delim DB_CFLAGS!$DB_CFLAGS$ac_delim DB_LIB!$DB_LIB$ac_delim NEEDS_LIBRT!$NEEDS_LIBRT$ac_delim -TARGET_OS_DARWIN!$TARGET_OS_DARWIN$ac_delim _ACEOF if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then @@ -18375,12 +18651,15 @@ _ACEOF ac_delim='%!_!# ' for ac_last_try in false false false false false :; do cat >conf$$subs.sed <<_ACEOF +TARGET_OS_DARWIN!$TARGET_OS_DARWIN$ac_delim TARGET_OS_LINUX!$TARGET_OS_LINUX$ac_delim BUILD_BMI_TCP!$BUILD_BMI_TCP$ac_delim -GM_HOME!$GM_HOME$ac_delim BUILD_GM!$BUILD_GM$ac_delim -MX_HOME!$MX_HOME$ac_delim +GM_INCDIR!$GM_INCDIR$ac_delim +GM_LIBDIR!$GM_LIBDIR$ac_delim BUILD_MX!$BUILD_MX$ac_delim +MX_INCDIR!$MX_INCDIR$ac_delim +MX_LIBDIR!$MX_LIBDIR$ac_delim BUILD_IB!$BUILD_IB$ac_delim IB_INCDIR!$IB_INCDIR$ac_delim IB_LIBDIR!$IB_LIBDIR$ac_delim @@ -18401,7 +18680,7 @@ LIBOBJS!$LIBOBJS$ac_delim LTLIBOBJS!$LTLIBOBJS$ac_delim _ACEOF - if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 24; then + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 27; then break elif $ac_last_try; then { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 diff --git a/configure.in b/configure.in index d031b3a..a63b999 100644 --- a/configure.in +++ b/configure.in @@ -91,6 +91,58 @@ AC_SUBST(BUILD_CC) AC_SUBST(BUILD_CFLAGS) AC_SUBST(BUILD_LDFLAGS) +# +# Threading options. +# +# Client - thread-safe or not +# --disable-thread-safety : chooses null or posix locking mechanism +# For applications that know they are not multi-threaded, or choose +# to handle locking themselves, this configure option can be used to +# slightly decrease library-induced latency by removing the locking. +# +# Client - job threading +# libpvfs2-threaded.{so,a} with __PVFS2_JOB_THREADED__ +# This option causes the client library to spawn an extra thread +# to handle network communications. In this way, it is possible +# that the library can handle new and completed requests from +# the application while also interacting with the network. +# +# These separate libraries can not be built using the existing +# configure mechanism. They are only built if required by the +# kernel module helper. +# +# Server - three options: +# trove +# (hack Makefile.in) +# job +# (hack Makefile.in) +# aio +# --disable-aio-threaded-callbacks +# +# Trove (storage) and job threading in the server are implemented +# using #defines, but not exported through the configure mechanism. +# AIO threaded callbacks are a separate thread used in conjunction +# with trove, and can be disabled through a configure option as +# AIO has been found to be buggy on many systems. +# +# +# Kernel module helper - job threading +# --enable-threaded-kmod-helper +# +# This is a special client that "helps" applications that access PVFS +# through the kernel using normal VFS calls (e.g. "ls"). This +# configure options builds it using __PVFS2_JOB_THREADED__ as described +# above. That enables a thread for the network layer and a thread +# for the kernel interface. This has the potential to increase the +# rate at which concurrent operations are processed, but has the potential +# drawback of somewhat higher overhead for a single operation and lack +# of testing. +# +# Enabling this options causes one of libpvfs2-threaded.{so,a} to be +# built, depending on --enable-shared and --enable-static. If both are +# enabled, the shared library takes precedence. +# + dnl a mechanism to turn off threads in the client library AC_MSG_CHECKING([for client library thread safety support]) AC_ARG_ENABLE(thread-safety, @@ -346,7 +398,7 @@ AC_TRY_COMPILE( #include ], [ - struct aiocb; + struct aiocb aiocb; aiocb.__error_code = 0; ], AC_MSG_RESULT(yes) @@ -362,7 +414,7 @@ AC_TRY_COMPILE( #include ], [ - struct aiocb; + struct aiocb aiocb; aiocb.__return_value = 0; ], AC_MSG_RESULT(yes) @@ -523,6 +575,19 @@ if test -n "$lk_src" ; then AC_DEFINE(WITH_LINUX_KMOD, 1, [Define to build for linux kernel module userspace helper.]) fi +dnl +dnl Enabling this option links pvfs2-client-core against libpvfs2-threaded.so. +dnl Note that even without this option, pvfs2-client-core always requires +dnl pthreads to run its remount thread. +dnl +AC_ARG_ENABLE([threaded-kmod-helper], +[ --enable-threaded-kmod-helper Use threads in the kernel helper application], +[ if test "x$enableval" = "xyes" ; then + THREADED_KMOD_HELPER=yes + fi +]) +AC_SUBST(THREADED_KMOD_HELPER) + dnl PAV configuration needs absolute location of source and build. dnl Linux-2.6 module needs absolute location of source, and uses the dnl relative location for soft links for out-of-tree builds. @@ -619,7 +684,20 @@ AC_ARG_ENABLE(epoll, dnl enables a hack to print back traces out of segfault signal handler AC_ARG_ENABLE(segv-backtrace, [ --disable-segv-backtrace Disables back traces in segfault signal handler],, - PVFS2_SEGV_BACKTRACE=1) + AC_MSG_CHECKING(if segv backtrace capable) + AC_TRY_COMPILE([ +#include +#define __USE_GNU +#include +#if !defined(REG_EIP) && !defined(REG_RIP) + choke me +#endif + ], [], + AC_MSG_RESULT(yes) + PVFS2_SEGV_BACKTRACE=1, + AC_MSG_RESULT(no) + ) +) AC_SUBST(PVFS2_SEGV_BACKTRACE) dnl shared or static client library @@ -776,48 +854,15 @@ AC_ARG_WITH(bmi-tcp, ) AC_SUBST(BUILD_BMI_TCP) -dnl configure options for GM install path -GM_HOME= -AC_ARG_WITH(gm, -[ --with-gm= Location of the GM installation (default no GM)], - if test -z "$withval" -o "$withval" = yes ; then - AC_MSG_ERROR([Option --with-gm requires the path to your GM tree.]) - elif test "$withval" != no ; then - GM_HOME="$withval" - fi -) -if test -n "$GM_HOME" ; then - save_cppflags="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS -I ${GM_HOME}/include -I ${GM_HOME}/include/gm" - AC_CHECK_HEADER(gm.h,, AC_MSG_ERROR([Header gm.h not found.])) - BUILD_GM=1 - CPPFLAGS="$save_cppflags" -fi -AC_SUBST(GM_HOME) -AC_SUBST(BUILD_GM) +dnl +dnl Configure bmi_gm, if --with-gm or a variant given. +dnl +AX_GM -dnl configure options for MX install path -MX_HOME= -AC_ARG_WITH(mx, -[ --with-mx= Location of the MX installation (default no MX)], - if test -z "$withval" -o "$withval" = yes ; then - AC_MSG_ERROR([Option --with-mx requires the path to your MX tree.]) - elif test "$withval" != no ; then - MX_HOME="$withval" - fi -) -if test -n "$MX_HOME" ; then - CPPFLAGS="$CPPFLAGS -I ${MX_HOME}/include" - AC_CHECK_HEADER(myriexpress.h,, AC_MSG_ERROR([Header myriexpress.h not found.])) - BUILD_MX=1 - CPPFLAGS="$CPPFLAGS_OLD" - CFLAGS="${CFLAGS} -I${MX_HOME}/include" - LDFLAGS="$LDFLAGS -L${MX_HOME}/lib" - SERVER_LDFLAGS="$SERVER_LDFLAGS -L${MX_HOME}/lib" - LIBS="$LIBS -lmyriexpress" -fi -AC_SUBST(MX_HOME) -AC_SUBST(BUILD_MX) +dnl +dnl Configure bmi_mx, if --with-mx or a variant given. +dnl +AX_MX dnl dnl Configure bmi_ib, if --with-ib or a variant given. diff --git a/doc/REFERENCES.bib b/doc/REFERENCES.bib index 6cd95bd..037be30 100644 --- a/doc/REFERENCES.bib +++ b/doc/REFERENCES.bib @@ -36,6 +36,7 @@ @inproceedings{SC07 location = "Reno, NV", month = "November", year = "2007", + URL = "http://cholera.ece.northwestern.edu/~aching/research_webpage/publications/2007sc_2.pdf" } @inproceedings{IPDPS07, diff --git a/examples/heartbeat/Filesystem-qla-monitor b/examples/heartbeat/Filesystem-qla-monitor index 67cf96a..86e7ba2 100644 --- a/examples/heartbeat/Filesystem-qla-monitor +++ b/examples/heartbeat/Filesystem-qla-monitor @@ -1,6 +1,6 @@ #!/bin/sh # -# $Id: Filesystem-qla-monitor,v 1.1 2007/11/07 21:54:12 slang Exp $ +# $Id: Filesystem-qla-monitor,v 1.2 2008/01/28 19:45:17 pcarns Exp $ # # Support: linux-ha@lists.linux-ha.org # License: GNU General Public License (GPL) @@ -81,7 +81,12 @@ ####################################################################### # Initialization: +# newer versions of heartbeat have moved the ocf-shellfuncs file +if [ -f /usr/lib/ocf/resource.d/heartbeat/.ocf-shellfuncs ] ; then +. /usr/lib/ocf/resource.d/heartbeat/.ocf-shellfuncs +else . /usr/lib/heartbeat/ocf-shellfuncs +fi ####################################################################### @@ -103,7 +108,7 @@ check_util () { usage() { cat <<-EOT usage: $0 {start|stop|status|monitor|validate-all|meta-data} - $Id: Filesystem-qla-monitor,v 1.1 2007/11/07 21:54:12 slang Exp $ + $Id: Filesystem-qla-monitor,v 1.2 2008/01/28 19:45:17 pcarns Exp $ EOT } diff --git a/examples/heartbeat/PVFS2 b/examples/heartbeat/PVFS2 index 1de0419..1c50291 100644 --- a/examples/heartbeat/PVFS2 +++ b/examples/heartbeat/PVFS2 @@ -27,7 +27,12 @@ VARRUN=/var/run +# newer versions of heartbeat have moved the ocf-shellfuncs file +if [ -f /usr/lib/ocf/resource.d/heartbeat/.ocf-shellfuncs ] ; then +. /usr/lib/ocf/resource.d/heartbeat/.ocf-shellfuncs +else . /usr/lib/heartbeat/ocf-shellfuncs +fi ####################################################################### # @@ -172,8 +177,18 @@ stop_pvfs2() { if ProcessRunning $PVFS2PID then - ocf_log info "$CMD still running ($PVFS2PID)." - false + sleep 1 + kill -9 $PVFS2PID >/dev/null 2>&1 + ocf_log warn "Killing (-9) pvfs2-server PID $PVFS2PID" + sleep 5 + if + ProcessRunning $PVFS2PID + then + ocf_log info "$CMD still running ($PVFS2PID)." + false + else + ocf_log info "$CMD stopped." + fi else ocf_log info "$CMD stopped." fi diff --git a/examples/heartbeat/PVFS2-notify b/examples/heartbeat/PVFS2-notify index 3acc817..1cfc241 100644 --- a/examples/heartbeat/PVFS2-notify +++ b/examples/heartbeat/PVFS2-notify @@ -21,7 +21,12 @@ MAILTOFILE=$VARRUN/PVFS2_notify ####################################################################### # Initialization: +# newer versions of heartbeat have moved the ocf-shellfuncs file +if [ -f /usr/lib/ocf/resource.d/heartbeat/.ocf-shellfuncs ] ; then +. /usr/lib/ocf/resource.d/heartbeat/.ocf-shellfuncs +else . /usr/lib/heartbeat/ocf-shellfuncs +fi ####################################################################### @@ -31,7 +36,7 @@ us=`uname -n` usage() { echo "Usage: $0 {start|stop|status|monitor|meta-data|validate-all}" - echo "$Id: PVFS2-notify,v 1.1 2007/11/07 21:54:12 slang Exp $" + echo "$Id: PVFS2-notify,v 1.2 2008/01/28 19:45:17 pcarns Exp $" } meta_data() { diff --git a/examples/heartbeat/apc-switched-pdu-hybrid-control.pl b/examples/heartbeat/apc-switched-pdu-hybrid-control.pl index bc3e306..cf4b1e3 100644 --- a/examples/heartbeat/apc-switched-pdu-hybrid-control.pl +++ b/examples/heartbeat/apc-switched-pdu-hybrid-control.pl @@ -45,7 +45,6 @@ my $snmp_output = `$snmp_command 2>&1`; if ( $? == 0 ) { - print "Success, snmp\n"; exit 0; } @@ -55,7 +54,6 @@ my $ssh_output = `$ssh_command 2>&1`; if ( $? == 0 ) { - print "Success, ssh\n"; exit 0; } diff --git a/examples/heartbeat/apc-switched-pdu-hybrid-outlet-status.pl b/examples/heartbeat/apc-switched-pdu-hybrid-outlet-status.pl new file mode 100644 index 0000000..2204f0d --- /dev/null +++ b/examples/heartbeat/apc-switched-pdu-hybrid-outlet-status.pl @@ -0,0 +1,124 @@ +#!/usr/bin/perl + +# requires APC MIB file, which is available for download from APC's web site + +# this script will first attempt to use SNMP to send power control commands, +# and then fail back to using SSH + +use strict; +use Getopt::Long; +use File::Find; +use File::Path; +use POSIX qw(setsid); +use Socket; + +my $host; +my $ssh_user; +my $ssh_pass; +my $snmp_user; +my $snmp_pass; +my $outlet; + +my $snmp_command; + +&process_args; + +$snmp_command = "snmpget -v3 -a MD5 -l authNoPriv -u $snmp_user -A $snmp_pass -m \"/var/lib/filesystems/powernet387.mib\" $host PowerNet-MIB::rPDUOutletControlOutletCommand.$outlet"; + +my $snmp_output = `$snmp_command 2>&1`; +if ( $? == 0 ) +{ + if($snmp_output =~ /immediateOn/) + { + print "On\n"; + } + elsif($snmp_output =~ /immediateOff/) + { + print "Off\n"; + } + else + { + print "Unknown\n"; + } + + exit 0; +} + +# no fall back to ssh implemented in this script + +print "Error: failed to contact APC unit.\n"; +print "SNMP output: $snmp_output"; +print "SSH unsupported in this utility.\n"; + +exit 1; + +sub process_args +{ + # Parse the command line options + # For a description of the command line options see &print_help + use vars qw( $opt_help $opt_host $opt_ssh_user $opt_ssh_pass $opt_snmp_user $opt_snmp_pass $opt_outlet); + + Getopt::Long::Configure( "no_ignore_case", "bundling"); + GetOptions( "help", + "host=s", + "ssh-user=s", + "ssh-pass=s", + "snmp-user=s", + "snmp-pass=s", + "outlet=i"); + + if ($opt_help) + { + &print_help; + exit(0); + } + + if(!$opt_host || !$opt_ssh_user || !$opt_ssh_pass || + !$opt_snmp_user || !$opt_snmp_pass || !$opt_outlet) + { + &print_help; + die "Error: missing arguments.\n"; + } + + $host = $opt_host; + $ssh_user = $opt_ssh_user; + $ssh_pass = $opt_ssh_pass; + $snmp_user = $opt_snmp_user; + $snmp_pass = $opt_snmp_pass; + $outlet = $opt_outlet; +} + + +# --------------- print help information ------------------------------ +sub print_help { + + print < + +options: + --help print this help and exit + --host hostname of APC unit + --ssh-user ssh username for APC unit + --ssh-pass ssh password for APC unit + --snmp-user SNMP username for APC unit + --snmp-pass SNMP authentication pass phrase (MD5) for APC unit + --outlet APC outlet to control + +EOF +} + +# Local variables: +# c-basic-offset: 3 +# perl-indent-level: 3 +# tab-width: 3 +# indent-tabs-mode: nil +# shiftwidth: 3 +# End: +# +# vim: ts=3 expandtab + diff --git a/examples/heartbeat/pvfs2-ha-heartbeat-configure.sh b/examples/heartbeat/pvfs2-ha-heartbeat-configure.sh index 4204dc3..4c04b77 100644 --- a/examples/heartbeat/pvfs2-ha-heartbeat-configure.sh +++ b/examples/heartbeat/pvfs2-ha-heartbeat-configure.sh @@ -30,6 +30,7 @@ echo "auto_failback off" >> ${OUTDIR}/ha.cf echo "use_logd no" >> ${OUTDIR}/ha.cf echo "respawn hacluster /usr/lib/heartbeat/cibmon -d" >> ${OUTDIR}/ha.cf echo "crm yes" >> ${OUTDIR}/ha.cf +echo "compression bz2" >> ${OUTDIR}/ha.cf # shift arguments down shift diff --git a/include/pvfs2-debug.h b/include/pvfs2-debug.h index 628426d..49ebc90 100644 --- a/include/pvfs2-debug.h +++ b/include/pvfs2-debug.h @@ -72,7 +72,8 @@ #define GOSSIP_BMI_DEBUG_MX ((uint64_t)1 << 50) #define GOSSIP_BSTREAM_DEBUG ((uint64_t)1 << 51) #define GOSSIP_BMI_DEBUG_PORTALS ((uint64_t)1 << 52) -#define GOSSIP_BMI_DEBUG_OSD ((uint64_t)1 << 53) +#define GOSSIP_USER_DEV_DEBUG ((uint64_t)1 << 53) +#define GOSSIP_BMI_DEBUG_OSD ((uint64_t)1 << 54) /* NOTE: if you want your gossip flag to be controllable from * pvfs2-set-debugmask you have to add it in diff --git a/maint/config/gm.m4 b/maint/config/gm.m4 new file mode 100644 index 0000000..06fb152 --- /dev/null +++ b/maint/config/gm.m4 @@ -0,0 +1,72 @@ +# +# Configure rules for GM +# +# Copyright (C) 2008 Pete Wyckoff +# +# See COPYING in top-level directory. +# +AC_DEFUN([AX_GM], +[ + dnl Configure options for GM install path. + dnl --with-gm= is shorthand for + dnl --with-gm-includes=/include + dnl --with-gm-libs=/lib (or lib64 if that exists) + gm_home= + AC_ARG_WITH(gm, + [ --with-gm= Location of the GM install (default no GM)], + if test -z "$withval" -o "$withval" = yes ; then + AC_MSG_ERROR([Option --with-gm requires the path to your GM tree.]) + elif test "$withval" != no ; then + gm_home="$withval" + fi + ) + AC_ARG_WITH(gm-includes, + [ --with-gm-includes= Location of the GM includes], + if test -z "$withval" -o "$withval" = yes ; then + AC_MSG_ERROR([Option --with-gm-includes requires path to GM headers.]) + elif test "$withval" != no ; then + GM_INCDIR="$withval" + fi + ) + AC_ARG_WITH(gm-libs, + [ --with-gm-libs= Location of the GM libraries], + if test -z "$withval" -o "$withval" = yes ; then + AC_MSG_ERROR([Option --with-gm-libs requires path to GM libraries.]) + elif test "$withval" != no ; then + GM_LIBDIR="$withval" + fi + ) + dnl If supplied the incls and libs explicitly, use them, else populate them + dnl using guesses from the --with-gm dir. + if test -n "$gm_home" ; then + if test -z "$GM_INCDIR"; then + GM_INCDIR=$gm_home/include + fi + if test -z "$GM_LIBDIR"; then + GM_LIBDIR=$gm_home/lib64 + if test ! -d "$GM_LIBDIR" ; then + GM_LIBDIR=$gm_home/lib + fi + fi + fi + dnl If anything GM-ish was set, go look for header. + if test -n "$GM_INCDIR$GM_LIBDIR" ; then + save_cppflags="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS -I$GM_INCDIR -I$GM_INCDIR/gm" + AC_CHECK_HEADER(gm.h,, AC_MSG_ERROR([Header gm.h not found.])) + dnl Run test is not possible on a machine that does not have a GM NIC. + dnl Link test would work, but just check for existence. + if test ! -f $GM_LIBDIR/libgm.so ; then + if test ! -f $GM_LIBDIR/libgm.a ; then + AC_MSG_ERROR([Neither GM library libgm.so or libgm.a found.]) + fi + fi + BUILD_GM=1 + CPPFLAGS="$save_cppflags" + fi + AC_SUBST(BUILD_GM) + AC_SUBST(GM_INCDIR) + AC_SUBST(GM_LIBDIR) +]) + +dnl vim: set ft=config : diff --git a/maint/config/kernel.m4 b/maint/config/kernel.m4 index 95ada22..6536b1f 100644 --- a/maint/config/kernel.m4 +++ b/maint/config/kernel.m4 @@ -17,6 +17,11 @@ AC_DEFUN([AX_KERNEL_FEATURES], CFLAGS="$USR_CFLAGS $NOSTDINCFLAGS -I$lk_src/include -I$lk_src/include/asm/mach-default -DKBUILD_STR(s)=#s -DKBUILD_BASENAME=KBUILD_STR(empty) -DKBUILD_MODNAME=KBUILD_STR(empty) -imacros $lk_src/include/linux/autoconf.h" + dnl we probably need additional includes if this build is intended + dnl for a different architecture + if test -n "${ARCH}" ; then + CFLAGS="$CFLAGS -I$lk_src/arch/${ARCH}/include" + fi AC_MSG_CHECKING(for i_size_write in kernel) dnl if this test passes, the kernel does not have it @@ -943,5 +948,19 @@ AC_DEFUN([AX_KERNEL_FEATURES], AC_MSG_RESULT(no) ) + dnl Starting with 2.6.25-rc1, .read_inode goes away. + AC_MSG_CHECKING(if kernel super_operations contains read_inode field) + AC_TRY_COMPILE([ + #define __KERNEL__ + #include + ], [ + struct super_operations sops; + sops.read_inode(NULL); + ], + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_READ_INODE, 1, [Define if kernel super_operations contains read_inode field]), + AC_MSG_RESULT(no) + ) + CFLAGS=$oldcflags ]) diff --git a/maint/config/mx.m4 b/maint/config/mx.m4 new file mode 100644 index 0000000..ab5d151 --- /dev/null +++ b/maint/config/mx.m4 @@ -0,0 +1,73 @@ +# +# Configure rules for MX +# +# Copyright (C) 2008 Pete Wyckoff +# +# See COPYING in top-level directory. +# +AC_DEFUN([AX_MX], +[ + dnl Configure options for MX install path. + dnl --with-mx= is shorthand for + dnl --with-mx-includes=/include + dnl --with-mx-libs=/lib (or lib64 if that exists) + mx_home= + AC_ARG_WITH(mx, + [ --with-mx= Location of the MX install (default no MX)], + if test -z "$withval" -o "$withval" = yes ; then + AC_MSG_ERROR([Option --with-mx requires the path to your MX tree.]) + elif test "$withval" != no ; then + mx_home="$withval" + fi + ) + AC_ARG_WITH(mx-includes, + [ --with-mx-includes= Location of the MX includes], + if test -z "$withval" -o "$withval" = yes ; then + AC_MSG_ERROR([Option --with-mx-includes requires path to MX headers.]) + elif test "$withval" != no ; then + MX_INCDIR="$withval" + fi + ) + AC_ARG_WITH(mx-libs, + [ --with-mx-libs= Location of the MX libraries], + if test -z "$withval" -o "$withval" = yes ; then + AC_MSG_ERROR([Option --with-mx-libs requires path to MX libraries.]) + elif test "$withval" != no ; then + MX_LIBDIR="$withval" + fi + ) + dnl If supplied the incls and libs explicitly, use them, else populate them + dnl using guesses from the --with-mx dir. + if test -n "$mx_home" ; then + if test -z "$MX_INCDIR"; then + MX_INCDIR=$mx_home/include + fi + if test -z "$MX_LIBDIR"; then + MX_LIBDIR=$mx_home/lib64 + if test ! -d "$MX_LIBDIR" ; then + MX_LIBDIR=$mx_home/lib + fi + fi + fi + dnl If anything MX-ish was set, go look for header. + if test -n "$MX_INCDIR$MX_LIBDIR" ; then + save_cppflags="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS -I$MX_INCDIR -I$MX_INCDIR/mx" + AC_CHECK_HEADER(myriexpress.h,, + AC_MSG_ERROR([Header myriexpress.h not found.])) + dnl Run test is not possible on a machine that does not have a MX NIC. + dnl Link test would work, but just check for existence. + if test ! -f $MX_LIBDIR/libmyriexpress.so ; then + if test ! -f $MX_LIBDIR/libmyriexpress.a ; then + AC_MSG_ERROR([Neither MX library libmyriexpress.so or libmyriexpress.a found.]) + fi + fi + BUILD_MX=1 + CPPFLAGS="$save_cppflags" + fi + AC_SUBST(BUILD_MX) + AC_SUBST(MX_INCDIR) + AC_SUBST(MX_LIBDIR) +]) + +dnl vim: set ft=config : diff --git a/maint/config/portals.m4 b/maint/config/portals.m4 index e02a645..2395cbc 100644 --- a/maint/config/portals.m4 +++ b/maint/config/portals.m4 @@ -74,7 +74,7 @@ AC_DEFUN([AX_PORTALS], CPPFLAGS="$CPPFLAGS $PORTALS_INCS" PORTALS_LIBS="$libs" - LIBS="$LIBS $PORTALS_LIBS" + LIBS="$save_libs $PORTALS_LIBS" AC_MSG_CHECKING([for portals3.h header]) ok=no @@ -102,7 +102,7 @@ AC_DEFUN([AX_PORTALS], if test "$ok" = no ; then PORTALS_LIBS="$libs -lportals" - LIBS="$LIBS $PORTALS_LIBS" + LIBS="$save_libs $PORTALS_LIBS" AC_TRY_LINK( [#include ], [int m, n; m = PtlInit(&n);], @@ -111,7 +111,7 @@ AC_DEFUN([AX_PORTALS], if test "$ok" = no ; then PORTALS_LIBS="$libs -lp3api -lp3lib -lp3utcp -lp3rt -lpthread" - LIBS="$LIBS $PORTALS_LIBS" + LIBS="$save_libs $PORTALS_LIBS" AC_TRY_LINK( [#include ], [int m, n; m = PtlInit(&n);], diff --git a/maint/make-dist.sh b/maint/make-dist.sh index c6858be..5bacc51 100644 --- a/maint/make-dist.sh +++ b/maint/make-dist.sh @@ -19,19 +19,20 @@ if test -z $2; then exit 1 fi +BUILDDIR=$(pwd) SRCDIR="$1" PVFS2_VERSION="$2" if test "x$SRCDIR" = "x."; then - SRCDIR=`pwd` + SRCIR=`pwd` echo "Assuming top-level source directory is $SRCDIR" fi STARTDIR=`pwd` TARGETBASE="pvfs-$PVFS2_VERSION" TARGETDIR="/tmp/$TARGETBASE" -TARFILE_NAME="$SRCDIR/pvfs-$PVFS2_VERSION.tar" -TARBALL_NAME="$SRCDIR/pvfs-$PVFS2_VERSION.tar.gz" +TARFILE_NAME="$BUILDDIR/pvfs-$PVFS2_VERSION.tar" +TARBALL_NAME="$BUILDDIR/pvfs-$PVFS2_VERSION.tar.gz" TAR=`which tar` GZIP=`which gzip` @@ -50,7 +51,7 @@ fi ################## make clean make docs -make statecomp +make statecompgen if test -d $TARGETDIR; then rm -rf $TARGETDIR @@ -58,6 +59,9 @@ fi mkdir $TARGETDIR cp -f --no-dereference -R $SRCDIR/* $TARGETDIR +cp $BUILDDIR/src/common/statecomp/parser.h $TARGETDIR/src/common/statecomp/ +cp $BUILDDIR/src/common/statecomp/parser.c $TARGETDIR/src/common/statecomp/ +cp $BUILDDIR/src/common/statecomp/scanner.c $TARGETDIR/src/common/statecomp/ cd $TARGETDIR @@ -72,8 +76,8 @@ for f in `find . -name module.mk`; do rm -rf $f; done for f in `find . -name "*.log"`; do rm -rf $f; done for f in `find . -name "*.toc"`; do rm -rf $f; done for f in `find . -name "*.aux"`; do rm -rf $f; done -rm Makefile pvfs2-config.h PVFS2-GLOBAL-TODO.txt -rm src/common/statecomp/statecomp +rm -f Makefile pvfs2-config.h PVFS2-GLOBAL-TODO.txt +rm -f src/common/statecomp/statecomp # dump some special options into the top level module.mk.in echo "DIST_RELEASE = 1" >> module.mk.in diff --git a/pvfs2-config.h.in b/pvfs2-config.h.in index a6d623e..58e4143 100644 --- a/pvfs2-config.h.in +++ b/pvfs2-config.h.in @@ -262,6 +262,9 @@ /* Define if struct file_operations in kernel has readx callback */ #undef HAVE_READX_FILE_OPERATIONS +/* Define if kernel super_operations contains read_inode field */ +#undef HAVE_READ_INODE + /* Define if kernel has register_ioctl32_conversion */ #undef HAVE_REGISTER_IOCTL32_CONVERSION diff --git a/src/apps/admin/pvfs2-config.in b/src/apps/admin/pvfs2-config.in index 656165b..c863ec0 100755 --- a/src/apps/admin/pvfs2-config.in +++ b/src/apps/admin/pvfs2-config.in @@ -47,7 +47,7 @@ while test $# -gt 0; do --libs|--static-libs) libflags="-L@libdir@ -lpvfs2 @LIBS@ @THREAD_LIB@" if [ x"@BUILD_GM@" = x"1" ]; then - libflags="$libflags -L@GM_HOME@/lib -lgm" + libflags="$libflags -L@GM_LIBDIR@ -lgm" fi if [ x"@BUILD_IB@" = x"1" ]; then libflags="$libflags -L@IB_LIBDIR@ -lvapi -lmtl_common -lmosal -lmpga -lpthread -ldl" @@ -56,7 +56,7 @@ while test $# -gt 0; do libflags="$libflags -L@OPENIB_LIBDIR@ -libverbs" fi if [ x"@BUILD_MX@" = x"1" ]; then - libflags="$libflags -L@MX_HOME@/lib -lmyriexpress" + libflags="$libflags -L@MX_LIBDIR@ -lmyriexpress -lpthread" fi if [ x"@BUILD_PORTALS@" = x"1" ]; then libflags="$libflags @PORTALS_LIBS@" @@ -73,7 +73,7 @@ while test $# -gt 0; do libflags="$libflags -lrt" fi if [ x"@BUILD_GM@" = x"1" ]; then - libflags="$libflags -L@GM_HOME@/lib -lgm" + libflags="$libflags -L@GM_LIBDIR@ -lgm" fi if [ x"@BUILD_IB@" = x"1" ]; then libflags="$libflags -L@IB_LIBDIR@ -lvapi -lmtl_common -lmosal -lmpga -lpthread -ldl" @@ -82,7 +82,7 @@ while test $# -gt 0; do libflags="$libflags -L@OPENIB_LIBDIR@ -libverbs" fi if [ x"@BUILD_MX@" = x"1" ]; then - libflags="$libflags -L@MX_HOME@/lib -lmyriexpress" + libflags="$libflags -L@MX_LIBDIR@ -lmyriexpress -lpthread" fi if [ x"@BUILD_PORTALS@" = x"1" ]; then libflags="$libflags @PORTALS_LIBS@" diff --git a/src/apps/admin/pvfs2-genconfig b/src/apps/admin/pvfs2-genconfig index ebf2cf9..b6168e6 100755 --- a/src/apps/admin/pvfs2-genconfig +++ b/src/apps/admin/pvfs2-genconfig @@ -1523,7 +1523,6 @@ my $client_job_timeout = get_client_job_timeout(); if (!$opt_quiet) { print $OUT "Writing fs config file... "; - print $OUT "done\n"; } emit_defaults($output_target, $num_unexp_reqs, @@ -1546,8 +1545,22 @@ if ($opt_metaspec) { if ($using_stdout == 0) { close($output_target); + + my $req_limit = 65536; + + if(-s $ARGV[0] > $req_limit) + { + my $size = (-s $ARGV[0]); + print STDERR +"Warning: Generated config file: " . $ARGV[0] . "\n" . +"has size: $size, which is larger than the current PVFS request: $req_limit\n" . +"Increase the value of PVFS_REQ_LIMIT_CONFIG_FILE_BYTES in src/proto/pvfs2-req-proto.h\n"; + } } +if (!$opt_quiet) { + print $OUT "done\n"; +} # Local variables: # c-indent-level: 4 diff --git a/src/apps/admin/pvfs2-ls.c b/src/apps/admin/pvfs2-ls.c index eb94981..1d69a8f 100644 --- a/src/apps/admin/pvfs2-ls.c +++ b/src/apps/admin/pvfs2-ls.c @@ -31,12 +31,6 @@ */ #define MAX_NUM_DIRENTS 32 -/* - arbitrarily restrict the number of paths - that this ls version can take as arguments -*/ -#define MAX_NUM_PATHS 8 - /* optional parameters, filled in by parse_args() */ struct options { @@ -51,7 +45,7 @@ struct options int list_no_owner; int list_inode; int list_use_si_units; - char *start[MAX_NUM_PATHS]; + char **start; int num_starts; }; @@ -683,19 +677,17 @@ static struct options* parse_args(int argc, char* argv[]) exit(EXIT_FAILURE); } } + tmp_opts->start = (char **) calloc(1, (argc-optind+1) * sizeof(char *)); + if (tmp_opts->start == NULL) { + exit(EXIT_FAILURE); + } for(i = optind; i < argc; i++) { - if (tmp_opts->num_starts < MAX_NUM_PATHS) - { - tmp_opts->start[i-optind] = argv[i]; - tmp_opts->num_starts++; - } - else - { - fprintf(stderr,"Ignoring path %s\n",argv[i]); - } + tmp_opts->start[i-optind] = argv[i]; + tmp_opts->num_starts++; } + assert(tmp_opts->num_starts < (argc - optind + 1)); return tmp_opts; } @@ -738,8 +730,8 @@ static void usage(int argc, char** argv) int main(int argc, char **argv) { int ret = -1, i = 0; - char pvfs_path[MAX_NUM_PATHS][PVFS_NAME_MAX]; - PVFS_fs_id fs_id_array[MAX_NUM_PATHS] = {0}; + char **pvfs_path; + PVFS_fs_id *fs_id_array = NULL; const PVFS_util_tab* tab; struct options* user_opts = NULL; char current_dir[PVFS_NAME_MAX] = {0}; @@ -761,12 +753,7 @@ int main(int argc, char **argv) return(-1); } - for(i = 0; i < MAX_NUM_PATHS; i++) - { - memset(pvfs_path[i],0,PVFS_NAME_MAX); - } - - ret = PVFS_sys_initialize(GOSSIP_NO_DEBUG); + ret = PVFS_sys_initialize(GOSSIP_NO_DEBUG); if (ret < 0) { PVFS_perror("PVFS_sys_initialize", ret); @@ -799,6 +786,28 @@ int main(int argc, char **argv) user_opts->num_starts = 1; } + pvfs_path = (char **) calloc(1, user_opts->num_starts * sizeof(char *)); + if (!pvfs_path) + { + fprintf(stderr, "Could not alloc memory\n"); + return -1; + } + for(i = 0; i < user_opts->num_starts; i++) + { + pvfs_path[i] = (char *) calloc(1, PVFS_NAME_MAX); + if (pvfs_path[i] == NULL) + { + fprintf(stderr, "Could not alloc memory\n"); + return -1; + } + } + fs_id_array = (PVFS_fs_id *) calloc(1, user_opts->num_starts * sizeof(*fs_id_array)); + if (fs_id_array == NULL) + { + fprintf(stderr, "Could not alloc memory\n"); + return -1; + } + for(i = 0; i < user_opts->num_starts; i++) { ret = PVFS_util_resolve(user_opts->start[i], @@ -830,8 +839,18 @@ int main(int argc, char **argv) printf("\n"); } } + for (i = 0; i < user_opts->num_starts; i++) + { + free(pvfs_path[i]); + } + free(user_opts->start); + free(pvfs_path); + free(fs_id_array); + free(user_opts); PVFS_sys_finalize(); + if (user_opts) + free(user_opts); return(ret); } diff --git a/src/apps/kernel/linux/module.mk.in b/src/apps/kernel/linux/module.mk.in index 7e71f5f..6e69bb8 100644 --- a/src/apps/kernel/linux/module.mk.in +++ b/src/apps/kernel/linux/module.mk.in @@ -1,11 +1,14 @@ DIR := src/apps/kernel/linux KERNAPPSRC += \ - $(DIR)/pvfs2-client-core.c \ $(DIR)/pvfs2-client.c -KERNAPPSTHRSRC += \ - $(DIR)/pvfs2-client-core.c +# if requested, build a threaded client core +ifeq (,@THREADED_KMOD_HELPER@) +KERNAPPSRC += $(DIR)/pvfs2-client-core.c +else +KERNAPPTHRSRC += $(DIR)/pvfs2-client-core.c +endif ifneq (,$(LINUX24_KERNEL_SRC)) KERNAPPSRC += $(DIR)/mount.pvfs2.c diff --git a/src/apps/kernel/linux/pvfs2-client-core.c b/src/apps/kernel/linux/pvfs2-client-core.c index 2305b73..ba7476d 100644 --- a/src/apps/kernel/linux/pvfs2-client-core.c +++ b/src/apps/kernel/linux/pvfs2-client-core.c @@ -227,27 +227,34 @@ static int write_device_response( job_status_s *jstat, job_context_id context); -#define write_inlined_device_response(vfs_request) \ -do { \ - void *buffer_list[MAX_LIST_SIZE]; \ - int size_list[MAX_LIST_SIZE]; \ - int list_size = 0, total_size = 0; \ - \ - log_operation_timing(vfs_request); \ - buffer_list[0] = &vfs_request->out_downcall; \ - size_list[0] = sizeof(pvfs2_downcall_t); \ - total_size = sizeof(pvfs2_downcall_t); \ - list_size = 1; \ - ret = write_device_response( \ - buffer_list,size_list,list_size, total_size, \ - vfs_request->info.tag, &vfs_request->op_id, \ - &vfs_request->jstat, s_client_dev_context); \ - if (ret < 0) \ - { \ - gossip_err("write_device_response failed (tag=%lld)\n",\ - lld(vfs_request->info.tag)); \ - } \ - vfs_request->was_handled_inline = 1; \ +#define write_inlined_device_response(vfs_request) \ +do { \ + void *buffer_list[MAX_LIST_SIZE]; \ + int size_list[MAX_LIST_SIZE]; \ + int list_size = 0, total_size = 0; \ + \ + log_operation_timing(vfs_request); \ + buffer_list[0] = &vfs_request->out_downcall; \ + size_list[0] = sizeof(pvfs2_downcall_t); \ + total_size = sizeof(pvfs2_downcall_t); \ + list_size = 1; \ + if(vfs_request->out_downcall.trailer_size > 0) \ + { \ + buffer_list[1] = vfs_request->out_downcall.trailer_buf; \ + size_list[1] = vfs_request->out_downcall.trailer_size; \ + list_size++; \ + total_size += vfs_request->out_downcall.trailer_size; \ + } \ + ret = write_device_response( \ + buffer_list,size_list,list_size, total_size, \ + vfs_request->info.tag, &vfs_request->op_id, \ + &vfs_request->jstat, s_client_dev_context); \ + if (ret < 0) \ + { \ + gossip_err("write_device_response failed (tag=%lld)\n", \ + lld(vfs_request->info.tag)); \ + } \ + vfs_request->was_handled_inline = 1; \ } while(0) static void client_segfault_handler(int signum) diff --git a/src/apps/kernel/linux/pvfs2-client.c b/src/apps/kernel/linux/pvfs2-client.c index dd38e39..09d2bad 100644 --- a/src/apps/kernel/linux/pvfs2-client.c +++ b/src/apps/kernel/linux/pvfs2-client.c @@ -28,7 +28,6 @@ #define PVFS2_CLIENT_CORE_SUFFIX "-core" #define PVFS2_CLIENT_CORE_NAME "pvfs2-client" PVFS2_CLIENT_CORE_SUFFIX -#define PVFS2_CLIENT_CORE_THR_SUFFIX "-threaded" static char s_client_core_path[PATH_MAX]; @@ -59,7 +58,6 @@ typedef struct char *logstamp; char *dev_buffer_count; char *dev_buffer_size; - int threaded; char *logtype; } options_t; @@ -282,15 +280,7 @@ static int monitor_pvfs2_client(options_t *opts) { sleep(1); - if(opts->threaded) - { - arg_list[0] = PVFS2_CLIENT_CORE_NAME PVFS2_CLIENT_CORE_THR_SUFFIX; - } - else - { - arg_list[0] = PVFS2_CLIENT_CORE_NAME; - } - + arg_list[0] = PVFS2_CLIENT_CORE_NAME; arg_index = 1; arg_list[arg_index++] = "-a"; arg_list[arg_index++] = opts->acache_timeout; @@ -429,7 +419,6 @@ static void print_help(char *progname) "PATH\n"); printf("--logstamp=none|usec|datetime override default log message time stamp format\n"); printf("--logtype=file|syslog specify writing logs to file or syslog\n"); - printf("--threaded use threaded client\n"); } static void parse_args(int argc, char **argv, options_t *opts) @@ -460,7 +449,6 @@ static void parse_args(int argc, char **argv, options_t *opts) {"gossip-mask",1,0,0}, {"path",1,0,0}, {"logstamp",1,0,0}, - {"threaded",0,0,0}, {0,0,0,0} }; @@ -569,11 +557,6 @@ static void parse_args(int argc, char **argv, options_t *opts) opts->gossip_mask = optarg; break; } - else if (strcmp("threaded", cur_option) == 0) - { - opts->threaded = 1; - break; - } break; case 'h': do_help: @@ -644,17 +627,7 @@ static void parse_args(int argc, char **argv, options_t *opts) if (!opts->path) { - if(opts->threaded) - { - sprintf(s_client_core_path, - "%s" PVFS2_CLIENT_CORE_SUFFIX PVFS2_CLIENT_CORE_THR_SUFFIX, - argv[0]); - } - else - { - sprintf(s_client_core_path, "%s" PVFS2_CLIENT_CORE_SUFFIX, - argv[0]); - } + sprintf(s_client_core_path, "%s" PVFS2_CLIENT_CORE_SUFFIX, argv[0]); opts->path = s_client_core_path; } diff --git a/src/client/sysint/client-state-machine.c b/src/client/sysint/client-state-machine.c index 1910dc3..53da044 100644 --- a/src/client/sysint/client-state-machine.c +++ b/src/client/sysint/client-state-machine.c @@ -91,8 +91,8 @@ static int conditional_remove_sm_if_in_completion_list(PINT_smcb *smcb) } else { - memmove(s_completion_list[i], - s_completion_list[i+1], + memmove(&s_completion_list[i], + &s_completion_list[i+1], (s_completion_list_index - (i + 1)) * sizeof(PINT_smcb *)); } @@ -301,7 +301,8 @@ int client_state_machine_terminate( if (!((PINT_smcb_op(smcb) == PVFS_SYS_IO) && (PINT_smcb_cancelled(smcb)) && - (cancelled_io_jobs_are_pending(smcb)))) + (cancelled_io_jobs_are_pending(smcb))) && + !PINT_smcb_immediate_completion(smcb)) { gossip_debug(GOSSIP_CLIENT_DEBUG, "add smcb %p to completion list\n", smcb); @@ -370,6 +371,7 @@ PVFS_error PINT_client_state_machine_post( /* save operation type; mark operation as unfinished */ sm_p->user_ptr = user_ptr; + gen_mutex_lock(&test_mutex); /* start state machine and continue advancing while we're getting immediate completions @@ -380,6 +382,7 @@ PVFS_error PINT_client_state_machine_post( if(sm_ret < 0) { /* state machine code failed */ + gen_mutex_unlock(&test_mutex); return sm_ret; } @@ -416,6 +419,7 @@ PVFS_error PINT_client_state_machine_post( lld((op_id ? *op_id : -1)), ret); } + gen_mutex_unlock(&test_mutex); return js.error_code; } diff --git a/src/client/sysint/fs-add.sm b/src/client/sysint/fs-add.sm index 86bfcc0..557ee01 100644 --- a/src/client/sysint/fs-add.sm +++ b/src/client/sysint/fs-add.sm @@ -134,7 +134,11 @@ PVFS_error PVFS_isys_fs_add( if (i == mntent->num_pvfs_config_servers) { gossip_err("%s: Failed to initialize any appropriate " - "BMI methods.\n", __func__); + "BMI methods for addresses:\n", __func__); + for(i = 0; i < mntent->num_pvfs_config_servers; ++i) + { + gossip_err("\t%s\n", mntent->pvfs_config_servers[i]); + } gen_mutex_unlock(&mt_config); return(ret); } diff --git a/src/client/sysint/mgmt-get-config.c b/src/client/sysint/mgmt-get-config.c index a893e1e..034472c 100755 --- a/src/client/sysint/mgmt-get-config.c +++ b/src/client/sysint/mgmt-get-config.c @@ -68,7 +68,7 @@ int PVFS_mgmt_get_config( config = PINT_get_server_config_struct(*fsid); mntent.the_pvfs_config_server = - (char*)PINT_cached_config_map_addr(config, *fsid, *addr, &server_type); + (char*)PINT_cached_config_map_addr(*fsid, *addr, &server_type); PINT_put_server_config_struct(config); diff --git a/src/client/sysint/mgmt-misc.c b/src/client/sysint/mgmt-misc.c index e481e2c..d370790 100644 --- a/src/client/sysint/mgmt-misc.c +++ b/src/client/sysint/mgmt-misc.c @@ -33,13 +33,7 @@ const char *PVFS_mgmt_map_addr( PVFS_BMI_addr_t addr, int *server_type) { - struct server_configuration_s *server_config = - PINT_get_server_config_struct(fs_id); - const char *ret = PINT_cached_config_map_addr( - server_config, fs_id, addr, server_type); - - PINT_put_server_config_struct(server_config); - return ret; + return PINT_cached_config_map_addr(fs_id, addr, server_type); } PVFS_error PVFS_mgmt_map_handle( @@ -47,8 +41,7 @@ PVFS_error PVFS_mgmt_map_handle( PVFS_handle handle, PVFS_BMI_addr_t *addr) { - return PINT_cached_config_map_to_server( - addr, handle, fs_id); + return PINT_cached_config_map_to_server(addr, handle, fs_id); } /** Obtains file system statistics from all servers in a given @@ -66,15 +59,10 @@ PVFS_error PVFS_mgmt_statfs_all( PVFS_error ret = -PVFS_EINVAL; PVFS_BMI_addr_t *addr_array = NULL; int real_count = 0; - struct server_configuration_s *server_config = NULL; - - server_config = PINT_get_server_config_struct(fs_id); - assert(server_config); ret = PINT_cached_config_count_servers( - server_config, fs_id, PVFS_MGMT_IO_SERVER|PVFS_MGMT_META_SERVER, + fs_id, PVFS_MGMT_IO_SERVER|PVFS_MGMT_META_SERVER, &real_count); - PINT_put_server_config_struct(server_config); if (ret < 0) { @@ -95,14 +83,10 @@ PVFS_error PVFS_mgmt_statfs_all( return -PVFS_ENOMEM; } - server_config = PINT_get_server_config_struct(fs_id); - assert(server_config); - /* generate default list of servers */ ret = PINT_cached_config_get_server_array( - server_config, fs_id, PVFS_MGMT_IO_SERVER|PVFS_MGMT_META_SERVER, + fs_id, PVFS_MGMT_IO_SERVER|PVFS_MGMT_META_SERVER, addr_array, &real_count); - PINT_put_server_config_struct(server_config); if (ret < 0) { @@ -135,15 +119,8 @@ PVFS_error PVFS_mgmt_setparam_all( int i, j, count = 0; PVFS_error ret = -PVFS_EINVAL; PVFS_BMI_addr_t *addr_array = NULL; - struct server_configuration_s *server_config = NULL; - - server_config = PINT_get_server_config_struct(fs_id); - assert(server_config); - ret = PINT_cached_config_count_servers( - server_config, fs_id, - PVFS_MGMT_IO_SERVER|PVFS_MGMT_META_SERVER, &count); - PINT_put_server_config_struct(server_config); + fs_id, PVFS_MGMT_IO_SERVER|PVFS_MGMT_META_SERVER, &count); if (ret < 0) { @@ -157,14 +134,10 @@ PVFS_error PVFS_mgmt_setparam_all( return -PVFS_ENOMEM; } - server_config = PINT_get_server_config_struct(fs_id); - assert(server_config); - /* generate default list of servers */ ret = PINT_cached_config_get_server_array( - server_config, fs_id, PVFS_MGMT_IO_SERVER|PVFS_MGMT_META_SERVER, + fs_id, PVFS_MGMT_IO_SERVER|PVFS_MGMT_META_SERVER, addr_array, &count); - PINT_put_server_config_struct(server_config); if (ret < 0) { @@ -228,14 +201,9 @@ PVFS_error PVFS_mgmt_get_server_array( int *inout_count_p) { PVFS_error ret = -PVFS_EINVAL; - struct server_configuration_s *server_config = NULL; - - server_config = PINT_get_server_config_struct(fs_id); - assert(server_config); ret = PINT_cached_config_get_server_array( - server_config, fs_id, server_type, addr_array, inout_count_p); - PINT_put_server_config_struct(server_config); + fs_id, server_type, addr_array, inout_count_p); return ret; } @@ -253,14 +221,8 @@ PVFS_error PVFS_mgmt_count_servers( int *count) { PVFS_error ret = -PVFS_EINVAL; - struct server_configuration_s *server_config = NULL; - server_config = PINT_get_server_config_struct(fs_id); - assert(server_config); - - ret = PINT_cached_config_count_servers( - server_config, fs_id, server_type, count); - PINT_put_server_config_struct(server_config); + ret = PINT_cached_config_count_servers(fs_id, server_type, count); return ret; } diff --git a/src/client/sysint/server-get-config.sm b/src/client/sysint/server-get-config.sm index a8aee35..c296af8 100644 --- a/src/client/sysint/server-get-config.sm +++ b/src/client/sysint/server-get-config.sm @@ -250,6 +250,12 @@ static int server_parse_config( { ret = PINT_parse_config(config, fs_template, NULL); } + else + { + gossip_err("Failed to write fs.conf buffer to temp file: %s: %s\n", + fs_template, strerror(errno)); + } + close(fs_fd); remove(fs_template); diff --git a/src/client/sysint/sys-create.sm b/src/client/sysint/sys-create.sm index b09ed24..6167954 100644 --- a/src/client/sysint/sys-create.sm +++ b/src/client/sysint/sys-create.sm @@ -687,7 +687,6 @@ static PINT_sm_action create_dspace_create_setup_msgpair( int ret = -PVFS_EINVAL; PVFS_handle_extent_array meta_handle_extent_array; PINT_sm_msgpair_state *msg_p = NULL; - struct server_configuration_s *server_config = NULL; /* * Check whether we're storing file metadata on a dedicated OSD MDS @@ -725,15 +724,10 @@ static PINT_sm_action create_dspace_create_setup_msgpair( PINT_init_msgpair(sm_p, msg_p); - server_config = PINT_get_server_config_struct( - sm_p->object_ref.fs_id); - ret = PINT_cached_config_get_next_meta( - server_config, sm_p->object_ref.fs_id, + sm_p->object_ref.fs_id, &msg_p->svr_addr, &meta_handle_extent_array, 0); - PINT_put_server_config_struct(server_config); - if (ret) { gossip_err("Failed to map meta server address\n"); @@ -830,11 +824,7 @@ static PINT_sm_action create_datafiles_setup_msgpair_array( return SM_ACTION_COMPLETE; } - server_config = PINT_get_server_config_struct( - sm_p->object_ref.fs_id); - ret = PINT_cached_config_map_servers( - server_config, sm_p->object_ref.fs_id, &sm_p->u.create.num_data_files, &sm_p->u.create.layout, @@ -847,8 +837,6 @@ static PINT_sm_action create_datafiles_setup_msgpair_array( return 1; } - PINT_put_server_config_struct(server_config); - if (ret) { gossip_err("Failed to retrieve data server addresses\n"); diff --git a/src/client/sysint/sys-lookup.sm b/src/client/sysint/sys-lookup.sm index b64ff4a..6815684 100644 --- a/src/client/sysint/sys-lookup.sm +++ b/src/client/sysint/sys-lookup.sm @@ -378,7 +378,7 @@ static int initialize_context( slash_str = orig_pathname; for (i = 0; i < cur_seg_index; i++) { - slash_str = strrchr(slash_str, '/'); + slash_str = strchr(slash_str, '/'); if (slash_str == NULL) { break; } diff --git a/src/client/sysint/sys-mkdir.sm b/src/client/sysint/sys-mkdir.sm index 7d9c426..2c4e246 100644 --- a/src/client/sysint/sys-mkdir.sm +++ b/src/client/sysint/sys-mkdir.sm @@ -404,7 +404,6 @@ static PINT_sm_action mkdir_msg_setup_msgpair( int ret = -PVFS_EINVAL; PVFS_handle_extent_array meta_handle_extent_array; PINT_sm_msgpair_state *msg_p = NULL; - struct server_configuration_s *server_config = NULL; gossip_debug(GOSSIP_CLIENT_DEBUG, "mkdir state: mkdir_msg_setup_msgpair\n"); @@ -413,14 +412,9 @@ static PINT_sm_action mkdir_msg_setup_msgpair( PINT_init_msgpair(sm_p, msg_p); - server_config = PINT_get_server_config_struct( - sm_p->object_ref.fs_id); - - ret = PINT_cached_config_get_next_meta(server_config, - sm_p->object_ref.fs_id, &msg_p->svr_addr, - &meta_handle_extent_array, 1); - - PINT_put_server_config_struct(server_config); + ret = PINT_cached_config_get_next_meta( + sm_p->object_ref.fs_id, + &msg_p->svr_addr, &meta_handle_extent_array, 1); if (ret) { diff --git a/src/client/sysint/sys-statfs.sm b/src/client/sysint/sys-statfs.sm index 4112453..9d1b49f 100644 --- a/src/client/sysint/sys-statfs.sm +++ b/src/client/sysint/sys-statfs.sm @@ -57,7 +57,6 @@ PVFS_error PVFS_isys_statfs( { PINT_smcb *smcb = NULL; PINT_client_sm *sm_p = NULL; - struct server_configuration_s *server_config = NULL; int ret = -1; gossip_debug(GOSSIP_CLIENT_DEBUG, @@ -75,12 +74,9 @@ PVFS_error PVFS_isys_statfs( sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); /* count the number of servers */ - server_config = PINT_get_server_config_struct(fs_id); - assert(server_config); ret = PINT_cached_config_count_servers( - server_config, fs_id, PVFS_MGMT_IO_SERVER|PVFS_MGMT_META_SERVER, + fs_id, PVFS_MGMT_IO_SERVER|PVFS_MGMT_META_SERVER, &sm_p->u.statfs_list.count); - PINT_put_server_config_struct(server_config); if (ret < 0) { PINT_smcb_free(smcb); @@ -106,12 +102,9 @@ PVFS_error PVFS_isys_statfs( } /* generate default list of servers */ - server_config = PINT_get_server_config_struct(fs_id); - assert(server_config); ret = PINT_cached_config_get_server_array( - server_config, fs_id, PVFS_MGMT_IO_SERVER|PVFS_MGMT_META_SERVER, + fs_id, PVFS_MGMT_IO_SERVER|PVFS_MGMT_META_SERVER, sm_p->u.statfs_list.addr_array, &sm_p->u.statfs_list.count); - PINT_put_server_config_struct(server_config); if (ret < 0) { free(sm_p->u.statfs_list.addr_array); diff --git a/src/client/sysint/sys-symlink.sm b/src/client/sysint/sys-symlink.sm index 689eb58..896f1b5 100644 --- a/src/client/sysint/sys-symlink.sm +++ b/src/client/sysint/sys-symlink.sm @@ -352,7 +352,6 @@ static PINT_sm_action symlink_dspace_create_setup_msgpair( int ret = -PVFS_EINVAL; PVFS_handle_extent_array meta_handle_extent_array; PINT_sm_msgpair_state *msg_p = NULL; - struct server_configuration_s *server_config = NULL; js_p->error_code = 0; @@ -360,15 +359,10 @@ static PINT_sm_action symlink_dspace_create_setup_msgpair( PINT_init_msgpair(sm_p, msg_p); - server_config = PINT_get_server_config_struct( - sm_p->object_ref.fs_id); - ret = PINT_cached_config_get_next_meta( - server_config, sm_p->object_ref.fs_id, + sm_p->object_ref.fs_id, &msg_p->svr_addr, &meta_handle_extent_array, 0); - PINT_put_server_config_struct(server_config); - if (ret) { gossip_err("Failed to map meta server address\n"); diff --git a/src/common/misc/fsck-utils.c b/src/common/misc/fsck-utils.c index 2dd2f15..a779f2f 100755 --- a/src/common/misc/fsck-utils.c +++ b/src/common/misc/fsck-utils.c @@ -135,7 +135,6 @@ int PVFS_fsck_check_server_configs( char *fs_config_diff = NULL; char *reference_config_server = NULL; const char *server_name = NULL; - struct server_configuration_s *server_config_struct = NULL; FILE *pin = NULL; char line[130] = { 0 }; char *cmd = NULL; @@ -181,15 +180,10 @@ int PVFS_fsck_check_server_configs( server_name = NULL; /* get the pretty server name */ - server_config_struct = PINT_get_server_config_struct(*cur_fs); server_name = PINT_cached_config_map_addr( - server_config_struct, - *cur_fs, - addresses[i], &server_type); + *cur_fs, addresses[i], &server_type); assert(server_name); - PINT_put_server_config_struct(server_config_struct); - fs_config = calloc(FS_CONFIG_BUFFER_SIZE, sizeof(char)); if (fs_config == NULL) { @@ -1475,21 +1469,15 @@ static int PINT_handle_wrangler_display_stranded_handles( int server_type = 0; PVFS_sysresp_getattr attributes; PVFS_object_ref pref; - struct server_configuration_s *config; const char *server_name = NULL; int header = 0; for (i = 0; i < PINT_handle_wrangler_handlelist.num_servers; i++) { /* get the pretty server name */ - config = PINT_get_server_config_struct(*cur_fs); - server_name = PINT_cached_config_map_addr(config, - *cur_fs, - PINT_handle_wrangler_handlelist. - addr_array[i], &server_type); - - /* release mutex on server config */ - PINT_put_server_config_struct(config); + server_name = PINT_cached_config_map_addr( + *cur_fs, PINT_handle_wrangler_handlelist. + addr_array[i], &server_type); for (j = 0; j < PINT_handle_wrangler_handlelist.size_array[i]; j++) { diff --git a/src/common/misc/msgpairarray.sm b/src/common/misc/msgpairarray.sm index cd2810b..ad0f5e1 100644 --- a/src/common/misc/msgpairarray.sm +++ b/src/common/misc/msgpairarray.sm @@ -487,7 +487,6 @@ static PINT_sm_action msgpairarray_completion_fn( int need_retry = 0; struct PINT_decoded_msg decoded_resp; const char* server_string = NULL; - struct server_configuration_s *server_config = NULL; int server_type; /* response structure (decoded) */ @@ -644,14 +643,9 @@ static PINT_sm_action msgpairarray_completion_fn( } else { char s[1024]; - server_config = PINT_server_config_mgr_get_config(msg_p->fs_id); - if(server_config) - { - server_string = PINT_cached_config_map_addr( - server_config, msg_p->fs_id, msg_p->svr_addr, &server_type); - PINT_server_config_mgr_put_config(server_config); - } - else + server_string = PINT_cached_config_map_addr( + msg_p->fs_id, msg_p->svr_addr, &server_type); + if(!server_string) { server_string = "[UNKNOWN]"; } @@ -714,7 +708,6 @@ int PINT_serv_decode_resp(PVFS_fs_id fs_id, struct PVFS_server_resp **resp_out_pp) { int ret = -1, server_type = 0; - struct server_configuration_s *server_config; const char *server_string; ret = PINT_decode(encoded_resp_p, PINT_DECODE_RESP, @@ -733,10 +726,8 @@ int PINT_serv_decode_resp(PVFS_fs_id fs_id, if (fs_id != PVFS_FS_ID_NULL) { - server_config = PINT_server_config_mgr_get_config(fs_id); server_string = PINT_cached_config_map_addr( - server_config, fs_id, *svr_addr_p, &server_type); - PINT_server_config_mgr_put_config(server_config); + fs_id, *svr_addr_p, &server_type); gossip_err(" Server: %s.\n", server_string); } else diff --git a/src/common/misc/pint-cached-config.c b/src/common/misc/pint-cached-config.c index f629387..60b6fe7 100644 --- a/src/common/misc/pint-cached-config.c +++ b/src/common/misc/pint-cached-config.c @@ -72,8 +72,7 @@ do { cur = hrange_list; \ break; \ } \ cur_host_extent_table->bmi_address = \ - PINT_config_get_host_addr_ptr( \ - config,cur_mapping->alias_mapping->host_alias); \ + cur_mapping->alias_mapping->bmi_address; \ assert(cur_host_extent_table->bmi_address); \ cur_host_extent_table->extent_list = \ PINT_create_extent_list(cur_mapping->handle_range); \ @@ -103,8 +102,7 @@ static int hash_fsid_compare( void *key, struct qlist_head *link); static void free_host_extent_table(void *ptr); -static int cache_server_array( - struct server_configuration_s *config, PVFS_fs_id fsid); +static int cache_server_array(PVFS_fs_id fsid); #ifndef __PVFS2_SERVER__ static int meta_randomized = 0; @@ -224,7 +222,7 @@ int PINT_cached_config_reinitialize( break; } - ret = PINT_handle_load_mapping(config, cur_fs); + ret = PINT_cached_config_handle_load_mapping(cur_fs); if (ret) { break; @@ -235,7 +233,7 @@ int PINT_cached_config_reinitialize( return 0; } -/* PINT_handle_load_mapping() +/* PINT_cached_config_handle_load_mapping() * * loads a new mapping of servers to handle into this interface. This * function may be called multiple times in order to add new file @@ -243,8 +241,7 @@ int PINT_cached_config_reinitialize( * * returns 0 on success, -errno on failure */ -int PINT_handle_load_mapping( - struct server_configuration_s *config, +int PINT_cached_config_handle_load_mapping( struct filesystem_configuration_s *fs) { int ret = -PVFS_EINVAL; @@ -253,7 +250,7 @@ int PINT_handle_load_mapping( struct config_fs_cache_s *cur_config_fs_cache = NULL; struct bmi_host_extent_table_s *cur_host_extent_table = NULL; - if (config && fs) + if (fs) { cur_config_fs_cache = (struct config_fs_cache_s *) malloc(sizeof(struct config_fs_cache_s)); @@ -319,7 +316,6 @@ int PINT_handle_load_mapping( * returns 0 on success, -errno on failure */ int PINT_cached_config_get_next_meta( - struct server_configuration_s *config, PVFS_fs_id fsid, PVFS_BMI_addr_t *meta_addr, PVFS_handle_extent_array *ext_array, @@ -330,13 +326,16 @@ int PINT_cached_config_get_next_meta( struct host_handle_mapping_s *cur_mapping = NULL; struct qlist_head *hash_link = NULL; struct config_fs_cache_s *cur_config_cache = NULL; + struct server_configuration_s *config; int want_osd; - if (config && ext_array) + if (ext_array) { hash_link = qhash_search(PINT_fsid_config_cache_table,&(fsid)); if (hash_link) { + config = PINT_get_server_config_struct(fsid); + cur_config_cache = qlist_entry( hash_link, struct config_fs_cache_s, hash_link); @@ -413,8 +412,7 @@ int PINT_cached_config_get_next_meta( continue; --jitter; } - meta_server_bmi_str = PINT_config_get_host_addr_ptr( - config,cur_mapping->alias_mapping->host_alias); + meta_server_bmi_str = cur_mapping->alias_mapping->bmi_address; ext_array->extent_count = cur_mapping->handle_extent_array.extent_count; @@ -429,6 +427,8 @@ int PINT_cached_config_get_next_meta( { ret = 0; } + + PINT_put_server_config_struct(config); } } return ret; @@ -436,7 +436,6 @@ int PINT_cached_config_get_next_meta( #endif static int PINT_cached_config_get_extents( - struct server_configuration_s *config, PVFS_fs_id fsid, PVFS_BMI_addr_t *addr, PVFS_handle_extent_array *handle_extents) @@ -471,8 +470,7 @@ static int PINT_cached_config_get_extents( server_list = PINT_llist_next(server_list); ret = BMI_addr_lookup( - &tmp_addr, PINT_config_get_host_addr_ptr( - config, cur_mapping->alias_mapping->host_alias)); + &tmp_addr, cur_mapping->alias_mapping->bmi_address); if(ret < 0) { return ret; @@ -492,7 +490,6 @@ static int PINT_cached_config_get_extents( } int PINT_cached_config_map_servers( - struct server_configuration_s *config, PVFS_fs_id fsid, int *inout_num_datafiles, PVFS_sys_layout *layout, @@ -507,9 +504,7 @@ int PINT_cached_config_map_servers( int start_index = -1; int index; - assert(config); assert(inout_num_datafiles); - assert(handle_extent_array); hash_link = qhash_search(PINT_fsid_config_cache_table,&(fsid)); if(!hash_link) @@ -541,15 +536,18 @@ int PINT_cached_config_map_servers( *inout_num_datafiles = layout->server_list.count; for(i = 0; i < layout->server_list.count; ++i) { - ret = PINT_cached_config_get_extents( - config, fsid, - &layout->server_list.servers[i], - &handle_extent_array[i]); - if(ret < 0) + if(handle_extent_array) { - gossip_err("The address specified in the datafile " - "layout is invalid\n"); - return ret; + ret = PINT_cached_config_get_extents( + fsid, + &layout->server_list.servers[i], + &handle_extent_array[i]); + if(ret < 0) + { + gossip_err("The address specified in the datafile " + "layout is invalid\n"); + return ret; + } } addr_array[i] = layout->server_list.servers[i]; @@ -580,17 +578,20 @@ int PINT_cached_config_map_servers( index = (i + start_index) % *inout_num_datafiles; ret = BMI_addr_lookup( - &addr_array[index], PINT_config_get_host_addr_ptr( - config, cur_mapping->alias_mapping->host_alias)); + &addr_array[index], + cur_mapping->alias_mapping->bmi_address); if (ret) { return ret; } - handle_extent_array[index].extent_count = - cur_mapping->handle_extent_array.extent_count; - handle_extent_array[index].extent_array = - cur_mapping->handle_extent_array.extent_array; + if(handle_extent_array) + { + handle_extent_array[index].extent_count = + cur_mapping->handle_extent_array.extent_count; + handle_extent_array[index].extent_array = + cur_mapping->handle_extent_array.extent_array; + } } break; @@ -619,18 +620,19 @@ int PINT_cached_config_map_servers( /* found an unused index */ ret = BMI_addr_lookup( &addr_array[index], - PINT_config_get_host_addr_ptr( - config, - cur_mapping->alias_mapping->host_alias)); + cur_mapping->alias_mapping->bmi_address); if (ret) { return ret; } - handle_extent_array[index].extent_count = - cur_mapping->handle_extent_array.extent_count; - handle_extent_array[index].extent_array = - cur_mapping->handle_extent_array.extent_array; + if(handle_extent_array) + { + handle_extent_array[index].extent_count = + cur_mapping->handle_extent_array.extent_count; + handle_extent_array[index].extent_array = + cur_mapping->handle_extent_array.extent_array; + } } } } @@ -642,7 +644,6 @@ int PINT_cached_config_map_servers( return 0; } - /* PINT_cached_config_get_next_io() * * returns the address of a set of servers that should be used to @@ -654,7 +655,6 @@ int PINT_cached_config_map_servers( * returns 0 on success, -errno on failure */ int PINT_cached_config_get_next_io( - struct server_configuration_s *config, PVFS_fs_id fsid, int num_servers, PVFS_BMI_addr_t *io_addr_array, @@ -668,7 +668,7 @@ int PINT_cached_config_get_next_io( int jitter = 0, num_io_servers = 0; PINT_llist* old_data_server_cursor = NULL; - if (config && num_servers && io_handle_extent_array) + if (num_servers && io_handle_extent_array) { hash_link = qhash_search(PINT_fsid_config_cache_table,&(fsid)); if (hash_link) @@ -725,8 +725,7 @@ int PINT_cached_config_get_next_io( cur_config_cache->data_server_cursor = PINT_llist_next( cur_config_cache->data_server_cursor); - data_server_bmi_str = PINT_config_get_host_addr_ptr( - config,cur_mapping->alias_mapping->host_alias); + data_server_bmi_str = cur_mapping->alias_mapping->bmi_address; if (io_addr_array != NULL) { @@ -766,7 +765,6 @@ int PINT_cached_config_get_next_io( * returns pointer to string on success, NULL on failure */ const char *PINT_cached_config_map_addr( - struct server_configuration_s *config, PVFS_fs_id fsid, PVFS_BMI_addr_t addr, int *server_type) @@ -775,11 +773,6 @@ const char *PINT_cached_config_map_addr( struct qlist_head *hash_link = NULL; struct config_fs_cache_s *cur_config_cache = NULL; - if (!config) - { - return NULL; - } - hash_link = qhash_search(PINT_fsid_config_cache_table,&(fsid)); if (!hash_link) { @@ -790,7 +783,7 @@ const char *PINT_cached_config_map_addr( assert(cur_config_cache); assert(cur_config_cache->fs); - ret = cache_server_array(config, fsid); + ret = cache_server_array(fsid); if (ret < 0) { return NULL; @@ -818,7 +811,6 @@ const char *PINT_cached_config_map_addr( * returns 0 on success, -errno on failure */ int PINT_cached_config_count_servers( - struct server_configuration_s *config, PVFS_fs_id fsid, int server_type, int *count) @@ -827,7 +819,7 @@ int PINT_cached_config_count_servers( struct qlist_head *hash_link = NULL; struct config_fs_cache_s *cur_config_cache = NULL; - if (!config || !server_type) + if (!server_type) { return ret; } @@ -843,7 +835,7 @@ int PINT_cached_config_count_servers( assert(cur_config_cache); assert(cur_config_cache->fs); - ret = cache_server_array(config, fsid); + ret = cache_server_array(fsid); if (ret == 0) { if (server_type == PINT_SERVER_TYPE_META) @@ -875,7 +867,6 @@ int PINT_cached_config_count_servers( * returns 0 on success, -errno on failure */ int PINT_cached_config_get_server_array( - struct server_configuration_s *config, PVFS_fs_id fsid, int server_type, PVFS_BMI_addr_t *addr_array, @@ -885,7 +876,7 @@ int PINT_cached_config_get_server_array( struct qlist_head *hash_link = NULL; struct config_fs_cache_s *cur_config_cache = NULL; - if (!config || !inout_count_p || !*inout_count_p || + if (!inout_count_p || !*inout_count_p || !addr_array || !server_type) { return ret; @@ -902,7 +893,7 @@ int PINT_cached_config_get_server_array( assert(cur_config_cache); assert(cur_config_cache->fs); - ret = cache_server_array(config, fsid); + ret = cache_server_array(fsid); if (ret < 0) { return ret; @@ -1290,7 +1281,6 @@ int PINT_cached_config_get_handle_timeout( * returns 0 on success, -errno on failure */ static int cache_server_array( - struct server_configuration_s *config, PVFS_fs_id fsid) { int ret = -PVFS_EINVAL, i = 0, j = 0; @@ -1304,11 +1294,6 @@ static int cache_server_array( int current = 0; int array_index = 0, array_index2 = 0; - if (!config) - { - return ret; - } - hash_link = qhash_search(PINT_fsid_config_cache_table,&(fsid)); if (!hash_link) { @@ -1389,8 +1374,7 @@ static int cache_server_array( while ((cur_mapping = PINT_llist_head(tmp_server))) { tmp_server = PINT_llist_next(tmp_server); - server_bmi_str = PINT_config_get_host_addr_ptr( - config,cur_mapping->alias_mapping->host_alias); + server_bmi_str = cur_mapping->alias_mapping->bmi_address; ret = BMI_addr_lookup(&tmp_bmi_addr,server_bmi_str); if (ret < 0) diff --git a/src/common/misc/pint-cached-config.h b/src/common/misc/pint-cached-config.h index e6fedca..fea2da6 100644 --- a/src/common/misc/pint-cached-config.h +++ b/src/common/misc/pint-cached-config.h @@ -28,44 +28,37 @@ int PINT_cached_config_initialize(void); int PINT_cached_config_finalize(void); -int PINT_handle_load_mapping( - struct server_configuration_s *config, +int PINT_cached_config_handle_load_mapping( struct filesystem_configuration_s *fs); int PINT_cached_config_map_alias( - struct server_configuration_s *config, const char *alias, PVFS_BMI_addr_t *addr); int PINT_cached_config_get_next_meta( - struct server_configuration_s *config, PVFS_fs_id fsid, PVFS_BMI_addr_t *meta_addr, PVFS_handle_extent_array *meta_extent_array, int is_directory); int PINT_cached_config_get_next_io( - struct server_configuration_s *config, PVFS_fs_id fsid, int num_servers, PVFS_BMI_addr_t *io_addr_array, PVFS_handle_extent_array *io_handle_extent_array); const char *PINT_cached_config_map_addr( - struct server_configuration_s *config, PVFS_fs_id fsid, PVFS_BMI_addr_t addr, int *server_type); int PINT_cached_config_get_server_array( - struct server_configuration_s *config, PVFS_fs_id fsid, int server_type, PVFS_BMI_addr_t *addr_array, int *inout_count_p); int PINT_cached_config_count_servers( - struct server_configuration_s *config, PVFS_fs_id fsid, int server_type, int *count); @@ -76,7 +69,6 @@ int PINT_cached_config_map_to_server( PVFS_fs_id fs_id); int PINT_cached_config_map_servers( - struct server_configuration_s *config, PVFS_fs_id fsid, int *inout_num_datafiles, PVFS_sys_layout *layout, diff --git a/src/common/misc/pvfs2-debug.c b/src/common/misc/pvfs2-debug.c index ea2f394..474639b 100644 --- a/src/common/misc/pvfs2-debug.c +++ b/src/common/misc/pvfs2-debug.c @@ -107,14 +107,14 @@ static __keyword_mask_t s_keyword_mask_map[] = /* Display the hostnames instead of IP addrs in debug output */ { "access_hostnames", GOSSIP_ACCESS_HOSTNAMES }, /* Show the client device events */ - { "dev", GOSSIP_DEV_DEBUG }, + { "user_dev", GOSSIP_USER_DEV_DEBUG }, /* Debug the fsck tool */ { "fsck", GOSSIP_FSCK_DEBUG }, { "bstream", GOSSIP_BSTREAM_DEBUG }, /* Everything except the periodic events. Useful for debugging */ { "verbose", (__DEBUG_ALL & ~(GOSSIP_PERFCOUNTER_DEBUG | GOSSIP_STATE_MACHINE_DEBUG | - GOSSIP_ENDECODE_DEBUG)) + GOSSIP_ENDECODE_DEBUG | GOSSIP_USER_DEV_DEBUG)) }, /* No debug output */ { "none", GOSSIP_NO_DEBUG }, diff --git a/src/common/misc/server-config-mgr.c b/src/common/misc/server-config-mgr.c index 705f6bf..652aabc 100644 --- a/src/common/misc/server-config-mgr.c +++ b/src/common/misc/server-config-mgr.c @@ -191,11 +191,11 @@ int PINT_server_config_mgr_reload_cached_config_interface(void) "Reloading handle mappings for fs_id %d\n", cur_fs->coll_id); - ret = PINT_handle_load_mapping( - config->server_config, cur_fs); + ret = PINT_cached_config_handle_load_mapping(cur_fs); if (ret) { - PVFS_perror("PINT_handle_load_mapping failed", ret); + PVFS_perror( + "PINT_cached_config_handle_load_mapping failed", ret); gen_mutex_unlock(&s_server_config_mgr_mutex); return ret; } diff --git a/src/common/misc/state-machine-fns.c b/src/common/misc/state-machine-fns.c index 6098ea0..f6572c6 100644 --- a/src/common/misc/state-machine-fns.c +++ b/src/common/misc/state-machine-fns.c @@ -70,30 +70,40 @@ int PINT_state_machine_halt(void) */ int PINT_state_machine_terminate(struct PINT_smcb *smcb, job_status_s *r) { - struct PINT_frame_s *current_frame; + struct PINT_frame_s *my_frame, *f; job_id_t id; /* notify parent */ if (smcb->parent_smcb) { - assert(smcb->parent_smcb->children_running > 0); - - current_frame = qlist_entry( - &smcb->frames.next, struct PINT_frame_s, link); - current_frame->error = r->error_code; - - if (--smcb->parent_smcb->children_running > 0) - { - /* SM is still deferred */ - return SM_ACTION_DEFERRED; - } - else + gossip_debug(GOSSIP_STATE_MACHINE_DEBUG, + "[SM Terminating Child]: (%p) %s:%s (error_code: %d)\n", + smcb, + /* skip pvfs2_ */ + PINT_state_machine_current_machine_name(smcb), + PINT_state_machine_current_state_name(smcb), + (int32_t)r->error_code); + assert(smcb->parent_smcb->children_running > 0); + + my_frame = qlist_entry( + smcb->frames.next, struct PINT_frame_s, link); + qlist_for_each_entry(f, &smcb->parent_smcb->frames, link) + { + if(my_frame->frame == f->frame) + { + f->error = r->error_code; + break; + } + } + + if (--smcb->parent_smcb->children_running <= 0) { /* no more child state machines running, so we can * start up the parent state machine again */ job_null(0, smcb->parent_smcb, 0, r, &id, smcb->context); } + return SM_ACTION_DEFERRED; } /* call state machine completion function */ if (smcb->terminate_fn) @@ -127,10 +137,6 @@ PINT_sm_action PINT_state_machine_invoke(struct PINT_smcb *smcb, return SM_ERROR; } - /* print pre-call debugging info */ - gossip_debug(GOSSIP_STATE_MACHINE_DEBUG, - "SM invoke smcb %p op %d\n",smcb,(smcb)->op); - state_name = PINT_state_machine_current_state_name(smcb); machine_name = PINT_state_machine_current_machine_name(smcb); @@ -148,17 +154,10 @@ PINT_sm_action PINT_state_machine_invoke(struct PINT_smcb *smcb, switch (retval) { case SM_ACTION_TERMINATE : - gossip_debug(GOSSIP_STATE_MACHINE_DEBUG, - "SM Terminates (%p)\n", smcb); smcb->op_terminate = 1; break; case SM_ACTION_COMPLETE : - gossip_debug(GOSSIP_STATE_MACHINE_DEBUG, - "SM Returns Complete (%p)\n", smcb); - break; case SM_ACTION_DEFERRED : - gossip_debug(GOSSIP_STATE_MACHINE_DEBUG, - "SM Returns Deferred (%p)\n", smcb); break; default : /* error */ @@ -169,7 +168,7 @@ PINT_sm_action PINT_state_machine_invoke(struct PINT_smcb *smcb, /* print post-call debugging info */ gossip_debug(GOSSIP_STATE_MACHINE_DEBUG, - "[SM Exiting]: (%p) %s:%s (error code: %d), (sm action: %s)\n", + "[SM Exiting]: (%p) %s:%s (error code: %d), (action: %s)\n", smcb, /* skip pvfs2_ */ machine_name, @@ -181,9 +180,6 @@ PINT_sm_action PINT_state_machine_invoke(struct PINT_smcb *smcb, { /* start child SMs */ PINT_sm_start_child_frames(smcb); - gossip_debug(GOSSIP_STATE_MACHINE_DEBUG, - "SM (%p) started %d child frames\n", - smcb, smcb->children_running); if (smcb->children_running > 0) retval = SM_ACTION_DEFERRED; else @@ -205,19 +201,25 @@ PINT_sm_action PINT_state_machine_start(struct PINT_smcb *smcb, job_status_s *r) { PINT_sm_action ret; + /* set the state machine to being completed immediately. We + * unset this bit once the state machine is deferred. + */ + smcb->immediate = 1; + /* run the current state action function */ ret = PINT_state_machine_invoke(smcb, r); if (ret == SM_ACTION_COMPLETE || ret == SM_ACTION_TERMINATE) { /* keep running until state machine deferrs or terminates */ - ret = PINT_state_machine_next(smcb, r); - - /* note that if ret == SM_ACTION_TERMINATE, we _don't_ call - * PINT_state_machine_terminate here because that adds the smcb - * to the completion list. We don't want to do that on immediate - * completion - */ + ret = PINT_state_machine_continue(smcb, r); } + + if(ret == SM_ACTION_DEFERRED) + { + /* this state machine isn't completing immediately */ + smcb->immediate = 0; + } + return ret; } @@ -239,8 +241,6 @@ PINT_sm_action PINT_state_machine_next(struct PINT_smcb *smcb, job_status_s *r) gossip_err("SM next called on invald smcb\n"); return -1; } - gossip_debug(GOSSIP_STATE_MACHINE_DEBUG, - "SM next smcb %p op %d\n",smcb,(smcb)->op); /* loop while invoke of new state returns COMPLETED */ do { /* loop while returning from nested SM */ @@ -254,12 +254,12 @@ PINT_sm_action PINT_state_machine_next(struct PINT_smcb *smcb, job_status_s *r) return -1; } transtbl = smcb->current_state->trtbl; - - /* for each entry in the transition table there is a return - * code followed by a next state pointer to the new state. - * This loops through each entry, checking for a match on the - * return address, and then sets the new current_state and calls - * the new state action function */ + + /* for each entry in the transition table there is a return + * code followed by a next state pointer to the new state. + * This loops through each entry, checking for a match on the + * return address, and then sets the new current_state and calls + * the new state action function */ for (i = 0; transtbl[i].return_value != DEFAULT_ERROR; i++) { if (transtbl[i].return_value == r->error_code) @@ -296,10 +296,8 @@ PINT_sm_action PINT_state_machine_next(struct PINT_smcb *smcb, job_status_s *r) if(!smcb->current_state || smcb->current_state->trtbl[0].flag == SM_TERM) { - /* assume nested machine was invoked without - * a parent, or nested machine completion results - * in immediate termination - */ + /* assume nested state machine was invoked without + * a parent */ return SM_ACTION_TERMINATE; } } @@ -355,6 +353,8 @@ int PINT_state_machine_locate(struct PINT_smcb *smcb) { struct PINT_state_s *current_tmp; struct PINT_state_machine_s *op_sm; + const char *state_name; + const char *machine_name; /* check for valid inputs */ if (!smcb || smcb->op < 0 || !smcb->op_get_state_machine) @@ -363,7 +363,7 @@ int PINT_state_machine_locate(struct PINT_smcb *smcb) return -PVFS_EINVAL; } gossip_debug(GOSSIP_STATE_MACHINE_DEBUG, - "SM locate smcb %p op %d\n",smcb,(smcb)->op); + "[SM Locating]: (%p) op-id: %d\n",smcb,(smcb)->op); /* this is a the usage dependant routine to look up the SM */ op_sm = (*smcb->op_get_state_machine)(smcb->op); if (op_sm != NULL) @@ -379,6 +379,14 @@ int PINT_state_machine_locate(struct PINT_smcb *smcb) current_tmp->action.nested)->first_state; } smcb->current_state = current_tmp; + + state_name = PINT_state_machine_current_state_name(smcb); + machine_name = PINT_state_machine_current_machine_name(smcb); + + gossip_debug(GOSSIP_STATE_MACHINE_DEBUG, + "[SM Locating]: (%p) located: %s:%s\n", + smcb, machine_name, state_name); + return 1; /* indicates successful locate */ } gossip_err("State machine not found for operation %d\n",smcb->op); @@ -393,12 +401,15 @@ int PINT_state_machine_locate(struct PINT_smcb *smcb) */ int PINT_smcb_set_op(struct PINT_smcb *smcb, int op) { - gossip_debug(GOSSIP_STATE_MACHINE_DEBUG, - "SM set op smcb %p op %d\n",smcb,op); smcb->op = op; return PINT_state_machine_locate(smcb); } +int PINT_smcb_immediate_completion(struct PINT_smcb *smcb) +{ + return smcb->immediate; +} + /* Function: PINT_smcb_op Params: pointer to an smcb pointer Returns: op (int) @@ -499,8 +510,6 @@ int PINT_smcb_alloc( { return -PVFS_ENOMEM; } - gossip_debug(GOSSIP_STATE_MACHINE_DEBUG, - "SM allocate smcb %p op %d\n",*smcb,op); /* zero out all members */ memset(*smcb, 0, sizeof(struct PINT_smcb)); @@ -540,8 +549,6 @@ void PINT_smcb_free(struct PINT_smcb *smcb) { struct PINT_frame_s *frame_entry, *tmp; assert(smcb); - gossip_debug(GOSSIP_STATE_MACHINE_DEBUG, - "SM free smcb %p op %d\n", smcb, smcb->op); qlist_for_each_entry_safe(frame_entry, tmp, &smcb->frames, link) { if (frame_entry->frame && frame_entry->task_id == 0) @@ -564,8 +571,10 @@ void PINT_smcb_free(struct PINT_smcb *smcb) */ static struct PINT_state_s *PINT_pop_state(struct PINT_smcb *smcb) { - assert(smcb->stackptr > 0); - + if(smcb->stackptr == 0) + { + return NULL; + } return smcb->state_stack[--smcb->stackptr]; } @@ -611,9 +620,6 @@ void *PINT_sm_frame(struct PINT_smcb *smcb, int index) next = next->next; } frame_entry = qlist_entry(next, struct PINT_frame_s, link); - gossip_debug(GOSSIP_STATE_MACHINE_DEBUG, - "FRAME GET smcb %p index %d -> frame: %p\n", - smcb, index, frame_entry->frame); return frame_entry->frame; } } @@ -627,9 +633,8 @@ int PINT_sm_push_frame(struct PINT_smcb *smcb, int task_id, void *frame_p) { struct PINT_frame_s *newframe; gossip_debug(GOSSIP_STATE_MACHINE_DEBUG, - "PUSH FRAME %p onto smcb %p\n", - frame_p, smcb); - + "[SM Frame PUSH]: (%p) frame: %p\n", + smcb, frame_p); newframe = malloc(sizeof(struct PINT_frame_s)); if(!newframe) { @@ -638,15 +643,22 @@ int PINT_sm_push_frame(struct PINT_smcb *smcb, int task_id, void *frame_p) newframe->task_id = task_id; newframe->frame = frame_p; qlist_add(&newframe->link, &smcb->frames); + smcb->frame_count++; return 0; } /* Function: PINT_sm_pop_frame - * Params: pointer to an smcb pointer + * Params: smcb - pointer to an smcb pointer + * task_id - the task id of this frame + * error_code - the frame's error if there was one. + * remaining - count of remaining frames on the smcb. * Returns: frame pointer * Synopsis: pops a frame pointer from the frame_stack and returns it */ -void *PINT_sm_pop_frame(struct PINT_smcb *smcb, int *error_code) +void *PINT_sm_pop_frame(struct PINT_smcb *smcb, + int *task_id, + int *error_code, + int *remaining) { struct PINT_frame_s *frame_entry; void *frame; @@ -656,17 +668,24 @@ void *PINT_sm_pop_frame(struct PINT_smcb *smcb, int *error_code) return NULL; } - frame_entry = qlist_entry(&smcb->frames.next, struct PINT_frame_s, link); + frame_entry = qlist_entry(smcb->frames.next, struct PINT_frame_s, link); qlist_del(smcb->frames.next); + smcb->frame_count--; + + if(remaining) + { + *remaining = smcb->frame_count; + } frame = frame_entry->frame; *error_code = frame_entry->error; + *task_id = frame_entry->task_id; free(frame_entry); gossip_debug(GOSSIP_STATE_MACHINE_DEBUG, - "POP FRAME %p from smcb %p\n", - frame, smcb); + "[SM Frame POP]: (%p) frame: %p\n", + smcb, frame); return frame; } @@ -710,11 +729,22 @@ static void PINT_sm_start_child_frames(struct PINT_smcb *smcb) struct PINT_smcb *new_sm; struct PINT_frame_s *frame_entry; job_status_s r; + struct qlist_head *f; assert(smcb); - qlist_for_each_entry(frame_entry, &smcb->frames, link) + memset(&r, 0, sizeof(job_status_s)); + + qlist_for_each(f, &smcb->frames) { + /* skip the last since its the parent frame */ + if(f->next == &smcb->frames) + { + break; + } + + frame_entry = qlist_entry(f, struct PINT_frame_s, link); + /* allocate smcb */ PINT_smcb_alloc(&new_sm, smcb->op, 0, NULL, child_sm_frame_terminate, smcb->context); diff --git a/src/common/misc/state-machine.h b/src/common/misc/state-machine.h index 86f3220..832c0e6 100644 --- a/src/common/misc/state-machine.h +++ b/src/common/misc/state-machine.h @@ -68,6 +68,7 @@ typedef struct PINT_smcb struct PINT_state_s *state_stack[PINT_STATE_STACK_SIZE]; struct qlist_head frames; + int frame_count; /* usage specific routinet to look up SM from OP */ struct PINT_state_machine_s *(*op_get_state_machine)(int); @@ -83,6 +84,7 @@ typedef struct PINT_smcb job_context_id context; /* job context when waiting for children */ int (*terminate_fn)(struct PINT_smcb *, job_status_s *); void *user_ptr; /* external user pointer */ + int immediate; /* specifies immediate completion of the state machine */ } PINT_smcb; #define PINT_SET_OP_COMPLETE do{PINT_smcb_set_complete(smcb);} while (0) @@ -152,14 +154,6 @@ enum { #define SM_STATE_RETURN -1 #define SM_NESTED_STATE 1 -#define SM_NONE 0 -#define SM_NEXT 1 -#define SM_RETURN 2 -#define SM_EXTERN 3 -#define SM_NESTED 5 -#define SM_JUMP 6 -#define SM_TERMINATE 7 - /* Prototypes for functions provided by user */ int PINT_state_machine_complete(void *); @@ -184,6 +178,7 @@ PINT_sm_action PINT_state_machine_continue( int PINT_state_machine_locate(struct PINT_smcb *) __attribute__((used)); int PINT_smcb_set_op(struct PINT_smcb *smcb, int op); int PINT_smcb_op(struct PINT_smcb *smcb); +int PINT_smcb_immediate_completion(struct PINT_smcb *smcb); void PINT_smcb_set_complete(struct PINT_smcb *smcb); int PINT_smcb_invalid_op(struct PINT_smcb *smcb); int PINT_smcb_complete(struct PINT_smcb *smcb); @@ -196,9 +191,10 @@ int PINT_smcb_alloc(struct PINT_smcb **, int, int, void PINT_smcb_free(struct PINT_smcb *); void *PINT_sm_frame(struct PINT_smcb *, int); int PINT_sm_push_frame(struct PINT_smcb *smcb, int task_id, void *frame_p); -void *PINT_sm_pop_frame(struct PINT_smcb *smcb, int *error_code); - -int PINT_sm_pop_error(PINT_smcb *smcb, PVFS_error ret); +void *PINT_sm_pop_frame(struct PINT_smcb *smcb, + int *task_id, + int *error_code, + int *remaining); /* This macro is used in calls to PINT_sm_fram() */ #define PINT_FRAME_CURRENT 0 diff --git a/src/io/bmi/bmi_gm/module.mk.in b/src/io/bmi/bmi_gm/module.mk.in index fd8fb3f..ac225db 100644 --- a/src/io/bmi/bmi_gm/module.mk.in +++ b/src/io/bmi/bmi_gm/module.mk.in @@ -1,14 +1,31 @@ -BUILD_GM = @BUILD_GM@ - -# only build GM module if configure detected GM -ifdef BUILD_GM - DIR := src/io/bmi/bmi_gm - LIBSRC += \ - $(DIR)/bmi-gm-addr-list.c \ - $(DIR)/bmi-gm-bufferpool.c \ - $(DIR)/bmi-gm.c - SERVERSRC += \ - $(DIR)/bmi-gm-addr-list.c \ - $(DIR)/bmi-gm-bufferpool.c \ - $(DIR)/bmi-gm.c -endif +# +# Makefile stub for bmi_gm. +# +# Copyright (C) 2008 Pete Wyckoff +# +# See COPYING in top-level directory. +# + +# only do any of this if configure decided to use GM +ifneq (,$(BUILD_GM)) + +# +# Local definitions. +# +DIR := src/io/bmi/bmi_gm +cfiles := bmi-gm-addr-list.c bmi-gm-bufferpool.c bmi-gm.c + +# +# Export these to the top Makefile to tell it what to build. +# +src := $(patsubst %,$(DIR)/%,$(cfiles)) +LIBSRC += $(src) +SERVERSRC += $(src) + +# +# Extra cflags for files in this directory. +# TODO: later on we will want the ability to modify this at configure time +# +MODCFLAGS_$(DIR) := -I@GM_INCDIR@ -I@GM_INCDIR@/gm -DENABLE_GM_BUFPOOL + +endif # BUILD_GM diff --git a/src/io/bmi/bmi_ib/README b/src/io/bmi/bmi_ib/README index 97b3699..57686b0 100644 --- a/src/io/bmi/bmi_ib/README +++ b/src/io/bmi/bmi_ib/README @@ -2,8 +2,6 @@ Notes on the BMI InfiniBand implementation Copyright (C) 2003-6 Pete Wyckoff -$Id: README,v 1.8 2006/12/02 19:08:41 pw Exp $ - InifiniBand programming interface --------------------------------- The BMI IB implementation was developed for the API provided by Mellanox, a diff --git a/src/io/bmi/bmi_ib/ib.c b/src/io/bmi/bmi_ib/ib.c index c4a1ac2..9261708 100644 --- a/src/io/bmi/bmi_ib/ib.c +++ b/src/io/bmi/bmi_ib/ib.c @@ -5,8 +5,6 @@ * Copyright (C) 2006 Kyle Schochenmaier * * See COPYING in top-level directory. - * - * $Id: ib.c,v 1.62 2007/12/05 20:03:17 pw Exp $ */ #include #include @@ -217,8 +215,9 @@ static int ib_check_cq(void) assert(0, "%s: unknown send state %s (%d) of sq %p", __func__, sq_state_name(sq->state.send), sq->state.send, sq); - debug(2, "%s: send to %s completed locally: -> %s", - __func__, bh->c->peername, sq_state_name(sq->state.send)); + debug(2, "%s: send to %s completed locally: sq %p -> %s", + __func__, bh->c->peername, sq, + sq_state_name(sq->state.send)); } else { struct ib_work *rq = sq; /* rename */ @@ -229,8 +228,9 @@ static int ib_check_cq(void) else assert(0, "%s: unknown send state %s of rq %p", __func__, rq_state_name(rq->state.recv), rq); - debug(2, "%s: send to %s completed locally: -> %s", - __func__, bh->c->peername, rq_state_name(rq->state.recv)); + debug(2, "%s: send to %s completed locally: rq %p -> %s", + __func__, bh->c->peername, rq, + rq_state_name(rq->state.recv)); } qlist_add_tail(&bh->list, &bh->c->eager_send_buf_free); @@ -599,7 +599,8 @@ encourage_recv_incoming(struct buf_head *bh, msg_type_t type, u_int32_t byte_len rq = NULL; qlist_for_each_entry(rqt, &ib_device->recvq, list) { - if (rqt->c == c && rqt->rts_mop_id == mh_rts_done.mop_id) { + if (rqt->c == c && rqt->rts_mop_id == mh_rts_done.mop_id && + rqt->state.recv == RQ_RTS_WAITING_RTS_DONE) { rq = rqt; break; } @@ -607,9 +608,6 @@ encourage_recv_incoming(struct buf_head *bh, msg_type_t type, u_int32_t byte_len assert(rq, "%s: mop_id %llx in RTS_DONE message not found", __func__, llu(mh_rts_done.mop_id)); - assert(rq->state.recv == RQ_RTS_WAITING_RTS_DONE, - "%s: RTS_DONE to rq wrong state %s", - __func__, rq_state_name(rq->state.recv)); #if MEMCACHE_BOUNCEBUF memcpy_to_buflist(&rq->buflist, reg_recv_buflist_buf, @@ -1490,7 +1488,10 @@ BMI_ib_cancel(bmi_op_id_t id, bmi_context_id context_id __unused) memcache_deregister(ib_device->memcache, &sq->buflist); # if MEMCACHE_EARLY_REG /* pin when sending rts, so also must dereg in this state */ - if (sq->state.send == SQ_WAITING_CTS) + if (sq->state.send == SQ_WAITING_RTS_SEND_COMPLETION || + sq->state.send == SQ_WAITING_RTS_SEND_COMPLETION_GOT_CTS || + sq->state.send == SQ_WAITING_CTS || + sq->state.send == SQ_WAITING_DATA_SEND_COMPLETION) memcache_deregister(ib_device->memcache, &sq->buflist); # endif #endif @@ -1505,7 +1506,8 @@ BMI_ib_cancel(bmi_op_id_t id, bmi_context_id context_id __unused) memcache_deregister(ib_device->memcache, &rq->buflist); # if MEMCACHE_EARLY_REG /* pin on post, dereg all these */ - if (rq->state.recv == RQ_RTS_WAITING_CTS_BUFFER) + if (rq->state.recv == RQ_RTS_WAITING_CTS_SEND_COMPLETION || + rq->state.recv == RQ_RTS_WAITING_RTS_DONE) memcache_deregister(ib_device->memcache, &rq->buflist); if (rq->state.recv == RQ_WAITING_INCOMING && rq->buflist.tot_len > ib_device->eager_buf_payload) diff --git a/src/io/bmi/bmi_ib/ib.h b/src/io/bmi/bmi_ib/ib.h index b115894..8bc0738 100644 --- a/src/io/bmi/bmi_ib/ib.h +++ b/src/io/bmi/bmi_ib/ib.h @@ -4,8 +4,6 @@ * Copyright (C) 2003-6 Pete Wyckoff * * See COPYING in top-level directory. - * - * $Id: ib.h,v 1.30 2007/11/15 15:50:59 slang Exp $ */ #ifndef __ib_h #define __ib_h diff --git a/src/io/bmi/bmi_ib/mem.c b/src/io/bmi/bmi_ib/mem.c index 360252d..c860c1e 100644 --- a/src/io/bmi/bmi_ib/mem.c +++ b/src/io/bmi/bmi_ib/mem.c @@ -4,8 +4,6 @@ * Copyright (C) 2004-6 Pete Wyckoff * * See COPYING in top-level directory. - * - * $Id: mem.c,v 1.14 2007/05/08 21:28:01 pw Exp $ */ #include #include "pvfs2-internal.h" diff --git a/src/io/bmi/bmi_ib/module.mk.in b/src/io/bmi/bmi_ib/module.mk.in index dcb387f..0dbd065 100644 --- a/src/io/bmi/bmi_ib/module.mk.in +++ b/src/io/bmi/bmi_ib/module.mk.in @@ -5,8 +5,6 @@ # # See COPYING in top-level directory. # -# $Id: module.mk.in,v 1.13 2006/09/16 20:55:13 pw Exp $ -# # only do any of this if configure decided to use IB on OpenIB ifneq (,$(BUILD_IB)$(BUILD_OPENIB)) diff --git a/src/io/bmi/bmi_ib/openib.c b/src/io/bmi/bmi_ib/openib.c index 947ad19..e104c08 100644 --- a/src/io/bmi/bmi_ib/openib.c +++ b/src/io/bmi/bmi_ib/openib.c @@ -5,8 +5,6 @@ * Copyright (C) 2006 Kyle Schochenmaier * * See COPYING in top-level directory. - * - * $Id: openib.c,v 1.14 2007/07/18 20:36:12 pw Exp $ */ #include #include diff --git a/src/io/bmi/bmi_ib/util.c b/src/io/bmi/bmi_ib/util.c index 10ab3c8..8db1a7a 100644 --- a/src/io/bmi/bmi_ib/util.c +++ b/src/io/bmi/bmi_ib/util.c @@ -4,8 +4,6 @@ * Copyright (C) 2003-6 Pete Wyckoff * * See COPYING in top-level directory. - * - * $Id: util.c,v 1.12 2007/07/22 16:15:01 pw Exp $ */ #include #include diff --git a/src/io/bmi/bmi_ib/vapi.c b/src/io/bmi/bmi_ib/vapi.c index cdd340a..71dd9a1 100644 --- a/src/io/bmi/bmi_ib/vapi.c +++ b/src/io/bmi/bmi_ib/vapi.c @@ -4,8 +4,6 @@ * Copyright (C) 2003-6 Pete Wyckoff * * See COPYING in top-level directory. - * - * $Id: vapi.c,v 1.13 2007/11/09 00:33:40 slang Exp $ */ #include #include diff --git a/src/io/bmi/bmi_mx/module.mk.in b/src/io/bmi/bmi_mx/module.mk.in index 4f77838..6b7fd2d 100644 --- a/src/io/bmi/bmi_mx/module.mk.in +++ b/src/io/bmi/bmi_mx/module.mk.in @@ -1,10 +1,30 @@ -BUILD_MX = @BUILD_MX@ - -# only build MX module if configure detected MX -ifdef BUILD_MX - DIR := src/io/bmi/bmi_mx - LIBSRC += \ - $(DIR)/mx.c - SERVERSRC += \ - $(DIR)/mx.c -endif +# +# Makefile stub for bmi_mx. +# +# Copyright (C) 2008 Pete Wyckoff +# +# See COPYING in top-level directory. +# + +# only do any of this if configure decided to use MX +ifneq (,$(BUILD_MX)) + +# +# Local definitions. +# +DIR := src/io/bmi/bmi_mx +cfiles := mx.c + +# +# Export these to the top Makefile to tell it what to build. +# +src := $(patsubst %,$(DIR)/%,$(cfiles)) +LIBSRC += $(src) +SERVERSRC += $(src) + +# +# Extra cflags for files in this directory. +# +MODCFLAGS_$(DIR) := -I@MX_INCLUDES@ + +endif # BUILD_MX diff --git a/src/io/bmi/bmi_portals/portals.c b/src/io/bmi/bmi_portals/portals.c index a317f34..3c3a75d 100644 --- a/src/io/bmi/bmi_portals/portals.c +++ b/src/io/bmi/bmi_portals/portals.c @@ -1,7 +1,7 @@ /* * Portals BMI method. * - * Copyright (C) 2007 Pete Wyckoff + * Copyright (C) 2007-8 Pete Wyckoff * * See COPYING in top-level directory. */ @@ -1898,16 +1898,20 @@ static int bmip_initialize(struct bmi_method_addr *listen_addr, goto out; } - /* global debugging on all NIs */ - /* PtlNIDebug(PTL_INVALID_HANDLE, PTL_DBG_ALL | PTL_DBG_NI_ALL); */ +/* + * utcp has shorter names for debug symbols; define catamount to these + * even though it never prints anything. + */ +#ifndef PTL_DBG_ALL +#define PTL_DBG_ALL PTL_DEBUG_ALL +#define PTL_DBG_NI_ALL PTL_DEBUG_NI_ALL +#endif + + PtlNIDebug(PTL_INVALID_HANDLE, PTL_DBG_ALL | PTL_DBG_NI_ALL); /* PtlNIDebug(PTL_INVALID_HANDLE, PTL_DBG_ALL | 0x001f0000); */ /* PtlNIDebug(PTL_INVALID_HANDLE, PTL_DBG_ALL | 0x00000000); */ /* PtlNIDebug(PTL_INVALID_HANDLE, PTL_DBG_DROP | 0x00000000); */ - /* catamount has different debug symbols, but never prints anything */ - PtlNIDebug(PTL_INVALID_HANDLE, PTL_DEBUG_ALL | PTL_DEBUG_NI_ALL); - /* PtlNIDebug(PTL_INVALID_HANDLE, PTL_DEBUG_DROP | 0x00000000); */ - /* * Allocate and build MDs for a queue of unexpected messages from * all hosts. Drop lock for coming NI init call. diff --git a/src/io/bmi/bmi_tcp/socket-collection-epoll.h b/src/io/bmi/bmi_tcp/socket-collection-epoll.h index 774c259..4c5a238 100644 --- a/src/io/bmi/bmi_tcp/socket-collection-epoll.h +++ b/src/io/bmi/bmi_tcp/socket-collection-epoll.h @@ -120,6 +120,7 @@ do { \ do { \ struct epoll_event event;\ struct tcp_addr* tcp_data = (m)->method_data; \ + tcp_data->write_ref_count = 0; \ memset(&event, 0, sizeof(event));\ event.events = 0;\ event.data.ptr = tcp_data->map;\ diff --git a/src/io/description/dist-twod-stripe.c b/src/io/description/dist-twod-stripe.c index a1595d2..f15e676 100644 --- a/src/io/description/dist-twod-stripe.c +++ b/src/io/description/dist-twod-stripe.c @@ -266,9 +266,9 @@ static PVFS_size logical_file_size(void* params, } gossip_debug(GOSSIP_DIST_DEBUG, - "%s: server_ct: %llu log_size: %llu\n", + "%s: server_ct: %u log_size: %llu\n", __func__, - llu(server_ct), + server_ct, llu(cur_max)); return cur_max; diff --git a/src/io/dev/pint-dev.c b/src/io/dev/pint-dev.c index 45ba84e..42791ee 100644 --- a/src/io/dev/pint-dev.c +++ b/src/io/dev/pint-dev.c @@ -210,8 +210,8 @@ int PINT_dev_get_mapped_regions(int ndesc, struct PVFS_dev_map_desc *desc, desc[i].count = params[i].dev_buffer_count; gossip_get_debug_mask(&debug_on, &debug_mask); - gossip_set_debug_mask(1, GOSSIP_DEV_DEBUG); - gossip_debug(GOSSIP_DEV_DEBUG, + gossip_set_debug_mask(1, GOSSIP_USER_DEV_DEBUG); + gossip_debug(GOSSIP_USER_DEV_DEBUG, "[INFO]: Mapping pointer %p for I/O.\n", ptr); gossip_set_debug_mask(debug_on, debug_mask); @@ -328,7 +328,7 @@ int PINT_dev_test_unexpected( pfd.fd = pdev_fd; pfd.events = POLLIN; - gossip_debug(GOSSIP_DEV_DEBUG, + gossip_debug(GOSSIP_USER_DEV_DEBUG, "[DEV]: Entered %s: incount: %d, timeout: %d\n", __func__, incount, max_idle_time); @@ -367,7 +367,7 @@ int PINT_dev_test_unexpected( /* device is emptied */ if (avail == 0) { - gossip_debug(GOSSIP_DEV_DEBUG, + gossip_debug(GOSSIP_USER_DEV_DEBUG, "[DEV]: Exiting %s: incount: %d, device empty!\n", __func__, incount); return ((*outcount > 0) ? 1 : 0); @@ -417,7 +417,7 @@ int PINT_dev_test_unexpected( /* assume we are done and return */ safe_exit: free(buffer); - gossip_debug(GOSSIP_DEV_DEBUG, + gossip_debug(GOSSIP_USER_DEV_DEBUG, "[DEV]: %s Exit: " "incount: %d, outcount: %d, bytes available: %d\n", __func__, incount, *outcount, avail); @@ -489,7 +489,7 @@ int PINT_dev_test_unexpected( } while((*outcount < incount) && avail); - gossip_debug(GOSSIP_DEV_DEBUG, + gossip_debug(GOSSIP_USER_DEV_DEBUG, "[DEV]: %s Exit: " "incount: %d, outcount: %d, bytes available: %d\n", __func__, incount, *outcount, avail); diff --git a/src/io/job/job.c b/src/io/job/job.c index 60b04db..9db968f 100644 --- a/src/io/job/job.c +++ b/src/io/job/job.c @@ -1006,8 +1006,11 @@ int job_dev_write_list(void** buffer_list, * returns 0 on success, -errno on failure, and 1 on immediate * completion */ -int job_req_sched_post(struct PVFS_server_req *in_request, - int req_index, +int job_req_sched_post(enum PVFS_server_op op, + PVFS_fs_id fs_id, + PVFS_handle handle, + int read_only, + int schedule, void *user_ptr, job_aint status_user_tag, job_status_s * out_status_p, @@ -1037,7 +1040,8 @@ int job_req_sched_post(struct PVFS_server_req *in_request, jd->context_id = context_id; jd->status_user_tag = status_user_tag; - ret = PINT_req_sched_post(in_request, req_index, jd, &(jd->u.req_sched.id)); + ret = PINT_req_sched_post( + op, fs_id, handle, read_only, schedule, jd, &(jd->u.req_sched.id)); if (ret < 0) { @@ -1067,6 +1071,51 @@ int job_req_sched_post(struct PVFS_server_req *in_request, return (0); } +int job_req_sched_change_mode(enum PVFS_server_mode mode, + void *user_ptr, + job_aint status_user_tag, + job_status_s *out_status_p, + job_id_t *id, + job_context_id context_id) +{ + struct job_desc *jd = NULL; + int ret = -1; + + jd = alloc_job_desc(JOB_REQ_SCHED); + if(!jd) + { + return (errno); + } + jd->job_user_ptr = user_ptr; + jd->u.req_sched.post_flag = 1; + jd->context_id = context_id; + jd->status_user_tag = status_user_tag; + + ret = PINT_req_sched_change_mode(mode, jd, &(jd->u.req_sched.id)); + if (ret < 0) + { + /* error posting */ + dealloc_job_desc(jd); + jd = NULL; + out_status_p->error_code = ret; + out_status_p->status_user_tag = status_user_tag; + return (1); + } + + if (ret == 1) + { + /* immediate completion */ + out_status_p->error_code = 0; + out_status_p->status_user_tag = status_user_tag; + *id = jd->job_id; + /* don't delete the job desc until a matching release comes through */ + return (1); + } + + *id = jd->job_id; + return (0); +} + /* job_req_sched_post_timer() * * posts a timer to the request scheduler diff --git a/src/io/job/job.h b/src/io/job/job.h index 3b48890..7736718 100644 --- a/src/io/job/job.h +++ b/src/io/job/job.h @@ -176,14 +176,25 @@ int job_dev_write_list(void** buffer_list, job_context_id context_id); /* request scheduler post */ -int job_req_sched_post(struct PVFS_server_req *in_request, - int req_index, +int job_req_sched_post(enum PVFS_server_op op, + PVFS_fs_id fs_id, + PVFS_handle handle, + int readonly, + int schedule, void *user_ptr, job_aint status_user_tag, job_status_s * out_status_p, job_id_t * id, job_context_id context_id); +/* change the mode */ +int job_req_sched_change_mode(enum PVFS_server_mode mode, + void *user_ptr, + job_aint status_user_tag, + job_status_s *out_status_p, + job_id_t *id, + job_context_id context_id); + int job_req_sched_post_timer(int msecs, void *user_ptr, job_aint status_user_tag, diff --git a/src/io/trove/trove-dbpf/dbpf-dspace.c b/src/io/trove/trove-dbpf/dbpf-dspace.c index 109fd0e..51fae51 100644 --- a/src/io/trove/trove-dbpf/dbpf-dspace.c +++ b/src/io/trove/trove-dbpf/dbpf-dspace.c @@ -645,6 +645,7 @@ static int dbpf_dspace_iterate_handles_op_svc(struct dbpf_op *op_p) data.size = data.ulen = start_size; data.flags = DB_DBT_USERMEM; + tmp_ptr = NULL; while(i < *op_p->u.d_iterate_handles.count_p) { ret = dbc_p->c_get(dbc_p, &key, &data, DB_MULTIPLE_KEY|DB_NEXT); diff --git a/src/io/trove/trove-dbpf/dbpf-mgmt.c b/src/io/trove/trove-dbpf/dbpf-mgmt.c index 9133020..c980cc7 100644 --- a/src/io/trove/trove-dbpf/dbpf-mgmt.c +++ b/src/io/trove/trove-dbpf/dbpf-mgmt.c @@ -16,6 +16,7 @@ #include #include #include +#include #include "trove.h" #ifdef HAVE_MALLOC_H @@ -47,6 +48,7 @@ extern int TROVE_shm_key_hint; struct dbpf_storage *my_storage_p = NULL; static int db_open_count, db_close_count; +static void unlink_db_cache_files(const char* path); #define COLL_ENV_FLAGS (DB_INIT_MPOOL | DB_CREATE | DB_THREAD) @@ -74,16 +76,33 @@ DB_ENV *dbpf_getdb_env(const char *path, unsigned int env_flags, int *error) } /* we start by making sure any old environment remnants are cleaned up */ - ret = db_env_create(&dbenv, 0); - if (ret != 0) + if(my_storage_p->flags & TROVE_DB_CACHE_MMAP) { - gossip_err("dbpf_env_create: could not create " - "any environment handle: %s\n", - db_strerror(ret)); - return 0; + /* mmap case: use env->remove function */ + ret = db_env_create(&dbenv, 0); + if (ret != 0) + { + gossip_err("dbpf_env_create: could not create " + "any environment handle: %s\n", + db_strerror(ret)); + *error = ret; + return NULL; + } + + /* don't check return code here; we don't care if it fails */ + dbenv->remove(dbenv, path, DB_FORCE); + } + else + { + /* shm case */ + /* destroy any old __db.??? files to make sure we don't accidentially + * reuse a shmid and collide with a server process that is already + * running on this node. We don't use env->remove because it could + * interfere with shm regions already allocated by another server + * process + */ + unlink_db_cache_files(path); } - /* don't check return code here; we don't care if it fails */ - dbenv->remove(dbenv, path, DB_FORCE); retry: ret = db_env_create(&dbenv, 0); @@ -134,6 +153,8 @@ DB_ENV *dbpf_getdb_env(const char *path, unsigned int env_flags, int *error) else { /* default to using shm style cache */ + + gossip_debug(GOSSIP_TROVE_DEBUG, "dbpf using shm key: %d\n", (646567223+TROVE_shm_key_hint)); ret = dbenv->set_shm_key(dbenv, (646567223+TROVE_shm_key_hint)); @@ -164,13 +185,7 @@ DB_ENV *dbpf_getdb_env(const char *path, unsigned int env_flags, int *error) * before using it again */ if (ret == EAGAIN) { - ret = dbenv->remove(dbenv, path, DB_FORCE); - if (ret != 0) - { - gossip_lerr("dbpf_remove(%s): %s\n", path, db_strerror(ret)); - *error = ret; - return NULL; - } + unlink_db_cache_files(path); assert(my_storage_p != NULL); my_storage_p->flags |= TROVE_DB_CACHE_MMAP; goto retry; @@ -180,15 +195,7 @@ DB_ENV *dbpf_getdb_env(const char *path, unsigned int env_flags, int *error) * open returns an EINVAL, retry with DB_PRIVATE. */ if(ret == EINVAL) { - - ret = dbenv->remove(dbenv, path, DB_FORCE); - if(ret != 0) - { - gossip_lerr("dbpf_remove(%s): %s\n", path, db_strerror(ret)); - *error = ret; - return NULL; - } - assert(my_storage_p != NULL); + unlink_db_cache_files(path); ret = dbenv->open(dbenv, path, DB_CREATE| DB_THREAD| @@ -212,6 +219,7 @@ DB_ENV *dbpf_getdb_env(const char *path, unsigned int env_flags, int *error) return NULL; } } + return dbenv; } @@ -1918,6 +1926,36 @@ char *dbpf_op_type_to_str(enum dbpf_op_type op_type) return ret; } +static void unlink_db_cache_files(const char* path) +{ + char* db_region_file = NULL; + glob_t pglob; + int ret; + int i; + + db_region_file = malloc(PATH_MAX); + if(!db_region_file) + { + return; + } + + snprintf(db_region_file, PATH_MAX, "%s/__db.???", path); + + ret = glob(db_region_file, 0, NULL, &pglob); + if(ret == 0) + { + for(i=0; id_inode : NULL); + struct inode *parent_inode = NULL; + pvfs2_kernel_op_t *new_op = NULL; + pvfs2_inode_t *parent = NULL; - return 0; + gossip_debug(GOSSIP_DCACHE_DEBUG, "pvfs2_d_revalidate_common: called on dentry %p.\n", dentry); + + /* find parent inode */ + if(dentry && dentry->d_parent) + { + gossip_debug(GOSSIP_DCACHE_DEBUG, "pvfs2_d_revalidate_common: parent found.\n"); + parent_inode = dentry->d_parent->d_inode; + } + else + { + gossip_debug(GOSSIP_DCACHE_DEBUG, "pvfs2_d_revalidate_common: parent not found.\n"); + } + + if (inode && parent_inode) + { + /* first perform a lookup to make sure that the object not only + * exists, but is still in the expected place in the name space + */ + if (!is_root_handle(inode)) + { + gossip_debug(GOSSIP_DCACHE_DEBUG, "pvfs2_d_revalidate_common: attempting lookup.\n"); + new_op = op_alloc(PVFS2_VFS_OP_LOOKUP); + if (!new_op) + { + return 0; + } + new_op->upcall.req.lookup.sym_follow = PVFS2_LOOKUP_LINK_NO_FOLLOW; + parent = PVFS2_I(parent_inode); + if (parent && parent->refn.handle != PVFS_HANDLE_NULL && parent->refn.fs_id != PVFS_FS_ID_NULL) + { + new_op->upcall.req.lookup.parent_refn = parent->refn; + } + else + { +#if defined(HAVE_IGET4_LOCKED) || defined(HAVE_IGET5_LOCKED) + gossip_lerr("Critical error: i_ino cannot be relied upon when using iget5/iget4\n"); + op_release(new_op); + return 0; +#endif + new_op->upcall.req.lookup.parent_refn.handle = + get_handle_from_ino(parent_inode); + new_op->upcall.req.lookup.parent_refn.fs_id = + PVFS2_SB(parent_inode->i_sb)->fs_id; + } + strncpy(new_op->upcall.req.lookup.d_name, + dentry->d_name.name, PVFS2_NAME_LEN); + + ret = service_operation( + new_op, "pvfs2_lookup", + get_interruptible_flag(parent_inode)); + + if((new_op->downcall.status != 0) || + !match_handle(new_op->downcall.resp.lookup.refn.handle, inode)) + { + gossip_debug(GOSSIP_DCACHE_DEBUG, "pvfs2_d_revalidate_common: lookup failure or no match.\n"); + op_release(new_op); + /* mark the inode as bad so that d_delete will be aggressive + * about dropping the dentry + */ + pvfs2_make_bad_inode(inode); + return(0); + } + + op_release(new_op); + } + else + { + gossip_debug(GOSSIP_DCACHE_DEBUG, "pvfs2_d_revalidate_common: root handle, lookup skipped.\n"); + } + + /* now perform revalidation */ + gossip_debug(GOSSIP_DCACHE_DEBUG, " (inode %llu)\n", + llu(get_handle_from_ino(inode))); + gossip_debug(GOSSIP_DCACHE_DEBUG, "pvfs2_d_revalidate_common: calling pvfs2_internal_revalidate().\n"); + ret = pvfs2_internal_revalidate(inode); + } + else + { + gossip_debug(GOSSIP_DCACHE_DEBUG, "\n"); + } + return ret; +} + +static int pvfs2_d_delete (struct dentry * dentry) +{ + gossip_debug(GOSSIP_DCACHE_DEBUG, "pvfs2_d_delete: called on dentry %p.\n", dentry); + if(dentry->d_inode && is_bad_inode(dentry->d_inode)) + { + gossip_debug(GOSSIP_DCACHE_DEBUG, "pvfs2_d_delete: returning 1 (bad inode).\n"); + return 1; + } + else + { + gossip_debug(GOSSIP_DCACHE_DEBUG, "pvfs2_d_delete: returning 0 (inode looks ok).\n"); + return 0; + } } /* should return 1 if dentry can still be trusted, else 0 */ @@ -78,13 +171,11 @@ static int pvfs2_d_compare( { gossip_debug(GOSSIP_DCACHE_DEBUG, "pvfs2_d_compare: called on parent %p\n (name1: %s| " "name2: %s)\n", parent, d_name->name, name->name); - /* force a cache miss every time */ - return 1; -} -static int pvfs2_d_delete (struct dentry * dentry) -{ - return 1; + /* if we have a match, return 0 (normally called from __d_lookup) */ + return !((d_name->len == name->len) && + (d_name->hash == name->hash) && + (memcmp(d_name->name, name->name, d_name->len) == 0)); } /** PVFS2 implementation of VFS dentry operations */ diff --git a/src/kernel/linux-2.6/dir.c b/src/kernel/linux-2.6/dir.c index 575729d..40d040f 100644 --- a/src/kernel/linux-2.6/dir.c +++ b/src/kernel/linux-2.6/dir.c @@ -124,7 +124,6 @@ static int pvfs2_readdir( pvfs2_kernel_op_t *new_op = NULL; pvfs2_inode_t *pvfs2_inode = PVFS2_I(dentry->d_inode); - pos = (PVFS_ds_position)file->f_pos; /* are we done? */ if (pos == PVFS_READDIR_END) @@ -266,6 +265,12 @@ static int pvfs2_readdir( if (filldir(dirent, current_entry, len, pos, current_ino, DT_UNKNOWN) < 0) { + gossip_debug(GOSSIP_DIR_DEBUG, "filldir() failed.\n"); + if(token_set && (i < 2)) + { + gossip_err("Filldir failed on one of the first two true PVFS directory entries.\n"); + gossip_err("Duplicate entries may appear.\n"); + } ret = 0; break; } @@ -276,13 +281,21 @@ static int pvfs2_readdir( * returned by the readdir response */ if (token_set == 1) { + /* this means that all of the filldir calls succeeded */ if (i == rhandle.readdir_response.pvfs_dirent_outcount) + { file->f_pos = rhandle.readdir_response.token; + } else - file->f_pos = i; + { + /* this means a filldir call failed */ + file->f_pos = i - 1; + gossip_debug(GOSSIP_DIR_DEBUG, "at least one filldir call failed. Setting f_pos to: %ld\n", (unsigned long) file->f_pos); + } } + gossip_debug(GOSSIP_DIR_DEBUG, - "pos = %llu, file->f_pos should have been %ld\n", + "pos = %llu, file->f_pos should have been %ld\n", llu(pos), (unsigned long) file->f_pos); } @@ -885,7 +898,8 @@ struct file_operations pvfs2_dir_operations = read : generic_read_dir, readdir : pvfs2_readdir, open : pvfs2_file_open, - release : pvfs2_file_release + release : pvfs2_file_release, + llseek : pvfs2_dir_llseek #else .read = generic_read_dir, .readdir = pvfs2_readdir, @@ -896,7 +910,7 @@ struct file_operations pvfs2_dir_operations = .readdirplus_lite = pvfs2_readdirplus_lite, #endif .open = pvfs2_file_open, - .release = pvfs2_file_release + .release = pvfs2_file_release, #endif }; diff --git a/src/kernel/linux-2.6/file.c b/src/kernel/linux-2.6/file.c index 588bad2..6e32648 100644 --- a/src/kernel/linux-2.6/file.c +++ b/src/kernel/linux-2.6/file.c @@ -3249,6 +3249,11 @@ static ssize_t pvfs2_sendfile(struct file *filp, loff_t *ppos, #endif +int pvfs2_lock(struct file *f, int flags, struct file_lock *lock) +{ + return -ENOSYS; +} + /** PVFS2 implementation of VFS file operations */ struct file_operations pvfs2_file_operations = { @@ -3271,6 +3276,7 @@ struct file_operations pvfs2_file_operations = /* for >= 2.6.19 */ .aio_read = pvfs2_file_aio_read_iovec, .aio_write = pvfs2_file_aio_write_iovec, + .lock = pvfs2_lock, #else .readv = pvfs2_file_readv, .writev = pvfs2_file_writev, @@ -3293,6 +3299,7 @@ struct file_operations pvfs2_file_operations = #ifdef HAVE_WRITEX_FILE_OPERATIONS .writex = pvfs2_file_writex, #endif + .lock = pvfs2_lock, #endif }; diff --git a/src/kernel/linux-2.6/inode.c b/src/kernel/linux-2.6/inode.c index 80935bb..e690807 100644 --- a/src/kernel/linux-2.6/inode.c +++ b/src/kernel/linux-2.6/inode.c @@ -464,7 +464,7 @@ struct inode *pvfs2_iget_common(struct super_block *sb, PVFS_object_ref *ref, in } #endif /* issue a call to read the inode */ - sb->s_op->read_inode(inode); + pvfs2_read_inode(inode); unlock_new_inode(inode); } #endif diff --git a/src/kernel/linux-2.6/pvfs2-bufmap.c b/src/kernel/linux-2.6/pvfs2-bufmap.c index 143c6a9..5fccd30 100644 --- a/src/kernel/linux-2.6/pvfs2-bufmap.c +++ b/src/kernel/linux-2.6/pvfs2-bufmap.c @@ -24,6 +24,7 @@ inline int pvfs_bufmap_shift_query(void) } static int bufmap_init = 0; +DECLARE_RWSEM(bufmap_init_sem); static struct page **bufmap_page_array = NULL; /* array to track usage of buffer descriptors */ @@ -108,6 +109,7 @@ int pvfs_bufmap_initialize(struct PVFS_dev_map_desc *user_desc) "(ptr (%p) sz (%d) cnt(%d).\n", user_desc->ptr, user_desc->size, user_desc->count); + down_write(&bufmap_init_sem); if (bufmap_init == 1) { gossip_err("pvfs2: error: bufmap already initialized.\n"); @@ -171,13 +173,13 @@ int pvfs_bufmap_initialize(struct PVFS_dev_map_desc *user_desc) } /* map the pages */ - down_read(¤t->mm->mmap_sem); + down_write(¤t->mm->mmap_sem); ret = get_user_pages( current, current->mm, (unsigned long)user_desc->ptr, bufmap_page_count, 1, 0, bufmap_page_array, NULL); - up_read(¤t->mm->mmap_sem); + up_write(¤t->mm->mmap_sem); if (ret < 0) { @@ -245,12 +247,14 @@ int pvfs_bufmap_initialize(struct PVFS_dev_map_desc *user_desc) spin_unlock(&readdir_index_lock); bufmap_init = 1; + up_write(&bufmap_init_sem); gossip_debug(GOSSIP_BUFMAP_DEBUG, "pvfs2_bufmap_initialize: exiting normally\n"); return 0; init_failure: finalize_bufmap_descriptors(); + up_write(&bufmap_init_sem); return ret; } @@ -267,10 +271,12 @@ void pvfs_bufmap_finalize(void) gossip_debug(GOSSIP_BUFMAP_DEBUG, "pvfs2_bufmap_finalize: called\n"); + down_write(&bufmap_init_sem); if (bufmap_init == 0) { gossip_debug(GOSSIP_BUFMAP_DEBUG, "pvfs2_bufmap_finalize: not yet " "initialized; returning\n"); + up_write(&bufmap_init_sem); return; } @@ -284,6 +290,7 @@ void pvfs_bufmap_finalize(void) bufmap_init = 0; finalize_bufmap_descriptors(); + up_write(&bufmap_init_sem); gossip_debug(GOSSIP_BUFMAP_DEBUG, "pvfs2_bufmap_finalize: exiting normally\n"); } @@ -373,12 +380,25 @@ static void put_back_slot(struct slot_args *slargs, int buffer_index) int pvfs_bufmap_get(int *buffer_index) { struct slot_args slargs; + int ret; + + down_read(&bufmap_init_sem); + if (bufmap_init == 0) + { + gossip_err("pvfs_bufmap_get: not yet " + "initialized.\n"); + gossip_err("pvfs2: please confirm that pvfs2-client daemon is running.\n"); + up_read(&bufmap_init_sem); + return -EIO; + } slargs.slot_count = pvfs2_bufmap_desc_count; slargs.slot_array = buffer_index_array; slargs.slot_lock = &buffer_index_lock; slargs.slot_wq = &bufmap_waitq; - return wait_for_a_slot(&slargs, buffer_index); + ret = wait_for_a_slot(&slargs, buffer_index); + up_read(&bufmap_init_sem); + return(ret); } /* pvfs_bufmap_put() @@ -391,11 +411,22 @@ void pvfs_bufmap_put(int buffer_index) { struct slot_args slargs; + down_read(&bufmap_init_sem); + if (bufmap_init == 0) + { + gossip_err("pvfs_bufmap_put: not yet " + "initialized.\n"); + gossip_err("pvfs2: please confirm that pvfs2-client daemon is running.\n"); + up_read(&bufmap_init_sem); + return; + } + slargs.slot_count = pvfs2_bufmap_desc_count; slargs.slot_array = buffer_index_array; slargs.slot_lock = &buffer_index_lock; slargs.slot_wq = &bufmap_waitq; put_back_slot(&slargs, buffer_index); + up_read(&bufmap_init_sem); return; } @@ -412,23 +443,48 @@ void pvfs_bufmap_put(int buffer_index) int readdir_index_get(int *buffer_index) { struct slot_args slargs; + int ret; + + down_read(&bufmap_init_sem); + if (bufmap_init == 0) + { + gossip_err("pvfs_bufmap_get: not yet " + "initialized.\n"); + gossip_err("pvfs2: please confirm that pvfs2-client daemon is running.\n"); + up_read(&bufmap_init_sem); + return -EIO; + } slargs.slot_count = PVFS2_READDIR_DEFAULT_DESC_COUNT; slargs.slot_array = readdir_index_array; slargs.slot_lock = &readdir_index_lock; slargs.slot_wq = &readdir_waitq; - return wait_for_a_slot(&slargs, buffer_index); + ret = wait_for_a_slot(&slargs, buffer_index); + up_read(&bufmap_init_sem); + return(ret); } void readdir_index_put(int buffer_index) { struct slot_args slargs; + down_read(&bufmap_init_sem); + if (bufmap_init == 0) + { + gossip_err("pvfs_bufmap_get: not yet " + "initialized.\n"); + gossip_err("pvfs2: please confirm that pvfs2-client daemon is running.\n"); + up_read(&bufmap_init_sem); + return; + } + + slargs.slot_count = PVFS2_READDIR_DEFAULT_DESC_COUNT; slargs.slot_array = readdir_index_array; slargs.slot_lock = &readdir_index_lock; slargs.slot_wq = &readdir_waitq; put_back_slot(&slargs, buffer_index); + up_read(&bufmap_init_sem); return; } @@ -449,11 +505,13 @@ int pvfs_bufmap_copy_to_user(void __user *to, int buffer_index, size_t size) gossip_debug(GOSSIP_BUFMAP_DEBUG, "pvfs_bufmap_copy_to_user: to %p, from %p, index %d, " "size %zd\n", to, from, buffer_index, size); + down_read(&bufmap_init_sem); if (bufmap_init == 0) { gossip_err("pvfs_bufmap_copy_to_user: not yet " "initialized.\n"); gossip_err("pvfs2: please confirm that pvfs2-client daemon is running.\n"); + up_read(&bufmap_init_sem); return -EIO; } @@ -470,6 +528,7 @@ int pvfs_bufmap_copy_to_user(void __user *to, int buffer_index, size_t size) if (ret) { gossip_debug(GOSSIP_BUFMAP_DEBUG, "Failed to copy data to user space %zd\n", ret); + up_read(&bufmap_init_sem); return -EFAULT; } @@ -477,6 +536,7 @@ int pvfs_bufmap_copy_to_user(void __user *to, int buffer_index, size_t size) amt_copied += cur_copy_size; index++; } + up_read(&bufmap_init_sem); return 0; } @@ -491,11 +551,13 @@ int pvfs_bufmap_copy_to_kernel( gossip_debug(GOSSIP_BUFMAP_DEBUG, "pvfs_bufmap_copy_to_kernel: to %p, index %d, size %zd\n", to, buffer_index, size); + down_read(&bufmap_init_sem); if (bufmap_init == 0) { gossip_err("pvfs_bufmap_copy_to_kernel: not yet " "initialized.\n"); gossip_err("pvfs2: please confirm that pvfs2-client daemon is running.\n"); + up_read(&bufmap_init_sem); return -EIO; } @@ -513,6 +575,7 @@ int pvfs_bufmap_copy_to_kernel( amt_copied += cur_copy_size; index++; } + up_read(&bufmap_init_sem); return 0; } @@ -536,11 +599,13 @@ int pvfs_bufmap_copy_from_user( gossip_debug(GOSSIP_BUFMAP_DEBUG, "pvfs_bufmap_copy_from_user: from %p, index %d, " "size %zd\n", from, buffer_index, size); + down_read(&bufmap_init_sem); if (bufmap_init == 0) { gossip_err("pvfs_bufmap_copy_from_user: not yet " "initialized.\n"); gossip_err("pvfs2: please confirm that pvfs2-client daemon is running.\n"); + up_read(&bufmap_init_sem); return -EIO; } @@ -564,6 +629,7 @@ int pvfs_bufmap_copy_from_user( if (ret) { gossip_debug(GOSSIP_BUFMAP_DEBUG, "Failed to copy data from user space\n"); + up_read(&bufmap_init_sem); return -EFAULT; } @@ -571,6 +637,7 @@ int pvfs_bufmap_copy_from_user( amt_copied += cur_copy_size; index++; } + up_read(&bufmap_init_sem); return 0; } @@ -596,11 +663,13 @@ int pvfs_bufmap_copy_to_pages(int buffer_index, gossip_debug(GOSSIP_BUFMAP_DEBUG, "pvfs_bufmap_copy_to_pages: nr_pages %lu," "index %d, size %zd\n", nr_segs, buffer_index, size); + down_read(&bufmap_init_sem); if (bufmap_init == 0) { gossip_err("pvfs_bufmap_copy_to_pages: not yet " "initialized.\n"); gossip_err("pvfs2: please confirm that pvfs2-client is running.\n"); + up_read(&bufmap_init_sem); return -EIO; } @@ -610,12 +679,14 @@ int pvfs_bufmap_copy_to_pages(int buffer_index, { gossip_err("pvfs_bufmap_copy_to_pages: count cannot exceed " "number of pages(%lu)\n", nr_segs); + up_read(&bufmap_init_sem); return -EIO; } page = (struct page *) vec[index].iov_base; if (page == NULL) { gossip_err("pvfs_bufmap_copy_to_pages: invalid page pointer %d\n", index); + up_read(&bufmap_init_sem); return -EIO; } amt_remaining = (size - amt_copied); @@ -643,6 +714,7 @@ int pvfs_bufmap_copy_to_pages(int buffer_index, amt_copied += cur_copy_size; index++; } + up_read(&bufmap_init_sem); return 0; } @@ -668,11 +740,13 @@ int pvfs_bufmap_copy_from_pages(int buffer_index, gossip_debug(GOSSIP_BUFMAP_DEBUG, "pvfs_bufmap_copy_from_pages: nr_pages %lu " "index %d, size %zd\n", nr_segs, buffer_index, size); + down_read(&bufmap_init_sem); if (bufmap_init == 0) { gossip_err("pvfs_bufmap_copy_from_pages: not yet " "initialized.\n"); gossip_err("pvfs2: please confirm that pvfs2-client is running.\n"); + up_read(&bufmap_init_sem); return -EIO; } @@ -681,11 +755,13 @@ int pvfs_bufmap_copy_from_pages(int buffer_index, if (index >= nr_segs) { gossip_err("pvfs_bufmap_copy_from_pages: count cannot exceed number of" "pages(%lu)\n", nr_segs); + up_read(&bufmap_init_sem); return -EIO; } page = (struct page *) vec[index].iov_base; if (page == NULL) { gossip_err("pvfs_bufmap_copy_from_pages: invalid page pointer\n"); + up_read(&bufmap_init_sem); return -EIO; } amt_remaining = (size - amt_copied); @@ -706,6 +782,7 @@ int pvfs_bufmap_copy_from_pages(int buffer_index, amt_copied += cur_copy_size; index++; } + up_read(&bufmap_init_sem); return 0; } @@ -741,10 +818,12 @@ int pvfs_bufmap_copy_iovec_from_user( gossip_debug(GOSSIP_BUFMAP_DEBUG, "pvfs_bufmap_copy_iovec_from_user: index %d, " "size %zd\n", buffer_index, size); + down_read(&bufmap_init_sem); if (bufmap_init == 0) { gossip_debug(GOSSIP_BUFMAP_DEBUG, "pvfs_bufmap_copy_iovec_from_user: not yet " "initialized; returning\n"); + up_read(&bufmap_init_sem); return -EIO; } /* @@ -755,6 +834,7 @@ int pvfs_bufmap_copy_iovec_from_user( if (copied_iovec == NULL) { gossip_err("pvfs2_bufmap_copy_iovec_from_user: failed allocating memory\n"); + up_read(&bufmap_init_sem); return -ENOMEM; } memcpy(copied_iovec, iov, nr_segs * sizeof(struct iovec)); @@ -771,6 +851,7 @@ int pvfs_bufmap_copy_iovec_from_user( gossip_err("pvfs2_bufmap_copy_iovec_from_user: computed total (%zd) is not equal to (%zd)\n", amt_copied, size); kfree(copied_iovec); + up_read(&bufmap_init_sem); return -EINVAL; } @@ -827,6 +908,7 @@ int pvfs_bufmap_copy_iovec_from_user( { gossip_err("Failed to copy data from user space\n"); kfree(copied_iovec); + up_read(&bufmap_init_sem); return -EFAULT; } @@ -840,6 +922,7 @@ int pvfs_bufmap_copy_iovec_from_user( } } kfree(copied_iovec); + up_read(&bufmap_init_sem); return 0; } @@ -872,10 +955,12 @@ int pvfs_bufmap_copy_iovec_from_kernel( gossip_debug(GOSSIP_BUFMAP_DEBUG, "pvfs_bufmap_copy_iovec_from_kernel: index %d, " "size %zd\n", buffer_index, size); + down_read(&bufmap_init_sem); if (bufmap_init == 0) { gossip_debug(GOSSIP_BUFMAP_DEBUG, "pvfs_bufmap_copy_iovec_from_kernel: not yet " "initialized; returning\n"); + up_read(&bufmap_init_sem); return -EIO; } /* @@ -886,6 +971,7 @@ int pvfs_bufmap_copy_iovec_from_kernel( if (copied_iovec == NULL) { gossip_err("pvfs2_bufmap_copy_iovec_from_kernel: failed allocating memory\n"); + up_read(&bufmap_init_sem); return -ENOMEM; } memcpy(copied_iovec, iov, nr_segs * sizeof(struct iovec)); @@ -902,6 +988,7 @@ int pvfs_bufmap_copy_iovec_from_kernel( gossip_err("pvfs2_bufmap_copy_iovec_from_kernel: computed total (%zd) is not equal to (%zd)\n", amt_copied, size); kfree(copied_iovec); + up_read(&bufmap_init_sem); return -EINVAL; } @@ -956,6 +1043,7 @@ int pvfs_bufmap_copy_iovec_from_kernel( } } kfree(copied_iovec); + up_read(&bufmap_init_sem); return 0; } @@ -986,10 +1074,12 @@ int pvfs_bufmap_copy_to_user_iovec( gossip_debug(GOSSIP_BUFMAP_DEBUG, "pvfs_bufmap_copy_to_user_iovec: index %d, " "size %zd\n", buffer_index, size); + down_read(&bufmap_init_sem); if (bufmap_init == 0) { gossip_debug(GOSSIP_BUFMAP_DEBUG, "pvfs2_bufmap_copy_to_user_iovec: not yet " "initialized; returning\n"); + up_read(&bufmap_init_sem); return -EIO; } /* @@ -1000,6 +1090,7 @@ int pvfs_bufmap_copy_to_user_iovec( if (copied_iovec == NULL) { gossip_err("pvfs2_bufmap_copy_to_user_iovec: failed allocating memory\n"); + up_read(&bufmap_init_sem); return -ENOMEM; } memcpy(copied_iovec, iov, nr_segs * sizeof(struct iovec)); @@ -1016,6 +1107,7 @@ int pvfs_bufmap_copy_to_user_iovec( gossip_err("pvfs2_bufmap_copy_to_user_iovec: computed total (%zd) is less than (%zd)\n", amt_copied, size); kfree(copied_iovec); + up_read(&bufmap_init_sem); return -EINVAL; } @@ -1071,6 +1163,7 @@ int pvfs_bufmap_copy_to_user_iovec( { gossip_err("Failed to copy data to user space\n"); kfree(copied_iovec); + up_read(&bufmap_init_sem); return -EFAULT; } @@ -1084,6 +1177,7 @@ int pvfs_bufmap_copy_to_user_iovec( } } kfree(copied_iovec); + up_read(&bufmap_init_sem); return 0; } @@ -1112,10 +1206,12 @@ int pvfs_bufmap_copy_to_kernel_iovec( gossip_debug(GOSSIP_BUFMAP_DEBUG, "pvfs_bufmap_copy_to_kernel_iovec: index %d, " "size %zd\n", buffer_index, size); + down_read(&bufmap_init_sem); if (bufmap_init == 0) { gossip_debug(GOSSIP_BUFMAP_DEBUG, "pvfs2_bufmap_copy_to_kernel_iovec: not yet " "initialized; returning\n"); + up_read(&bufmap_init_sem); return -EIO; } /* @@ -1126,6 +1222,7 @@ int pvfs_bufmap_copy_to_kernel_iovec( if (copied_iovec == NULL) { gossip_err("pvfs2_bufmap_copy_to_kernel_iovec: failed allocating memory\n"); + up_read(&bufmap_init_sem); return -ENOMEM; } memcpy(copied_iovec, iov, nr_segs * sizeof(struct iovec)); @@ -1142,6 +1239,7 @@ int pvfs_bufmap_copy_to_kernel_iovec( gossip_err("pvfs2_bufmap_copy_to_kernel_iovec: computed total (%zd) is less than (%zd)\n", amt_copied, size); kfree(copied_iovec); + up_read(&bufmap_init_sem); return -EINVAL; } @@ -1197,6 +1295,7 @@ int pvfs_bufmap_copy_to_kernel_iovec( } } kfree(copied_iovec); + up_read(&bufmap_init_sem); return 0; } @@ -1237,17 +1336,20 @@ size_t pvfs_bufmap_copy_to_user_task( " PID: %d, to %p, from %p, index %d, " " size %zd\n", tsk->pid, to, from, buffer_index, size); + down_read(&bufmap_init_sem); if (bufmap_init == 0) { gossip_err("pvfs2_bufmap_copy_to_user: not yet " "initialized.\n"); gossip_err("pvfs2: please confirm that pvfs2-client " "daemon is running.\n"); + up_read(&bufmap_init_sem); return -EIO; } mm = get_task_mm(tsk); if (!mm) { + up_read(&bufmap_init_sem); return -EIO; } /* @@ -1312,6 +1414,7 @@ size_t pvfs_bufmap_copy_to_user_task( } up_read(&mm->mmap_sem); mmput(mm); + up_read(&bufmap_init_sem); return (amt_copied < size) ? -EFAULT: amt_copied; } diff --git a/src/kernel/linux-2.6/pvfs2-kernel.h b/src/kernel/linux-2.6/pvfs2-kernel.h index e510fbf..8ce2be4 100644 --- a/src/kernel/linux-2.6/pvfs2-kernel.h +++ b/src/kernel/linux-2.6/pvfs2-kernel.h @@ -751,6 +751,9 @@ struct super_block *pvfs2_get_sb( #endif #endif +void pvfs2_read_inode( + struct inode *inode); + void pvfs2_kill_sb(struct super_block *sb); int pvfs2_remount( struct super_block *sb, @@ -1275,18 +1278,6 @@ static inline void i_size_write(struct inode *inode, loff_t i_size) } #endif -#ifndef HAVE_KZALLOC -static void *kzalloc(size_t size, gfp_t mask) -{ - void *ptr; - ptr = kmalloc(size, mask); - if (ptr) { - memset(ptr, 0, size); - } - return ptr; -} -#endif - #endif /* PVFS2_LINUX_KERNEL_2_4 */ static inline unsigned int diff(struct timeval *end, struct timeval *begin) diff --git a/src/kernel/linux-2.6/super.c b/src/kernel/linux-2.6/super.c index a4bd7ca..e36e93b 100644 --- a/src/kernel/linux-2.6/super.c +++ b/src/kernel/linux-2.6/super.c @@ -215,7 +215,7 @@ static void pvfs2_destroy_inode(struct inode *inode) } } -static void pvfs2_read_inode( +void pvfs2_read_inode( struct inode *inode) { pvfs2_inode_t *pvfs2_inode = PVFS2_I(inode); @@ -248,7 +248,7 @@ static void pvfs2_read_inode( #else /* !PVFS2_LINUX_KERNEL_2_4 */ -static void pvfs2_read_inode( +void pvfs2_read_inode( struct inode *inode) { pvfs2_inode_t *pvfs2_inode = NULL; @@ -849,7 +849,9 @@ struct super_operations pvfs2_s_ops = .drop_inode = generic_delete_inode, .alloc_inode = pvfs2_alloc_inode, .destroy_inode = pvfs2_destroy_inode, +#ifdef HAVE_READ_INODE .read_inode = pvfs2_read_inode, +#endif .dirty_inode = pvfs2_dirty_inode, .put_inode = pvfs2_put_inode, .statfs = pvfs2_statfs, diff --git a/src/kernel/linux-2.6/waitqueue.c b/src/kernel/linux-2.6/waitqueue.c index fa9310c..ccc56f2 100644 --- a/src/kernel/linux-2.6/waitqueue.c +++ b/src/kernel/linux-2.6/waitqueue.c @@ -59,6 +59,7 @@ int service_operation( retry_servicing: op->downcall.status = 0; gossip_debug(GOSSIP_WAIT_DEBUG, "pvfs2: service_operation: %s %p\n", op_name, op); + gossip_debug(GOSSIP_WAIT_DEBUG, "pvfs2: operation posted by process: %s, pid: %i\n", current->comm, current->pid); /* mask out signals if this operation is not to be interrupted */ if(!(flags & PVFS2_OP_INTERRUPTIBLE)) diff --git a/src/proto/pvfs2-req-proto.h b/src/proto/pvfs2-req-proto.h index 7014dd2..c141cda 100644 --- a/src/proto/pvfs2-req-proto.h +++ b/src/proto/pvfs2-req-proto.h @@ -92,8 +92,10 @@ enum PVFS_server_op /* max size of opaque distribution parameters */ #define PVFS_REQ_LIMIT_DIST_BYTES 1024 -/* max size of each configuration file transmitted to clients */ -#define PVFS_REQ_LIMIT_CONFIG_FILE_BYTES 16384 +/* max size of each configuration file transmitted to clients. + * Note: If you change this value, you should change the $req_limit + * in pvfs2-genconfig as well. */ +#define PVFS_REQ_LIMIT_CONFIG_FILE_BYTES 65536 /* max size of all path strings */ #define PVFS_REQ_LIMIT_PATH_NAME_BYTES PVFS_NAME_MAX /* max size of strings representing a single path element */ @@ -408,7 +410,7 @@ struct PVFS_servreq_lookup_path { char *path; /* path name */ PVFS_fs_id fs_id; /* file system */ - PVFS_handle starting_handle; /* handle of path parent */ + PVFS_handle handle; /* handle of path parent */ /* mask of attribs to return with lookup results */ uint32_t attrmask; }; @@ -417,7 +419,7 @@ endecode_fields_5_struct( string, path, PVFS_fs_id, fs_id, skip4,, - PVFS_handle, starting_handle, + PVFS_handle, handle, uint32_t, attrmask) #define extra_size_PVFS_servreq_lookup_path \ roundup8(PVFS_REQ_LIMIT_PATH_NAME_BYTES + 1) @@ -434,7 +436,7 @@ do { \ (__req).credentials = (__creds); \ (__req).u.lookup_path.path = (__path); \ (__req).u.lookup_path.fs_id = (__fsid); \ - (__req).u.lookup_path.starting_handle = (__handle);\ + (__req).u.lookup_path.handle = (__handle);\ (__req).u.lookup_path.attrmask = (__amask); \ } while (0) @@ -519,14 +521,14 @@ struct PVFS_servreq_crdirent { char *name; /* name of new entry */ PVFS_handle new_handle; /* handle of new entry */ - PVFS_handle parent_handle; /* handle of directory */ + PVFS_handle handle; /* handle of directory */ PVFS_fs_id fs_id; /* file system */ }; endecode_fields_4_struct( PVFS_servreq_crdirent, string, name, PVFS_handle, new_handle, - PVFS_handle, parent_handle, + PVFS_handle, handle, PVFS_fs_id, fs_id) #define extra_size_PVFS_servreq_crdirent \ roundup8(PVFS_REQ_LIMIT_SEGMENT_BYTES+1) @@ -535,7 +537,7 @@ endecode_fields_4_struct( __creds, \ __name, \ __new_handle, \ - __parent_handle, \ + __handle, \ __fs_id) \ do { \ memset(&(__req), 0, sizeof(__req)); \ @@ -543,8 +545,8 @@ do { \ (__req).credentials = (__creds); \ (__req).u.crdirent.name = (__name); \ (__req).u.crdirent.new_handle = (__new_handle); \ - (__req).u.crdirent.parent_handle = \ - (__parent_handle); \ + (__req).u.crdirent.handle = \ + (__handle); \ (__req).u.crdirent.fs_id = (__fs_id); \ } while (0) @@ -554,13 +556,13 @@ do { \ struct PVFS_servreq_rmdirent { char *entry; /* name of entry to remove */ - PVFS_handle parent_handle; /* handle of directory */ + PVFS_handle handle; /* handle of directory */ PVFS_fs_id fs_id; /* file system */ }; endecode_fields_3_struct( PVFS_servreq_rmdirent, string, entry, - PVFS_handle, parent_handle, + PVFS_handle, handle, PVFS_fs_id, fs_id) #define extra_size_PVFS_servreq_rmdirent \ roundup8(PVFS_REQ_LIMIT_SEGMENT_BYTES+1) @@ -575,7 +577,7 @@ do { \ (__req).op = PVFS_SERV_RMDIRENT; \ (__req).credentials = (__creds); \ (__req).u.rmdirent.fs_id = (__fsid); \ - (__req).u.rmdirent.parent_handle = (__handle);\ + (__req).u.rmdirent.handle = (__handle); \ (__req).u.rmdirent.entry = (__entry); \ } while (0); @@ -594,14 +596,14 @@ struct PVFS_servreq_chdirent { char *entry; /* name of entry to remove */ PVFS_handle new_dirent_handle; /* handle of directory */ - PVFS_handle parent_handle; /* handle of directory */ + PVFS_handle handle; /* handle of directory */ PVFS_fs_id fs_id; /* file system */ }; endecode_fields_4_struct( PVFS_servreq_chdirent, string, entry, PVFS_handle, new_dirent_handle, - PVFS_handle, parent_handle, + PVFS_handle, handle, PVFS_fs_id, fs_id) #define extra_size_PVFS_servreq_chdirent \ roundup8(PVFS_REQ_LIMIT_SEGMENT_BYTES+1) @@ -609,7 +611,7 @@ endecode_fields_4_struct( #define PINT_SERVREQ_CHDIRENT_FILL(__req, \ __creds, \ __fsid, \ - __parent_handle,\ + __handle, \ __new_dirent, \ __entry) \ do { \ @@ -617,8 +619,8 @@ do { \ (__req).op = PVFS_SERV_CHDIRENT; \ (__req).credentials = (__creds); \ (__req).u.chdirent.fs_id = (__fsid); \ - (__req).u.chdirent.parent_handle = \ - (__parent_handle); \ + (__req).u.chdirent.handle = \ + (__handle); \ (__req).u.chdirent.new_dirent_handle = \ (__new_dirent); \ (__req).u.chdirent.entry = (__entry); \ diff --git a/src/server/chdirent.sm b/src/server/chdirent.sm index 06a08ab..a6e1c8c 100644 --- a/src/server/chdirent.sm +++ b/src/server/chdirent.sm @@ -115,7 +115,7 @@ static PINT_sm_action chdirent_verify_parent_metadata_and_read_directory_entry_h " reading dirdata handle (coll_id = 0x%x, handle = %llu, " "key = %s (%d), val_buf = %p (%d))\n", s_op->req->u.chdirent.fs_id, - llu(s_op->req->u.chdirent.parent_handle), + llu(s_op->req->u.chdirent.handle), (char *) s_op->key.buffer, s_op->key.buffer_sz, s_op->val.buffer, @@ -123,7 +123,7 @@ static PINT_sm_action chdirent_verify_parent_metadata_and_read_directory_entry_h ret = job_trove_keyval_read( s_op->req->u.chdirent.fs_id, - s_op->req->u.chdirent.parent_handle, + s_op->req->u.chdirent.handle, &s_op->key, &s_op->val, 0, @@ -266,7 +266,7 @@ static PINT_sm_action chdirent_update_directory_attr( PVFS_object_attr_to_ds_attr(tmp_attr_ptr, ds_attr); ret = job_trove_dspace_setattr( - s_op->req->u.chdirent.fs_id, s_op->req->u.chdirent.parent_handle, + s_op->req->u.chdirent.fs_id, s_op->req->u.chdirent.handle, ds_attr, TROVE_SYNC | 0, @@ -319,6 +319,18 @@ static PINT_sm_action chdirent_cleanup( return (server_state_machine_complete(smcb)); } +PINT_GET_OBJECT_REF_DEFINE(chdirent); + +struct PINT_server_req_params pvfs2_chdirent_params = +{ + .string_name = "chdirent", + .perm = PINT_SERVER_CHECK_WRITE, + .access_type = PINT_server_req_modify, + .sched_policy = PINT_SERVER_REQ_SCHEDULE, + .get_object_ref = PINT_get_object_ref_chdirent, + .state_machine = &pvfs2_chdirent_sm +}; + /* * Local variables: * mode: c diff --git a/src/server/crdirent.sm b/src/server/crdirent.sm index bf86dc8..ba8b813 100644 --- a/src/server/crdirent.sm +++ b/src/server/crdirent.sm @@ -326,7 +326,7 @@ static PINT_sm_action crdirent_update_directory_attr( PVFS_object_attr_to_ds_attr(tmp_attr_ptr, ds_attr); ret = job_trove_dspace_setattr( - s_op->req->u.crdirent.fs_id, s_op->req->u.crdirent.parent_handle, + s_op->req->u.crdirent.fs_id, s_op->req->u.crdirent.handle, ds_attr, TROVE_SYNC, smcb, 0, js_p, &j_id, server_job_context); @@ -355,7 +355,7 @@ static PINT_sm_action crdirent_setup_op( s_op->u.crdirent.name = s_op->req->u.crdirent.name; s_op->u.crdirent.new_handle = s_op->req->u.crdirent.new_handle; - s_op->u.crdirent.parent_handle = s_op->req->u.crdirent.parent_handle; + s_op->u.crdirent.parent_handle = s_op->req->u.crdirent.handle; s_op->u.crdirent.fs_id = s_op->req->u.crdirent.fs_id; s_op->u.crdirent.dir_attr_update_required = 0; @@ -363,6 +363,18 @@ static PINT_sm_action crdirent_setup_op( return SM_ACTION_COMPLETE; } +PINT_GET_OBJECT_REF_DEFINE(crdirent); + +struct PINT_server_req_params pvfs2_crdirent_params = +{ + .string_name = "crdirent", + .perm = PINT_SERVER_CHECK_CRDIRENT, + .access_type = PINT_server_req_modify, + .sched_policy = PINT_SERVER_REQ_SCHEDULE, + .get_object_ref = PINT_get_object_ref_crdirent, + .state_machine = &pvfs2_crdirent_sm +}; + /* * Local variables: * mode: c diff --git a/src/server/create.sm b/src/server/create.sm index e3767c4..37fd338 100644 --- a/src/server/create.sm +++ b/src/server/create.sm @@ -158,6 +158,22 @@ static int create_cleanup( return(server_state_machine_complete(smcb)); } +static inline int PINT_get_object_ref_create( + struct PVFS_server_req *req, PVFS_fs_id *fs_id, PVFS_handle *handle) +{ + *fs_id = req->u.create.fs_id; + *handle = PVFS_HANDLE_NULL; + return 0; +}; + +struct PINT_server_req_params pvfs2_create_params = +{ + .string_name = "create", + .get_object_ref = PINT_get_object_ref_create, + .perm = PINT_SERVER_CHECK_NONE, + .access_type = PINT_server_req_modify, + .state_machine = &pvfs2_create_sm +}; /* * Local variables: diff --git a/src/server/del-eattr.sm b/src/server/del-eattr.sm index 4feadb0..4ca65b3 100644 --- a/src/server/del-eattr.sm +++ b/src/server/del-eattr.sm @@ -195,6 +195,18 @@ static PINT_sm_action deleattr_cleanup( return(server_state_machine_complete(smcb)); } +PINT_GET_OBJECT_REF_DEFINE(deleattr); + +struct PINT_server_req_params pvfs2_del_eattr_params = +{ + .string_name = "del_eattr", + .perm = PINT_SERVER_CHECK_ATTR, + .access_type = PINT_server_req_modify, + .sched_policy = PINT_SERVER_REQ_SCHEDULE, + .get_object_ref = PINT_get_object_ref_deleattr, + .state_machine = &pvfs2_del_eattr_sm +}; + /* * Local variables: * mode: c diff --git a/src/server/event-mon.sm b/src/server/event-mon.sm index 68b04cf..d8deee0 100644 --- a/src/server/event-mon.sm +++ b/src/server/event-mon.sm @@ -89,7 +89,12 @@ static PINT_sm_action event_mon_do_work( return SM_ACTION_COMPLETE; } - +struct PINT_server_req_params pvfs2_event_mon_params = +{ + .string_name = "mgmt_event_mon", + .perm = PINT_SERVER_CHECK_NONE, + .state_machine = &pvfs2_event_mon_sm +}; /* * Local variables: diff --git a/src/server/final-response.sm b/src/server/final-response.sm index 2cfd65a..7f7a1af 100644 --- a/src/server/final-response.sm +++ b/src/server/final-response.sm @@ -162,57 +162,10 @@ static PINT_sm_action final_response_cleanup( PINT_encode_release(&s_op->encoded, PINT_ENCODE_RESP); - /* decrement reference count for this bmi address */ - BMI_set_info(s_op->addr, BMI_DEC_ADDR_REF, NULL); - js_p->error_code = 0; return SM_ACTION_COMPLETE; } - -static const struct { - enum PVFS_server_op type; - const char *type_str; -} s_req_resp_type_map[] = { - { PVFS_SERV_INVALID, "PVFS_SERV_INVALID"}, - { PVFS_SERV_CREATE, "PVFS_SERV_CREATE" }, - { PVFS_SERV_REMOVE, "PVFS_SERV_REMOVE" }, - { PVFS_SERV_IO, "PVFS_SERV_IO" }, - { PVFS_SERV_GETATTR, "PVFS_SERV_GETATTR" }, - { PVFS_SERV_SETATTR, "PVFS_SERV_SETATTR" }, - { PVFS_SERV_LOOKUP_PATH, "PVFS_SERV_LOOKUP_PATH" }, - { PVFS_SERV_CRDIRENT, "PVFS_SERV_CRDIRENT" }, - { PVFS_SERV_RMDIRENT, "PVFS_SERV_RMDIRENT" }, - { PVFS_SERV_CHDIRENT, "PVFS_SERV_CHDIRENT" }, - { PVFS_SERV_TRUNCATE, "PVFS_SERV_TRUNCATE" }, - { PVFS_SERV_MKDIR, "PVFS_SERV_MKDIR" }, - { PVFS_SERV_READDIR, "PVFS_SERV_READDIR" }, - { PVFS_SERV_GETCONFIG, "PVFS_SERV_GETCONFIG" }, - { PVFS_SERV_WRITE_COMPLETION, "PVFS_SERV_WRITE_COMPLETION" }, - { PVFS_SERV_FLUSH, "PVFS_SERV_FLUSH" }, - { PVFS_SERV_LISTATTR, "PVFS_SERV_LISTATTR" }, - { PVFS_SERV_MGMT_SETPARAM, "PVFS_SERV_MGMT_SETPARAM" }, - { PVFS_SERV_MGMT_NOOP, "PVFS_SERV_MGMT_NOOP" }, - { PVFS_SERV_STATFS, "PVFS_SERV_STATFS" }, - { PVFS_SERV_PERF_UPDATE, "PVFS_SERV_PERF_UPDATE" }, - { PVFS_SERV_MGMT_PERF_MON, "PVFS_SERV_MGMT_PERF_MON" }, - { PVFS_SERV_MGMT_ITERATE_HANDLES, "PVFS_SERV_MGMT_ITERATE_HANDLES" }, - { PVFS_SERV_MGMT_DSPACE_INFO_LIST, - "PVFS_SERV_MGMT_DSPACE_INFO_LIST" }, - { PVFS_SERV_MGMT_EVENT_MON, "PVFS_SERV_MGMT_EVENT_MON" }, - { PVFS_SERV_MGMT_REMOVE_OBJECT, "PVFS_SERV_MGMT_REMOVE_OBJECT" }, - { PVFS_SERV_MGMT_REMOVE_DIRENT, "PVFS_SERV_MGMT_REMOVE_DIRENT" }, - { PVFS_SERV_MGMT_GET_DIRDATA_HANDLE, - "PVFS_SERV_MGMT_GET_DIRDATA_HANDLE" }, - { PVFS_SERV_JOB_TIMER, "PVFS_SERV_JOB_TIMER" }, - { PVFS_SERV_PROTO_ERROR, "PVFS_SERV_PROTO_ERROR" }, - { PVFS_SERV_GETEATTR, "PVFS_SERV_GETEATTR" }, - { PVFS_SERV_SETEATTR, "PVFS_SERV_SETEATTR" }, - { PVFS_SERV_DELEATTR, "PVFS_SERV_DELEATTR" }, - { PVFS_SERV_LISTEATTR, "PVFS_SERV_LISTEATTR" }, - { PVFS_SERV_SMALL_IO, "PVFS_SERV_SMALL_IO" } -}; - static void PINT_gossip_err_server_resp( struct PVFS_server_resp *resp) { @@ -221,7 +174,7 @@ static void PINT_gossip_err_server_resp( if (resp->op >= 0 && resp->op < PVFS_SERV_NUM_OPS) { gossip_err("Server Response %p is of type: %s\n", - resp, s_req_resp_type_map[resp->op].type_str); + resp, PINT_map_server_op_to_string(resp->op)); } else { diff --git a/src/server/flush.sm b/src/server/flush.sm index 22eeb7d..ceb4ab1 100644 --- a/src/server/flush.sm +++ b/src/server/flush.sm @@ -195,6 +195,18 @@ static PINT_sm_action flush_cleanup( return(server_state_machine_complete(smcb)); } +PINT_GET_OBJECT_REF_DEFINE(flush); + +struct PINT_server_req_params pvfs2_flush_params = +{ + .string_name = "flush", + .perm = PINT_SERVER_CHECK_NONE, + .access_type = PINT_server_req_modify, + .sched_policy = PINT_SERVER_REQ_SCHEDULE, + .get_object_ref = PINT_get_object_ref_flush, + .state_machine = &pvfs2_flush_sm +}; + /* * Local variables: * mode: c diff --git a/src/server/get-attr.sm b/src/server/get-attr.sm index 389c2e4..7cd7f93 100644 --- a/src/server/get-attr.sm +++ b/src/server/get-attr.sm @@ -1087,6 +1087,18 @@ static PINT_sm_action getattr_interpret_dir_hint( return SM_ACTION_COMPLETE; } +PINT_GET_OBJECT_REF_DEFINE(getattr); + +struct PINT_server_req_params pvfs2_get_attr_params = +{ + .string_name = "getattr", + .perm = PINT_SERVER_CHECK_ATTR, + .access_type = PINT_server_req_readonly, + .sched_policy = PINT_SERVER_REQ_SCHEDULE, + .get_object_ref = PINT_get_object_ref_getattr, + .state_machine = &pvfs2_get_attr_sm +}; + /* * Local variables: * mode: c diff --git a/src/server/get-config.sm b/src/server/get-config.sm index 0e96620..9d71e1a 100644 --- a/src/server/get-config.sm +++ b/src/server/get-config.sm @@ -104,6 +104,12 @@ static PINT_sm_action getconfig_cleanup( return(server_state_machine_complete(smcb)); } +struct PINT_server_req_params pvfs2_get_config_params = +{ + .string_name = "getconfig", + .perm = PINT_SERVER_CHECK_NONE, + .state_machine = &pvfs2_get_config_sm +}; /* * Local variables: diff --git a/src/server/get-eattr.sm b/src/server/get-eattr.sm index b97155f..f263346 100644 --- a/src/server/get-eattr.sm +++ b/src/server/get-eattr.sm @@ -234,6 +234,17 @@ static PINT_sm_action geteattr_cleanup( return(server_state_machine_complete(smcb)); } +PINT_GET_OBJECT_REF_DEFINE(geteattr); + +struct PINT_server_req_params pvfs2_get_eattr_params = +{ + .string_name = "get_eattr", + .perm = PINT_SERVER_CHECK_ATTR, + .sched_policy = PINT_SERVER_REQ_SCHEDULE, + .get_object_ref = PINT_get_object_ref_geteattr, + .state_machine = &pvfs2_get_eattr_sm +}; + /* * Local variables: * mode: c diff --git a/src/server/io.sm b/src/server/io.sm index 7d6d5cd..c82d19f 100644 --- a/src/server/io.sm +++ b/src/server/io.sm @@ -306,13 +306,6 @@ static PINT_sm_action io_cleanup( PINT_encode_release(&s_op->encoded, PINT_ENCODE_RESP); } - /* NOTE: this would happen in final_response nested state machine - * for most operations, but io.sm is the one state machine which - * does not use final_response -- decrement reference count for - * this bmi address - */ - BMI_set_info(s_op->addr, BMI_DEC_ADDR_REF, NULL); - return(server_state_machine_complete(smcb)); } @@ -386,6 +379,28 @@ static PINT_sm_action io_send_completion_ack( return err; } +static inline int PINT_server_req_access_io( + struct PVFS_server_req *req) +{ + if(req->u.io.io_type == PVFS_IO_READ) + { + return 1; + } + return 0; +} + +PINT_GET_OBJECT_REF_DEFINE(io); + +struct PINT_server_req_params pvfs2_io_params = +{ + .string_name = "io", + .perm = PINT_SERVER_CHECK_NONE, + .access_type = PINT_server_req_access_io, + .sched_policy = PINT_SERVER_REQ_SCHEDULE, + .get_object_ref = PINT_get_object_ref_io, + .state_machine = &pvfs2_io_sm +}; + /* * Local variables: * mode: c diff --git a/src/server/iterate-handles.sm b/src/server/iterate-handles.sm index ffd6ae0..257abcb 100644 --- a/src/server/iterate-handles.sm +++ b/src/server/iterate-handles.sm @@ -129,6 +129,22 @@ static PINT_sm_action iterate_handles_fill_resp( return SM_ACTION_COMPLETE; } +static inline int PINT_get_object_ref_iterate_handles( + struct PVFS_server_req *req, PVFS_fs_id *fs_id, PVFS_handle *handle) +{ + *fs_id = req->u.mgmt_iterate_handles.fs_id; + *handle = PVFS_HANDLE_NULL; + return 0; +} + +struct PINT_server_req_params pvfs2_iterate_handles_params = +{ + .string_name = "mgmt_iterate_handles", + .perm = PINT_SERVER_CHECK_NONE, + .get_object_ref = PINT_get_object_ref_iterate_handles, + .state_machine = &pvfs2_iterate_handles_sm +}; + /* * Local variables: * mode: c diff --git a/src/server/job-timer.sm b/src/server/job-timer.sm index 304fa1d..74530e3 100644 --- a/src/server/job-timer.sm +++ b/src/server/job-timer.sm @@ -80,6 +80,13 @@ static PINT_sm_action job_timer_do_work( server_job_context)); } +struct PINT_server_req_params pvfs2_job_timer_params = +{ + .string_name = "job_timer", + .perm = PINT_SERVER_CHECK_INVALID, + .state_machine = &pvfs2_job_timer_sm +}; + diff --git a/src/server/list-attr.sm b/src/server/list-attr.sm index 0de66e0..d7c56a5 100644 --- a/src/server/list-attr.sm +++ b/src/server/list-attr.sm @@ -802,6 +802,24 @@ static PINT_sm_action listattr_interpret_dirent_count( return SM_ACTION_COMPLETE; } +static inline int PINT_get_object_ref_listattr( + struct PVFS_server_req *req, PVFS_fs_id *fs_id, PVFS_handle *handle) +{ + *fs_id = req->u.listattr.fs_id; + *handle = PVFS_HANDLE_NULL; + return 0; +}; + +struct PINT_server_req_params pvfs2_list_attr_params = +{ + .string_name = "list_attr", + .perm = PINT_SERVER_CHECK_NONE, + .access_type = PINT_server_req_readonly, + .sched_policy = PINT_SERVER_REQ_SCHEDULE, + .get_object_ref = PINT_get_object_ref_listattr, + .state_machine = &pvfs2_list_attr_sm +}; + /* * Local variables: * mode: c diff --git a/src/server/list-eattr.sm b/src/server/list-eattr.sm index 717de1d..0e58031 100644 --- a/src/server/list-eattr.sm +++ b/src/server/list-eattr.sm @@ -238,6 +238,17 @@ static PINT_sm_action listeattr_cleanup( return(server_state_machine_complete(smcb)); } +PINT_GET_OBJECT_REF_DEFINE(listeattr); + +struct PINT_server_req_params pvfs2_list_eattr_params = +{ + .string_name = "listeattr", + .perm = PINT_SERVER_CHECK_ATTR, + .sched_policy = PINT_SERVER_REQ_SCHEDULE, + .get_object_ref = PINT_get_object_ref_listeattr, + .state_machine = &pvfs2_list_eattr_sm +}; + /* * Local variables: * mode: c diff --git a/src/server/lookup.sm b/src/server/lookup.sm index ca21b68..68a24e6 100644 --- a/src/server/lookup.sm +++ b/src/server/lookup.sm @@ -146,7 +146,7 @@ static PINT_sm_action lookup_init( "(# of segments:%u)\n", s_op->req->u.lookup_path.path, s_op->req->u.lookup_path.fs_id, - llu(s_op->req->u.lookup_path.starting_handle), + llu(s_op->req->u.lookup_path.handle), s_op->req->u.lookup_path.attrmask, s_op->u.lookup.seg_ct); if ((s_op->u.lookup.seg_ct < 0) || @@ -217,7 +217,7 @@ static PINT_sm_action lookup_read_object_metadata( /* use the base handle if we haven't looked up a segment yet */ if (s_op->u.lookup.seg_nr == 0) { - handle = s_op->req->u.lookup_path.starting_handle; + handle = s_op->req->u.lookup_path.handle; ds_attr = &(s_op->u.lookup.ds_attr_array[0]); } else @@ -500,7 +500,7 @@ static PINT_sm_action lookup_read_directory_entry_handle( /* use the base handle if we haven't looked up a segment yet */ if (s_op->u.lookup.seg_nr == 0) { - handle = s_op->req->u.lookup_path.starting_handle; + handle = s_op->req->u.lookup_path.handle; } else { @@ -653,6 +653,17 @@ static PINT_sm_action lookup_cleanup( return(server_state_machine_complete(smcb)); } +PINT_GET_OBJECT_REF_DEFINE(lookup_path); + +struct PINT_server_req_params pvfs2_lookup_params = +{ + .string_name = "lookup_path", + .perm = PINT_SERVER_CHECK_NONE, + .sched_policy = PINT_SERVER_REQ_SCHEDULE, + .get_object_ref = PINT_get_object_ref_lookup_path, + .state_machine = &pvfs2_lookup_sm +}; + /* * Local variables: * mode: c diff --git a/src/server/mgmt-get-dirdata-handle.sm b/src/server/mgmt-get-dirdata-handle.sm index 80ee1a0..37bea8d 100644 --- a/src/server/mgmt-get-dirdata-handle.sm +++ b/src/server/mgmt-get-dirdata-handle.sm @@ -117,6 +117,17 @@ static PINT_sm_action mgmt_get_dirdata_handle_cleanup( return(server_state_machine_complete(smcb)); } +PINT_GET_OBJECT_REF_DEFINE(mgmt_get_dirdata_handle); + +struct PINT_server_req_params pvfs2_mgmt_get_dirdata_handle_params = +{ + .string_name = "mgmt-get-dirdata-handle", + .perm = PINT_SERVER_CHECK_NONE, + .sched_policy = PINT_SERVER_REQ_SCHEDULE, + .get_object_ref = PINT_get_object_ref_mgmt_get_dirdata_handle, + .state_machine = &pvfs2_mgmt_get_dirdata_handle_sm +}; + /* * Local variables: * mode: c diff --git a/src/server/mgmt-remove-dirent.sm b/src/server/mgmt-remove-dirent.sm index 2e313b9..227e1e1 100644 --- a/src/server/mgmt-remove-dirent.sm +++ b/src/server/mgmt-remove-dirent.sm @@ -125,6 +125,18 @@ static PINT_sm_action mgmt_remove_dirent_cleanup( return(server_state_machine_complete(smcb)); } +PINT_GET_OBJECT_REF_DEFINE(mgmt_remove_dirent); + +struct PINT_server_req_params pvfs2_mgmt_remove_dirent_params = +{ + .string_name = "mgmt-remove-dirent", + .perm = PINT_SERVER_CHECK_NONE, + .access_type = PINT_server_req_modify, + .sched_policy = PINT_SERVER_REQ_SCHEDULE, + .get_object_ref = PINT_get_object_ref_mgmt_remove_dirent, + .state_machine = &pvfs2_mgmt_remove_dirent_sm +}; + /* * Local variables: * mode: c diff --git a/src/server/mgmt-remove-object.sm b/src/server/mgmt-remove-object.sm index 63355b8..319cfb6 100644 --- a/src/server/mgmt-remove-object.sm +++ b/src/server/mgmt-remove-object.sm @@ -77,6 +77,18 @@ static PINT_sm_action mgmt_remove_cleanup( return(server_state_machine_complete(smcb)); } +PINT_GET_OBJECT_REF_DEFINE(mgmt_remove_object); + +struct PINT_server_req_params pvfs2_mgmt_remove_object_params = +{ + .string_name = "mgmt-remove-object", + .perm = PINT_SERVER_CHECK_NONE, + .access_type = PINT_server_req_modify, + .sched_policy = PINT_SERVER_REQ_SCHEDULE, + .get_object_ref = PINT_get_object_ref_mgmt_remove_object, + .state_machine = &pvfs2_mgmt_remove_object_sm +}; + /* * Local variables: * mode: c diff --git a/src/server/mkdir.sm b/src/server/mkdir.sm index ad60f4a..bc88758 100644 --- a/src/server/mkdir.sm +++ b/src/server/mkdir.sm @@ -308,6 +308,22 @@ static PINT_sm_action mkdir_prep_sm( return SM_ACTION_COMPLETE; } +static inline int PINT_get_object_ref_mkdir( + struct PVFS_server_req *req, PVFS_fs_id *fs_id, PVFS_handle *handle) +{ + *fs_id = req->u.mkdir.fs_id; + *handle = PVFS_HANDLE_NULL; + return 0; +}; + +struct PINT_server_req_params pvfs2_mkdir_params = +{ + .string_name = "mkdir", + .perm = PINT_SERVER_CHECK_NONE, + .access_type = PINT_server_req_modify, + .state_machine = &pvfs2_mkdir_sm +}; + /* * Local variables: * mode: c diff --git a/src/server/module.mk.in b/src/server/module.mk.in index 8ad7c36..6998c75 100644 --- a/src/server/module.mk.in +++ b/src/server/module.mk.in @@ -53,8 +53,8 @@ ifdef BUILD_SERVER SMCGEN += $(SERVER_SMCGEN) # server code that will be linked manually, not included in library - MISCSRC += \ - $(DIR)/pvfs2-server.c + SERVERBINSRC += \ + $(DIR)/pvfs2-server.c $(DIR)/pvfs2-server-req.c # to stat the fs, need to know about handle statistics MODCFLAGS_$(DIR)/statfs.c = \ diff --git a/src/server/noop.sm b/src/server/noop.sm index 1618f15..40fe26e 100644 --- a/src/server/noop.sm +++ b/src/server/noop.sm @@ -48,6 +48,13 @@ static PINT_sm_action noop_cleanup( return(server_state_machine_complete(smcb)); } +struct PINT_server_req_params pvfs2_noop_params = +{ + .string_name = "noop", + .perm = PINT_SERVER_CHECK_NONE, + .access_type = PINT_server_req_readonly, + .state_machine = &pvfs2_noop_sm +}; /* * Local variables: diff --git a/src/server/perf-mon.sm b/src/server/perf-mon.sm index 9402044..1c8c0a8 100644 --- a/src/server/perf-mon.sm +++ b/src/server/perf-mon.sm @@ -312,6 +312,13 @@ static int reallocate_static_arrays_if_needed(void) return(0); } +struct PINT_server_req_params pvfs2_perf_mon_params = +{ + .string_name = "mgmt_perf_mon", + .perm = PINT_SERVER_CHECK_NONE, + .state_machine = &pvfs2_perf_mon_sm +}; + /* * Local variables: * mode: c diff --git a/src/server/perf-update.sm b/src/server/perf-update.sm index 007fca8..3aa015c 100644 --- a/src/server/perf-update.sm +++ b/src/server/perf-update.sm @@ -100,6 +100,12 @@ static PINT_sm_action perf_update_do_work( server_job_context)); } +struct PINT_server_req_params pvfs2_perf_update_params = +{ + .string_name = "perf_update", + .state_machine = &pvfs2_perf_update_sm +}; + diff --git a/src/server/prelude.sm b/src/server/prelude.sm index 143f574..b6662b6 100644 --- a/src/server/prelude.sm +++ b/src/server/prelude.sm @@ -29,7 +29,7 @@ enum { %% -nested machine pvfs2_prelude_sm +nested machine pvfs2_prelude_work_sm { state req_sched { @@ -64,8 +64,37 @@ nested machine pvfs2_prelude_sm } } +nested machine pvfs2_prelude_sm +{ + state setup + { + run prelude_setup; + default => prelude_work; + } + + state prelude_work + { + jump pvfs2_prelude_work_sm; + default => return; + } +} + %% +static PINT_sm_action prelude_setup( + struct PINT_smcb *smcb, job_status_s *js_p) +{ + int ret; + struct PINT_server_op *s_op = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); + + ret = PINT_server_req_get_object_ref( + s_op->req, &s_op->target_fs_id, &s_op->target_handle); + s_op->access_type = PINT_server_req_get_access_type(s_op->req); + s_op->sched_policy = PINT_server_req_get_sched_policy(s_op->req); + + return SM_ACTION_COMPLETE; +} + /* prelude_req_sched() * * posts a request scheduler job @@ -82,23 +111,9 @@ static PINT_sm_action prelude_req_sched( PINT_ACCESS_DEBUG(s_op, GOSSIP_ACCESS_DETAIL_DEBUG, "request\n"); - /* this is the first state for every normal pvfs2 server state - * machine, so we get to do some housekeeping here. In - * particular, bump up the reference count on the bmi address that - * we are using - */ - BMI_set_info(s_op->addr, BMI_INC_ADDR_REF, NULL); - - /* this is a bit of a hack; if we are changing server mode we must - * preserve the old mode value before calling req scheduler - */ - if ((s_op->op == PVFS_SERV_MGMT_SETPARAM) && - (s_op->req->u.mgmt_setparam.param == PVFS_SERV_PARAM_MODE)) - { - s_op->resp.u.mgmt_setparam.old_value = PINT_req_sched_get_mode(); - } - - ret = job_req_sched_post(s_op->req, 0, smcb, 0, js_p, + ret = job_req_sched_post(s_op->op, s_op->target_fs_id, s_op->target_handle, + s_op->access_type, s_op->sched_policy, + smcb, 0, js_p, &(s_op->scheduled_id), server_job_context); PINT_perf_count(PINT_server_pc, PINT_PERF_REQSCHED, 1, PINT_PERF_ADD); @@ -114,7 +129,7 @@ static PINT_sm_action prelude_getattr_if_needed( struct PINT_smcb *smcb, job_status_s *js_p) { struct PINT_server_op *s_op = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); - int ret = -PVFS_EINVAL, readonly_flag = 0; + int ret = -PVFS_EINVAL; job_id_t tmp_id; PINT_ACCESS_DEBUG(s_op, GOSSIP_ACCESS_DETAIL_DEBUG, "start\n"); @@ -123,23 +138,6 @@ static PINT_sm_action prelude_getattr_if_needed( "(%p) %s (prelude sm) state: getattr_if_needed\n", s_op, PINT_map_server_op_to_string(s_op->req->op)); - /* first, run a request scheduler utility function that tells us - * what handle this request will operate on - */ - ret = PINT_req_sched_target_handle( - s_op->req, 0, &s_op->target_handle, - &s_op->target_fs_id, &readonly_flag); - - if (ret < 0) - { - gossip_debug(GOSSIP_SERVER_DEBUG, "PINT_req_sched_target_handle " - "returned %d ret, skipping getattr on handle %llu\n", - ret, llu(s_op->target_handle)); - - js_p->error_code = ret; - return SM_ACTION_COMPLETE; - } - /* if the handle is 0, that indicates that the request does not * operate on a specific handle, so there is nothing we can do * here @@ -165,137 +163,6 @@ static PINT_sm_action prelude_getattr_if_needed( return ret; } -static void get_fs_intent(struct PVFS_server_req *req, PVFS_fs_id *fsid, int *read_only) -{ - if (req == NULL) - { - *fsid = PVFS_FS_ID_NULL; - *read_only = -1; - return; - } - switch (req->op) - { - case PVFS_SERV_CREATE: - *fsid = req->u.create.fs_id; - *read_only = 0; - break; - case PVFS_SERV_REMOVE: - *fsid = req->u.remove.fs_id; - *read_only = 0; - break; - case PVFS_SERV_IO: - *fsid = req->u.io.fs_id; - *read_only = (req->u.io.io_type == PVFS_IO_READ) ? 1 : 0; - break; - case PVFS_SERV_SMALL_IO: - *fsid = req->u.small_io.fs_id; - *read_only = (req->u.small_io.io_type == PVFS_IO_READ) ? 1 : 0; - break; - case PVFS_SERV_GETATTR: - *fsid = req->u.getattr.fs_id; - *read_only = 1; - break; - case PVFS_SERV_LISTATTR: - *fsid = req->u.listattr.fs_id; - *read_only = 1; - break; - case PVFS_SERV_SETATTR: - *fsid = req->u.setattr.fs_id; - *read_only = 0; - break; - case PVFS_SERV_LOOKUP_PATH: - *fsid = req->u.lookup_path.fs_id; - *read_only = 1; - break; - case PVFS_SERV_CRDIRENT: - *fsid = req->u.crdirent.fs_id; - *read_only = 0; - break; - case PVFS_SERV_RMDIRENT: - *fsid = req->u.rmdirent.fs_id; - *read_only = 0; - break; - case PVFS_SERV_CHDIRENT: - *fsid = req->u.chdirent.fs_id; - *read_only = 0; - break; - case PVFS_SERV_TRUNCATE: - *fsid = req->u.truncate.fs_id; - *read_only = 0; - break; - case PVFS_SERV_MKDIR: - *fsid = req->u.mkdir.fs_id; - *read_only = 0; - break; - case PVFS_SERV_READDIR: - *fsid = req->u.readdir.fs_id; - *read_only = 1; - break; - case PVFS_SERV_FLUSH: - *fsid = req->u.flush.fs_id; - *read_only = 0; - break; - case PVFS_SERV_MGMT_SETPARAM: - *fsid = req->u.mgmt_setparam.fs_id; - *read_only = 0; - break; - case PVFS_SERV_STATFS: - *fsid = req->u.statfs.fs_id; - *read_only = 1; - break; - case PVFS_SERV_MGMT_ITERATE_HANDLES: - *fsid = req->u.mgmt_iterate_handles.fs_id; - *read_only = 1; - break; - case PVFS_SERV_MGMT_DSPACE_INFO_LIST: - *fsid = req->u.mgmt_dspace_info_list.fs_id; - *read_only = 1; - break; - case PVFS_SERV_MGMT_REMOVE_OBJECT: - *fsid = req->u.mgmt_remove_object.fs_id; - *read_only = 0; - break; - case PVFS_SERV_MGMT_REMOVE_DIRENT: - *fsid = req->u.mgmt_remove_dirent.fs_id; - *read_only = 0; - break; - case PVFS_SERV_MGMT_GET_DIRDATA_HANDLE: - *fsid = req->u.mgmt_get_dirdata_handle.fs_id; - *read_only = 0; - break; - case PVFS_SERV_GETEATTR: - *fsid = req->u.geteattr.fs_id; - *read_only = 1; - break; - case PVFS_SERV_SETEATTR: - *fsid = req->u.seteattr.fs_id; - *read_only = 0; - break; - case PVFS_SERV_DELEATTR: - *fsid = req->u.deleattr.fs_id; - *read_only = 0; - break; - case PVFS_SERV_LISTEATTR: - *fsid = req->u.listeattr.fs_id; - *read_only = 1; - break; - case PVFS_SERV_PROTO_ERROR: - case PVFS_SERV_JOB_TIMER: - case PVFS_SERV_MGMT_EVENT_MON: - case PVFS_SERV_MGMT_PERF_MON: - case PVFS_SERV_PERF_UPDATE: - case PVFS_SERV_MGMT_NOOP: - case PVFS_SERV_WRITE_COMPLETION: - case PVFS_SERV_GETCONFIG: - case PVFS_SERV_NUM_OPS: - case PVFS_SERV_INVALID: - *fsid = PVFS_FS_ID_NULL; - *read_only = -1; - break; - } - return; -} - static void get_anon_ids(struct filesystem_configuration_s *fsconfig, PVFS_uid *uid, PVFS_gid *gid) { @@ -473,7 +340,6 @@ static PINT_sm_action prelude_perm_check( PVFS_uid translated_uid = s_op->req->credentials.uid; PVFS_gid translated_gid = s_op->req->credentials.gid; PVFS_fs_id fsid = PVFS_FS_ID_NULL; - int rdonly = -1; int squashed_flag = 0; int skip_acl_flag = 0; @@ -492,34 +358,14 @@ static PINT_sm_action prelude_perm_check( /* Set the target object attribute pointer.. used later by the acl check */ s_op->target_object_attr = obj_attr; - /* Commenting out the below block for now. I think this code is - * deprecated? Even if not all of the attributes have been filled in - * yet, we should still be able to read them after the object has been - * created. If this change seems stable then we need to also come back - * and remove the PINT_SERVER_ATTRIBS_NOT_REQUIRED flag. -Phil 4-13-2006 - */ -#if 0 - /* the next thing we need to do is interpret the error code from - * reading the attributes. Normally it is an error if that step - * failed, but we have to look for the special case in which we - * set attributes on a file that did not have attributes - * previously. - */ - if (PINT_server_req_table[s_op->req->op].attrib_flags == - PINT_SERVER_ATTRIBS_NOT_REQUIRED) - { - js_p->error_code = 0; - } -#endif - - get_fs_intent(s_op->req, &fsid, &rdonly); - if (fsid != PVFS_FS_ID_NULL) + if (s_op->target_fs_id != PVFS_FS_ID_NULL) { /* * if we are exporting a volume readonly, disallow any operation that modifies * the state of the file-system. */ - if (permit_operation(fsid, rdonly, s_op->addr) < 0) + if (permit_operation( + s_op->target_fs_id, s_op->access_type, s_op->addr) < 0) { js_p->error_code = -PVFS_EROFS; return SM_ACTION_COMPLETE; @@ -566,7 +412,7 @@ static PINT_sm_action prelude_perm_check( ((s_op->attr.mask & PVFS_ATTR_COMMON_GID) ? "yes" : "no"), s_op->attr.group, translated_gid); - switch(PINT_server_req_table[s_op->req->op].perm) + switch(PINT_server_req_get_perms(s_op->req)) { case PINT_SERVER_CHECK_WRITE: js_p->error_code = PINT_check_mode( @@ -633,7 +479,9 @@ static PINT_sm_action prelude_perm_check( } break; case PINT_SERVER_CHECK_NONE: - if(squashed_flag && !rdonly && ((s_op->req->op == PVFS_SERV_IO) || + if(squashed_flag && + !PINT_server_req_get_access_type(s_op->req) && + ((s_op->req->op == PVFS_SERV_IO) || (s_op->req->op == PVFS_SERV_SMALL_IO) || (s_op->req->op == PVFS_SERV_TRUNCATE))) { @@ -754,7 +602,7 @@ static PINT_sm_action prelude_check_acls( js_p->error_code = -PVFS_EINVAL; goto cleanup; } - switch (PINT_server_req_table[s_op->req->op].perm) + switch (PINT_server_req_get_perms(s_op->req)) { case PINT_SERVER_CHECK_WRITE: default: diff --git a/src/server/proto-error.sm b/src/server/proto-error.sm index ecdc674..390f50f 100644 --- a/src/server/proto-error.sm +++ b/src/server/proto-error.sm @@ -95,6 +95,12 @@ static PINT_sm_action proto_error_cleanup( return(server_state_machine_complete(smcb)); } +struct PINT_server_req_params pvfs2_proto_error_params = +{ + .string_name = "proto_error", + .state_machine = &pvfs2_proto_error_sm +}; + /* * Local variables: diff --git a/src/server/pvfs2-server-req.c b/src/server/pvfs2-server-req.c new file mode 100644 index 0000000..f5051fa --- /dev/null +++ b/src/server/pvfs2-server-req.c @@ -0,0 +1,164 @@ +/* + * (C) 2001 Clemson University and The University of Chicago + * + * See COPYING in top-level directory. + */ + +#include "pvfs2-server.h" +#include + +/* server operation state machines */ +extern struct PINT_server_req_params pvfs2_get_config_params; +extern struct PINT_server_req_params pvfs2_get_attr_params; +extern struct PINT_server_req_params pvfs2_list_attr_params; +extern struct PINT_server_req_params pvfs2_set_attr_params; +extern struct PINT_server_req_params pvfs2_create_params; +extern struct PINT_server_req_params pvfs2_crdirent_params; +extern struct PINT_server_req_params pvfs2_mkdir_params; +extern struct PINT_server_req_params pvfs2_readdir_params; +extern struct PINT_server_req_params pvfs2_lookup_params; +extern struct PINT_server_req_params pvfs2_io_params; +extern struct PINT_server_req_params pvfs2_small_io_params; +extern struct PINT_server_req_params pvfs2_remove_params; +extern struct PINT_server_req_params pvfs2_mgmt_remove_object_params; +extern struct PINT_server_req_params pvfs2_mgmt_remove_dirent_params; +extern struct PINT_server_req_params pvfs2_mgmt_get_dirdata_handle_params; +extern struct PINT_server_req_params pvfs2_rmdirent_params; +extern struct PINT_server_req_params pvfs2_chdirent_params; +extern struct PINT_server_req_params pvfs2_flush_params; +extern struct PINT_server_req_params pvfs2_truncate_params; +extern struct PINT_server_req_params pvfs2_setparam_params; +extern struct PINT_server_req_params pvfs2_noop_params; +extern struct PINT_server_req_params pvfs2_unexpected_params; +extern struct PINT_server_req_params pvfs2_statfs_params; +extern struct PINT_server_req_params pvfs2_perf_update_params; +extern struct PINT_server_req_params pvfs2_job_timer_params; +extern struct PINT_server_req_params pvfs2_proto_error_params; +extern struct PINT_server_req_params pvfs2_perf_mon_params; +extern struct PINT_server_req_params pvfs2_event_mon_params; +extern struct PINT_server_req_params pvfs2_iterate_handles_params; +extern struct PINT_server_req_params pvfs2_get_eattr_params; +extern struct PINT_server_req_params pvfs2_get_eattr_list_params; +extern struct PINT_server_req_params pvfs2_set_eattr_params; +extern struct PINT_server_req_params pvfs2_set_eattr_list_params; +extern struct PINT_server_req_params pvfs2_del_eattr_params; +extern struct PINT_server_req_params pvfs2_list_eattr_params; + +/* table of incoming request types and associated parameters */ +struct PINT_server_req_entry PINT_server_req_table[] = +{ + /* 0 */ {PVFS_SERV_INVALID, NULL}, + /* 1 */ {PVFS_SERV_CREATE, &pvfs2_create_params}, + /* 2 */ {PVFS_SERV_REMOVE, &pvfs2_remove_params}, + /* 3 */ {PVFS_SERV_IO, &pvfs2_io_params}, + /* 4 */ {PVFS_SERV_GETATTR, &pvfs2_get_attr_params}, + /* 5 */ {PVFS_SERV_SETATTR, &pvfs2_set_attr_params}, + /* 6 */ {PVFS_SERV_LOOKUP_PATH, &pvfs2_lookup_params}, + /* 7 */ {PVFS_SERV_CRDIRENT, &pvfs2_crdirent_params}, + /* 8 */ {PVFS_SERV_RMDIRENT, &pvfs2_rmdirent_params}, + /* 9 */ {PVFS_SERV_CHDIRENT, &pvfs2_chdirent_params}, + /* 10 */ {PVFS_SERV_TRUNCATE, &pvfs2_truncate_params}, + /* 11 */ {PVFS_SERV_MKDIR, &pvfs2_mkdir_params}, + /* 12 */ {PVFS_SERV_READDIR, &pvfs2_readdir_params}, + /* 13 */ {PVFS_SERV_GETCONFIG, &pvfs2_get_config_params}, + /* 14 */ {PVFS_SERV_WRITE_COMPLETION, NULL}, + /* 15 */ {PVFS_SERV_FLUSH, &pvfs2_flush_params}, + /* 16 */ {PVFS_SERV_MGMT_SETPARAM, &pvfs2_setparam_params}, + /* 17 */ {PVFS_SERV_MGMT_NOOP, &pvfs2_noop_params}, + /* 18 */ {PVFS_SERV_STATFS, &pvfs2_statfs_params}, + /* 19 */ {PVFS_SERV_PERF_UPDATE, &pvfs2_perf_update_params}, + /* 20 */ {PVFS_SERV_MGMT_PERF_MON, &pvfs2_perf_mon_params}, + /* 21 */ {PVFS_SERV_MGMT_ITERATE_HANDLES, &pvfs2_iterate_handles_params}, + /* 22 */ {PVFS_SERV_MGMT_DSPACE_INFO_LIST, NULL}, + /* 23 */ {PVFS_SERV_MGMT_EVENT_MON, &pvfs2_event_mon_params}, + /* 24 */ {PVFS_SERV_MGMT_REMOVE_OBJECT, &pvfs2_mgmt_remove_object_params}, + /* 25 */ {PVFS_SERV_MGMT_REMOVE_DIRENT, &pvfs2_mgmt_remove_dirent_params}, + /* 26 */ {PVFS_SERV_MGMT_GET_DIRDATA_HANDLE, &pvfs2_mgmt_get_dirdata_handle_params}, + /* 27 */ {PVFS_SERV_JOB_TIMER, &pvfs2_job_timer_params}, + /* 28 */ {PVFS_SERV_PROTO_ERROR, &pvfs2_proto_error_params}, + /* 29 */ {PVFS_SERV_GETEATTR, &pvfs2_get_eattr_params}, + /* 30 */ {PVFS_SERV_SETEATTR, &pvfs2_set_eattr_params}, + /* 31 */ {PVFS_SERV_DELEATTR, &pvfs2_del_eattr_params}, + /* 32 */ {PVFS_SERV_LISTEATTR, &pvfs2_list_eattr_params}, + /* 33 */ {PVFS_SERV_SMALL_IO, &pvfs2_small_io_params}, + /* 34 */ {PVFS_SERV_LISTATTR, &pvfs2_list_attr_params}, +}; + +#define CHECK_OP(_op_) assert(_op_ == PINT_server_req_table[_op_].op_type) + +inline int PINT_server_req_readonly(struct PVFS_server_req *req) +{ + return 1; +} + +inline int PINT_server_req_modify(struct PVFS_server_req *req) +{ + return 0; +} + +enum PINT_server_req_permissions +PINT_server_req_get_perms(struct PVFS_server_req *req) +{ + CHECK_OP(req->op); + return PINT_server_req_table[req->op].params->perm; +} + +enum PINT_server_req_access_type +PINT_server_req_get_access_type(struct PVFS_server_req *req) +{ + CHECK_OP(req->op); + + if(!PINT_server_req_table[req->op].params->access_type) + { + return PINT_SERVER_REQ_READONLY; + } + return PINT_server_req_table[req->op].params->access_type(req); +} + +enum PINT_server_sched_policy +PINT_server_req_get_sched_policy(struct PVFS_server_req *req) +{ + CHECK_OP(req->op); + return PINT_server_req_table[req->op].params->sched_policy; +} + +int PINT_server_req_get_object_ref( + struct PVFS_server_req *req, PVFS_fs_id *fs_id, PVFS_handle *handle) +{ + CHECK_OP(req->op); + + if(!PINT_server_req_table[req->op].params->get_object_ref) + { + *fs_id = 0; + *handle = 0; + return 0; + } + else + { + return PINT_server_req_table[req->op].params->get_object_ref( + req, fs_id, handle); + } +} + +/* + * PINT_map_server_op_to_string() + * + * provides a string representation of the server operation number + * + * returns a pointer to a static string (DONT FREE IT) on success, + * null on failure + */ +const char* PINT_map_server_op_to_string(enum PVFS_server_op op) +{ + CHECK_OP(op); + return PINT_server_req_table[op].params->string_name; +} + +/* + * Local variables: + * c-indent-level: 4 + * c-basic-offset: 4 + * End: + * + * vim: ts=8 sts=4 sw=4 expandtab + */ diff --git a/src/server/pvfs2-server.c b/src/server/pvfs2-server.c index f58d86b..2ac5c3a 100644 --- a/src/server/pvfs2-server.c +++ b/src/server/pvfs2-server.c @@ -156,261 +156,11 @@ static void bt_sighandler(int sig, siginfo_t *info, void *secret); static int create_pidfile(char *pidfile); static void write_pidfile(int fd); static void remove_pidfile(void); -static int parse_port_from_host_id(char* host_id); +static int generate_shm_key_hint(void); static char *guess_alias(void); static TROVE_method_id trove_coll_to_method_callback(TROVE_coll_id); -/* table of incoming request types and associated parameters */ -struct PINT_server_req_params PINT_server_req_table[] = -{ - /* 0 */ - {PVFS_SERV_INVALID, - "invalid", - PINT_SERVER_CHECK_INVALID, - PINT_SERVER_ATTRIBS_REQUIRED, - NULL}, - - /* 1 */ - {PVFS_SERV_CREATE, - "create", - PINT_SERVER_CHECK_NONE, - PINT_SERVER_ATTRIBS_REQUIRED, - &pvfs2_create_sm}, - - /* 2 */ - {PVFS_SERV_REMOVE, - "remove", - PINT_SERVER_CHECK_NONE, - PINT_SERVER_ATTRIBS_NOT_REQUIRED, - &pvfs2_remove_sm}, - - /* 3 */ - {PVFS_SERV_IO, - "io", - PINT_SERVER_CHECK_NONE, - PINT_SERVER_ATTRIBS_NOT_REQUIRED, - &pvfs2_io_sm}, - - /* 4 */ - {PVFS_SERV_GETATTR, - "getattr", - PINT_SERVER_CHECK_ATTR, - PINT_SERVER_ATTRIBS_NOT_REQUIRED, - &pvfs2_get_attr_sm}, - - /* 5 */ - {PVFS_SERV_SETATTR, - "setattr", - PINT_SERVER_CHECK_ATTR, - PINT_SERVER_ATTRIBS_NOT_REQUIRED, - &pvfs2_set_attr_sm}, - - /* 6 */ - {PVFS_SERV_LOOKUP_PATH, - "lookup_path", - PINT_SERVER_CHECK_NONE, - PINT_SERVER_ATTRIBS_REQUIRED, - &pvfs2_lookup_sm}, - - /* 7 */ - {PVFS_SERV_CRDIRENT, - "crdirent", - PINT_SERVER_CHECK_CRDIRENT, - PINT_SERVER_ATTRIBS_REQUIRED, - &pvfs2_crdirent_sm}, - - /* 8 */ - {PVFS_SERV_RMDIRENT, - "rmdirent", - PINT_SERVER_CHECK_WRITE, - PINT_SERVER_ATTRIBS_REQUIRED, - &pvfs2_rmdirent_sm}, - - /* 9 */ - {PVFS_SERV_CHDIRENT, - "chdirent", - PINT_SERVER_CHECK_WRITE, - PINT_SERVER_ATTRIBS_REQUIRED, - &pvfs2_chdirent_sm}, - - /* 10 */ - {PVFS_SERV_TRUNCATE, - "truncate", - PINT_SERVER_CHECK_NONE, - PINT_SERVER_ATTRIBS_NOT_REQUIRED, - &pvfs2_truncate_sm}, - - /* 11 */ - {PVFS_SERV_MKDIR, - "mkdir", - PINT_SERVER_CHECK_NONE, - PINT_SERVER_ATTRIBS_REQUIRED, - &pvfs2_mkdir_sm}, - - - /* 12 */ - {PVFS_SERV_READDIR, - "readdir", - PINT_SERVER_CHECK_READ, - PINT_SERVER_ATTRIBS_REQUIRED, - &pvfs2_readdir_sm}, - - /* 13 */ - {PVFS_SERV_GETCONFIG, - "getconfig", - PINT_SERVER_CHECK_NONE, - PINT_SERVER_ATTRIBS_REQUIRED, - &pvfs2_get_config_sm}, - - /* 14 */ - {PVFS_SERV_WRITE_COMPLETION, - "write_completion", - PINT_SERVER_CHECK_INVALID, - PINT_SERVER_ATTRIBS_REQUIRED, - NULL}, - - /* 15 */ - {PVFS_SERV_FLUSH, - "flush", - PINT_SERVER_CHECK_NONE, - PINT_SERVER_ATTRIBS_NOT_REQUIRED, - &pvfs2_flush_sm}, - - /* 16 */ - {PVFS_SERV_MGMT_SETPARAM, - "mgmt_setparam", - PINT_SERVER_CHECK_NONE, - PINT_SERVER_ATTRIBS_REQUIRED, - &pvfs2_setparam_sm}, - - /* 17 */ - {PVFS_SERV_MGMT_NOOP, - "mgmt_noop", - PINT_SERVER_CHECK_NONE, - PINT_SERVER_ATTRIBS_REQUIRED, - &pvfs2_noop_sm}, - - /* 18 */ - {PVFS_SERV_STATFS, - "statfs", - PINT_SERVER_CHECK_NONE, - PINT_SERVER_ATTRIBS_REQUIRED, - &pvfs2_statfs_sm}, - - /* 19 */ - {PVFS_SERV_PERF_UPDATE, - "perf_update", - PINT_SERVER_CHECK_INVALID, - PINT_SERVER_ATTRIBS_REQUIRED, - &pvfs2_perf_update_sm}, - - /* 20 */ - {PVFS_SERV_MGMT_PERF_MON, - "mgmt_perf_mon", - PINT_SERVER_CHECK_NONE, - PINT_SERVER_ATTRIBS_REQUIRED, - &pvfs2_perf_mon_sm}, - - /* 21 */ - {PVFS_SERV_MGMT_ITERATE_HANDLES, - "mgmt_iterate_handles", - PINT_SERVER_CHECK_NONE, - PINT_SERVER_ATTRIBS_REQUIRED, - &pvfs2_iterate_handles_sm}, - - /* 22 */ - {PVFS_SERV_MGMT_DSPACE_INFO_LIST, - "mgmt_dspace_info_list", - PINT_SERVER_CHECK_NONE, - PINT_SERVER_ATTRIBS_REQUIRED, - NULL}, - - /* 23 */ - {PVFS_SERV_MGMT_EVENT_MON, - "mgmt_event_mon", - PINT_SERVER_CHECK_NONE, - PINT_SERVER_ATTRIBS_REQUIRED, - &pvfs2_event_mon_sm}, - - /* 24 */ - {PVFS_SERV_MGMT_REMOVE_OBJECT, - "mgmt-remove-object", - PINT_SERVER_CHECK_NONE, - PINT_SERVER_ATTRIBS_NOT_REQUIRED, - &pvfs2_mgmt_remove_object_sm}, - - /* 25 */ - {PVFS_SERV_MGMT_REMOVE_DIRENT, - "mgmt-remove-dirent", - PINT_SERVER_CHECK_NONE, - PINT_SERVER_ATTRIBS_NOT_REQUIRED, - &pvfs2_mgmt_remove_dirent_sm}, - - /* 26 */ - {PVFS_SERV_MGMT_GET_DIRDATA_HANDLE, - "mgmt-get-dirdata-handle", - PINT_SERVER_CHECK_NONE, - PINT_SERVER_ATTRIBS_NOT_REQUIRED, - &pvfs2_mgmt_get_dirdata_handle_sm}, - - /* 27 */ - {PVFS_SERV_JOB_TIMER, - "job_timer", - PINT_SERVER_CHECK_INVALID, - PINT_SERVER_ATTRIBS_REQUIRED, - &pvfs2_job_timer_sm}, - - /* 28 */ - {PVFS_SERV_PROTO_ERROR, - "proto_error", - PINT_SERVER_CHECK_INVALID, - PINT_SERVER_ATTRIBS_REQUIRED, - &pvfs2_proto_error_sm}, - - /* 29 */ - {PVFS_SERV_GETEATTR, - "geteattr", - PINT_SERVER_CHECK_ATTR, - PINT_SERVER_ATTRIBS_NOT_REQUIRED, - &pvfs2_get_eattr_sm}, - - /* 30 */ - {PVFS_SERV_SETEATTR, - "seteattr", - PINT_SERVER_CHECK_ATTR, - PINT_SERVER_ATTRIBS_NOT_REQUIRED, - &pvfs2_set_eattr_sm}, - - /* 31 */ - {PVFS_SERV_DELEATTR, - "deleattr", - PINT_SERVER_CHECK_ATTR, - PINT_SERVER_ATTRIBS_NOT_REQUIRED, - &pvfs2_del_eattr_sm}, - - /* 32 */ - {PVFS_SERV_LISTEATTR, - "listeattr", - PINT_SERVER_CHECK_ATTR, - PINT_SERVER_ATTRIBS_NOT_REQUIRED, - &pvfs2_list_eattr_sm}, - - /* 33 */ - {PVFS_SERV_SMALL_IO, - "small_io", - PINT_SERVER_CHECK_NONE, - PINT_SERVER_ATTRIBS_NOT_REQUIRED, - &pvfs2_small_io_sm}, - - /* 34 */ - {PVFS_SERV_LISTATTR, - "listattr", - PINT_SERVER_CHECK_NONE, - PINT_SERVER_ATTRIBS_NOT_REQUIRED, - &pvfs2_list_attr_sm}, -}; - struct server_configuration_s *PINT_get_server_config(void) { return &server_config; @@ -906,8 +656,8 @@ static int server_initialize_subsystems( char buf[16] = {0}; PVFS_fs_id orig_fsid; PVFS_ds_flags init_flags = 0; - int port_num = 0; int bmi_flags = BMI_INIT_SERVER; + int shm_key_hint; /* Initialize distributions */ ret = PINT_dist_initialize(0); @@ -964,15 +714,11 @@ static int server_initialize_subsystems( /* this should never fail */ assert(ret == 0); - /* parse port number and allow trove to use it to help differentiate - * shmem regions if needed - */ - port_num = parse_port_from_host_id(server_config.host_id); - if(port_num > 0) - { - ret = trove_collection_setinfo(0, 0, TROVE_SHM_KEY_HINT, &port_num); - assert(ret == 0); - } + /* help trove chose a differentiating shm key if needed for Berkeley DB */ + shm_key_hint = generate_shm_key_hint(); + gossip_debug(GOSSIP_SERVER_DEBUG, "Server using shm key hint: %d\n", shm_key_hint); + ret = trove_collection_setinfo(0, 0, TROVE_SHM_KEY_HINT, &shm_key_hint); + assert(ret == 0); if(server_config.db_cache_type && (!strcmp(server_config.db_cache_type, "mmap"))) @@ -1038,7 +784,7 @@ static int server_initialize_subsystems( break; } - ret = PINT_handle_load_mapping(&server_config, cur_fs); + ret = PINT_cached_config_handle_load_mapping(cur_fs); if(ret) { PVFS_perror("Error: PINT_handle_load_mapping", ret); @@ -1992,7 +1738,7 @@ int server_state_machine_complete(PINT_smcb *smcb) gossip_debug(GOSSIP_SERVER_DEBUG, "server_state_machine_complete %p\n",smcb); - + /* set a timestamp on the completion of the state machine */ id_gen_fast_register(&tmp_id, s_op); PINT_event_timestamp(PVFS_EVENT_API_SM, (int32_t)s_op->req->op, @@ -2004,10 +1750,12 @@ int server_state_machine_complete(PINT_smcb *smcb) PINT_decode_release(&(s_op->decoded),PINT_DECODE_REQ); } + BMI_set_info(s_op->unexp_bmi_buff.addr, BMI_DEC_ADDR_REF, NULL); BMI_unexpected_free(s_op->unexp_bmi_buff.addr, s_op->unexp_bmi_buff.buffer); s_op->unexp_bmi_buff.buffer = NULL; + /* Remove s_op from the inprogress_sop_list */ qlist_del(&s_op->next); @@ -2029,37 +1777,6 @@ struct server_configuration_s *get_server_config_struct(void) return &server_config; } -/* parse_port_from_host_id() - * - * attempts to parse the port number from a BMI address. Returns port number - * on success, -1 on failure - */ -static int parse_port_from_host_id(char* host_id) -{ - int ret = -1; - int port_num; - char* port_index; - char* colon_index; - - /* see if we have a ://: format */ - port_index = rindex(host_id, ':'); - colon_index = index(host_id, ':'); - /* if so, parse the port number */ - if(port_index && (port_index != colon_index)) - { - port_index++; - ret = sscanf(port_index, "%d", &port_num); - } - - /* report error if we don't find a valid port number in the string */ - if(ret != 1) - { - return(-1); - } - - return(port_num); -} - /* server_op_get_machine() * * looks up the state machine for the op * given and returns it, or @@ -2082,7 +1799,7 @@ struct PINT_state_machine_s *server_op_state_get_machine(int op) default : { if (op >= 0 && op < PVFS_SERV_NUM_OPS) - return PINT_server_req_table[op].sm; + return PINT_server_req_table[op].params->state_machine; else return NULL; break; @@ -2108,9 +1825,6 @@ void PINT_server_access_debug(PINT_server_op * s_op, const char * format, ...) { - PVFS_handle handle; - PVFS_fs_id fsid; - int flag; static char pint_access_buffer[GOSSIP_BUF_SIZE]; struct passwd* pw; struct group* gr; @@ -2122,7 +1836,6 @@ void PINT_server_access_debug(PINT_server_op * s_op, { va_start(ap, format); - PINT_req_sched_target_handle(s_op->req, 0, &handle, &fsid, &flag); pw = getpwuid(s_op->req->credentials.uid); gr = getgrgid(s_op->req->credentials.gid); snprintf(pint_access_buffer, GOSSIP_BUF_SIZE, @@ -2130,7 +1843,7 @@ void PINT_server_access_debug(PINT_server_op * s_op, ((pw) ? pw->pw_name : "UNKNOWN"), ((gr) ? gr->gr_name : "UNKNOWN"), BMI_addr_rev_lookup_unexpected(s_op->addr), - llu(handle), + llu(s_op->target_handle), s_op, PINT_map_server_op_to_string(s_op->req->op), format); @@ -2142,23 +1855,6 @@ void PINT_server_access_debug(PINT_server_op * s_op, } #endif -/* - * PINT_map_server_op_to_string() - * - * provides a string representation of the server operation number - * - * returns a pointer to a static string (DONT FREE IT) on success, - * null on failure - */ -const char* PINT_map_server_op_to_string(enum PVFS_server_op op) -{ - const char *s = NULL; - - if (op >= 0 && op < PVFS_SERV_NUM_OPS) - s = PINT_server_req_table[op].string_name; - return s; -} - static char *guess_alias(void) { char tmp_alias[1024]; @@ -2187,6 +1883,50 @@ static char *guess_alias(void) return strdup(tmp_alias); } +/* generate_shm_key_hint() + * + * Makes a best effort to produce a unique shm key (for Trove's Berkeley + * DB use) for each server. By default it will base this on the server's + * position in the fs.conf, but it will fall back to using a random number + * + * returns integer key + */ +static int generate_shm_key_hint(void) +{ + int server_index = 1; + struct host_alias_s *cur_alias = NULL; + + PINT_llist *cur = server_config.host_aliases; + + /* iterate through list of aliases in configuration file */ + while(cur) + { + cur_alias = PINT_llist_head(cur); + if(!cur_alias) + { + break; + } + if(strcmp(cur_alias->bmi_address, server_config.host_id) == 0) + { + /* match */ + /* space the shm keys out by 10 to allow for Berkeley DB using + * using more than one key on each server + */ + return(server_index*10); + } + + server_index++; + cur = PINT_llist_next(cur); + } + + /* If we reach this point, we didn't find this server in the alias list. + * This is not a normal situation, but fall back to using a random + * number for the key just to be safe. + */ + srand((unsigned int)time(NULL)); + return(rand()); +} + /* * Local variables: * c-indent-level: 4 diff --git a/src/server/pvfs2-server.h b/src/server/pvfs2-server.h index 87a0033..9a92f9f 100644 --- a/src/server/pvfs2-server.h +++ b/src/server/pvfs2-server.h @@ -77,30 +77,86 @@ enum PINT_server_req_permissions needs write and execute */ }; -/* indicates if the attributes for the target object must exist for - * the operation to proceed (see prelude.sm) - */ -enum PINT_server_req_attrib_flags +enum PINT_server_req_access_type { - PINT_SERVER_ATTRIBS_INVALID = 0, - PINT_SERVER_ATTRIBS_REQUIRED = 1, - /* operations that operate on datafiles or on incomplete metafiles - * do not expect to necessarily find attributes present before - * starting the operation - */ - PINT_SERVER_ATTRIBS_NOT_REQUIRED = 2 + PINT_SERVER_REQ_READONLY = 0, + PINT_SERVER_REQ_MODIFY }; +enum PINT_server_sched_policy +{ + PINT_SERVER_REQ_BYPASS = 0, + PINT_SERVER_REQ_SCHEDULE +}; + +#define PINT_GET_OBJECT_REF_DEFINE(req_name) \ +static inline int PINT_get_object_ref_##req_name( \ + struct PVFS_server_req *req, PVFS_fs_id *fs_id, PVFS_handle *handle) \ +{ \ + *fs_id = req->u.req_name.fs_id; \ + *handle = req->u.req_name.handle; \ + return 0; \ +} + +typedef int (*PINT_server_req_access_callback)(struct PVFS_server_req *req); + +int PINT_server_req_readonly(struct PVFS_server_req *req); +int PINT_server_req_modify(struct PVFS_server_req *req); + struct PINT_server_req_params { - enum PVFS_server_op op_type; const char* string_name; + + /* For each request that specifies an object ref (fsid,handle) we + * get the common attributes on that object and check the permissions. + * For the request to proceed the permissions required by this flag + * must be met. + */ enum PINT_server_req_permissions perm; - enum PINT_server_req_attrib_flags attrib_flags; - struct PINT_state_machine_s* sm; + + /* Specifies the type of access on the object (readonly, modify). This + * is used by the request scheduler to determine + * which requests to queue (block), and which to schedule (proceed). + * This is a callback implemented by the request. For example, sometimes + * the io request writes, sometimes it reads. + * Default functions PINT_server_req_readonly and PINT_server_req_modify + * are used for requests that always require the same access type. + */ + PINT_server_req_access_callback access_type; + + /* Specifies the scheduling policy for the request. In some cases, + * we can bypass the request scheduler and proceed directly with the + * request. + */ + enum PINT_server_sched_policy sched_policy; + + /* A callback implemented by the request to return the object reference + * from the server request structure. + */ + int (*get_object_ref)( + struct PVFS_server_req *req, PVFS_fs_id *fs_id, PVFS_handle *handle); + + /* The state machine that performs the request */ + struct PINT_state_machine_s *state_machine; +}; + +struct PINT_server_req_entry +{ + enum PVFS_server_op op_type; + struct PINT_server_req_params *params; }; -extern struct PINT_server_req_params PINT_server_req_table[]; +extern struct PINT_server_req_entry PINT_server_req_table[]; + +int PINT_server_req_get_object_ref( + struct PVFS_server_req *req, PVFS_fs_id *fs_id, PVFS_handle *handle); + +enum PINT_server_req_permissions +PINT_server_req_get_perms(struct PVFS_server_req *req); +enum PINT_server_req_access_type +PINT_server_req_get_access_type(struct PVFS_server_req *req); +enum PINT_server_sched_policy +PINT_server_req_get_sched_policy(struct PVFS_server_req *req); const char* PINT_map_server_op_to_string(enum PVFS_server_op op); @@ -364,6 +420,9 @@ typedef struct PINT_server_op PVFS_fs_id target_fs_id; PVFS_object_attr *target_object_attr; + enum PINT_server_req_access_type access_type; + enum PINT_server_sched_policy sched_policy; + union { /* request-specific scratch spaces for use during processing */ @@ -405,51 +464,16 @@ void PINT_server_access_debug(PINT_server_op * s_op, int64_t debug_mask, const char * format, ...) __attribute__((format(printf, 3, 4))); -/* server operation state machines */ -extern struct PINT_state_machine_s pvfs2_get_config_sm; -extern struct PINT_state_machine_s pvfs2_get_attr_sm; -extern struct PINT_state_machine_s pvfs2_list_attr_sm; -extern struct PINT_state_machine_s pvfs2_set_attr_sm; -extern struct PINT_state_machine_s pvfs2_create_sm; -extern struct PINT_state_machine_s pvfs2_crdirent_sm; -extern struct PINT_state_machine_s pvfs2_mkdir_sm; -extern struct PINT_state_machine_s pvfs2_readdir_sm; -extern struct PINT_state_machine_s pvfs2_lookup_sm; -extern struct PINT_state_machine_s pvfs2_io_sm; -extern struct PINT_state_machine_s pvfs2_small_io_sm; -extern struct PINT_state_machine_s pvfs2_remove_sm; -extern struct PINT_state_machine_s pvfs2_mgmt_remove_object_sm; -extern struct PINT_state_machine_s pvfs2_mgmt_remove_dirent_sm; -extern struct PINT_state_machine_s pvfs2_mgmt_get_dirdata_handle_sm; -extern struct PINT_state_machine_s pvfs2_rmdirent_sm; -extern struct PINT_state_machine_s pvfs2_chdirent_sm; -extern struct PINT_state_machine_s pvfs2_flush_sm; -extern struct PINT_state_machine_s pvfs2_truncate_sm; -extern struct PINT_state_machine_s pvfs2_setparam_sm; -extern struct PINT_state_machine_s pvfs2_noop_sm; -extern struct PINT_state_machine_s pvfs2_unexpected_sm; -extern struct PINT_state_machine_s pvfs2_statfs_sm; -extern struct PINT_state_machine_s pvfs2_perf_update_sm; -extern struct PINT_state_machine_s pvfs2_job_timer_sm; -extern struct PINT_state_machine_s pvfs2_proto_error_sm; -extern struct PINT_state_machine_s pvfs2_perf_mon_sm; -extern struct PINT_state_machine_s pvfs2_event_mon_sm; -extern struct PINT_state_machine_s pvfs2_iterate_handles_sm; -extern struct PINT_state_machine_s pvfs2_get_eattr_sm; -extern struct PINT_state_machine_s pvfs2_get_eattr_list_sm; -extern struct PINT_state_machine_s pvfs2_set_eattr_sm; -extern struct PINT_state_machine_s pvfs2_set_eattr_list_sm; -extern struct PINT_state_machine_s pvfs2_del_eattr_sm; -extern struct PINT_state_machine_s pvfs2_list_eattr_sm; -extern struct PINT_state_machine_s pvfs2_list_eattr_list_sm; /* nested state machines */ extern struct PINT_state_machine_s pvfs2_get_attr_work_sm; extern struct PINT_state_machine_s pvfs2_prelude_sm; +extern struct PINT_state_machine_s pvfs2_prelude_work_sm; extern struct PINT_state_machine_s pvfs2_final_response_sm; extern struct PINT_state_machine_s pvfs2_check_entry_not_exist_sm; extern struct PINT_state_machine_s pvfs2_remove_work_sm; extern struct PINT_state_machine_s pvfs2_mkdir_work_sm; +extern struct PINT_state_machine_s pvfs2_unexpected_sm; /* Exported Prototypes */ struct server_configuration_s *get_server_config_struct(void); @@ -475,7 +499,7 @@ int server_state_machine_start_noreq( #define PINT_OP_STATE PINT_server_op #define PINT_OP_STATE_GET_MACHINE(_op) \ ((_op >= 0 && _op < PVFS_SERV_NUM_OPS) ? \ - PINT_server_req_table[_op].sm : NULL) + PINT_server_req_table[_op].params->sm : NULL) #endif #include "pvfs2-internal.h" diff --git a/src/server/readdir.sm b/src/server/readdir.sm index 9a4e1f8..5900703 100644 --- a/src/server/readdir.sm +++ b/src/server/readdir.sm @@ -257,6 +257,16 @@ static PINT_sm_action readdir_cleanup( return(server_state_machine_complete(smcb)); } +PINT_GET_OBJECT_REF_DEFINE(readdir); + +struct PINT_server_req_params pvfs2_readdir_params = +{ + .string_name = "readdir", + .perm = PINT_SERVER_CHECK_READ, + .get_object_ref = PINT_get_object_ref_readdir, + .state_machine = &pvfs2_readdir_sm +}; + /* * Local variables: * mode: c diff --git a/src/server/remove.sm b/src/server/remove.sm index 41d6663..0dcd8d1 100644 --- a/src/server/remove.sm +++ b/src/server/remove.sm @@ -384,6 +384,18 @@ static PINT_sm_action remove_setup_work( return SM_ACTION_COMPLETE; } +PINT_GET_OBJECT_REF_DEFINE(remove); + +struct PINT_server_req_params pvfs2_remove_params = +{ + .string_name = "remove", + .get_object_ref = PINT_get_object_ref_remove, + .perm = PINT_SERVER_CHECK_NONE, + .access_type = PINT_server_req_modify, + .sched_policy = PINT_SERVER_REQ_SCHEDULE, + .state_machine = &pvfs2_remove_sm +}; + /* * Local variables: diff --git a/src/server/request-scheduler/request-scheduler.c b/src/server/request-scheduler/request-scheduler.c index 424d4c3..e3e7cd4 100644 --- a/src/server/request-scheduler/request-scheduler.c +++ b/src/server/request-scheduler/request-scheduler.c @@ -73,8 +73,8 @@ struct req_sched_list /** linked list elements; one for each request in the scheduler */ struct req_sched_element { + enum PVFS_server_op op; struct qlist_head list_link; /* ties it to a queue */ - struct PVFS_server_req *req_ptr; /* ties it to a request */ struct qlist_head ready_link; /* ties to ready queue */ void *user_ptr; /* user pointer */ req_sched_id id; /* unique identifier */ @@ -83,6 +83,9 @@ struct req_sched_element PVFS_handle handle; struct timeval tv; /* used for timer events */ int readonly_flag; /* indicates a read only operation */ + + int mode_change; /* specifies that the element is a mode change */ + enum PVFS_server_mode mode; /* the mode to change to */ }; @@ -189,169 +192,110 @@ int PINT_req_sched_finalize( return (0); } -/** Finds the handle that the given request will operate on - * - * \return 0 on success, -errno on failure - * - * \note a handle value of 0 and a return value of 0 indicates - * that the request does not operate on any particular handle - * - * \note a return value of 1 indicates that we can let this operation pass - * through without any scheduling - * - * \todo we need to fix this function and all of its callers if we - * define something besides "0" to represent an invalid handle value - */ -int PINT_req_sched_target_handle( - struct PVFS_server_req *req, - int req_index, - PVFS_handle * handle, - PVFS_fs_id * fs_id, - int* readonly_flag) +int PINT_req_sched_change_mode(enum PVFS_server_mode mode, + void *user_ptr, + req_sched_id *id) { - *handle = 0; - *fs_id = 0; - *readonly_flag = 1; + int ret = -1; + int mode_change_ready = 0; + struct req_sched_element *mode_element; - switch (req->op) + /* create a structure to store in the request queues */ + mode_element = (struct req_sched_element *) malloc( + sizeof(struct req_sched_element)); + if (!mode_element) { - case PVFS_SERV_INVALID: - return (-EINVAL); - case PVFS_SERV_MGMT_SETPARAM: - return (1); - case PVFS_SERV_CREATE: - *readonly_flag = 0; - return (1); - case PVFS_SERV_REMOVE: - *readonly_flag = 0; - *handle = req->u.remove.handle; - *fs_id = req->u.remove.fs_id; - return (0); - case PVFS_SERV_MGMT_REMOVE_OBJECT: - *readonly_flag = 0; - *handle = req->u.mgmt_remove_object.handle; - *fs_id = req->u.mgmt_remove_object.fs_id; - return (0); - case PVFS_SERV_MGMT_REMOVE_DIRENT: - *readonly_flag = 0; - *handle = req->u.mgmt_remove_dirent.handle; - *fs_id = req->u.mgmt_remove_dirent.fs_id; - return (0); - case PVFS_SERV_IO: - if(req->u.io.io_type == PVFS_IO_WRITE) - *readonly_flag = 0; - *handle = req->u.io.handle; - *fs_id = req->u.io.fs_id; - return (0); - case PVFS_SERV_SMALL_IO: - if(req->u.small_io.io_type == PVFS_IO_WRITE) - *readonly_flag = 0; - *handle = req->u.small_io.handle; - *fs_id = req->u.small_io.fs_id; - return (0); - case PVFS_SERV_GETATTR: - *handle = req->u.getattr.handle; - *fs_id = req->u.getattr.fs_id; - return (0); - case PVFS_SERV_SETATTR: - *readonly_flag = 0; - *handle = req->u.setattr.handle; - *fs_id = req->u.setattr.fs_id; - return (0); - case PVFS_SERV_LOOKUP_PATH: - *handle = req->u.lookup_path.starting_handle; - *fs_id = req->u.lookup_path.fs_id; - return (0); - case PVFS_SERV_CRDIRENT: - *readonly_flag = 0; - *handle = req->u.crdirent.parent_handle; - *fs_id = req->u.crdirent.fs_id; - return (0); - case PVFS_SERV_RMDIRENT: - *readonly_flag = 0; - *handle = req->u.rmdirent.parent_handle; - *fs_id = req->u.rmdirent.fs_id; - return (0); - case PVFS_SERV_CHDIRENT: - *readonly_flag = 0; - *handle = req->u.chdirent.parent_handle; - *fs_id = req->u.chdirent.fs_id; - return (0); - case PVFS_SERV_TRUNCATE: - *readonly_flag = 0; - *handle = req->u.truncate.handle; - *fs_id = req->u.truncate.fs_id; - return (0); - case PVFS_SERV_MKDIR: - *readonly_flag = 0; - return (1); - case PVFS_SERV_READDIR: - *handle = req->u.readdir.handle; - *fs_id = req->u.readdir.fs_id; - return (0); - case PVFS_SERV_GETCONFIG: - return (1); - case PVFS_SERV_FLUSH: - *readonly_flag = 0; - *handle = req->u.flush.handle; - *fs_id = req->u.flush.fs_id; - return (0); - case PVFS_SERV_LISTATTR: - *readonly_flag = 1; - *fs_id = req->u.listattr.fs_id; - *handle = PVFS_HANDLE_NULL; - return 0; - case PVFS_SERV_MGMT_NOOP: - return (1); - case PVFS_SERV_MGMT_PERF_MON: - return (1); - case PVFS_SERV_MGMT_EVENT_MON: - return (1); - case PVFS_SERV_MGMT_ITERATE_HANDLES: - *fs_id = req->u.mgmt_iterate_handles.fs_id; - return (1); - case PVFS_SERV_MGMT_DSPACE_INFO_LIST: - if(req_index >= req->u.mgmt_dspace_info_list.handle_count) + return (-errno); + } + + mode_element->user_ptr = user_ptr; + id_gen_fast_register(id, mode_element); + mode_element->id = *id; + mode_element->state = REQ_QUEUED; + mode_element->mode_change = 1; + mode_element->mode = mode; + + /* will this be the front of the queue */ + if(qlist_empty(&mode_queue)) + mode_change_ready = 1; + + qlist_add_tail(&(mode_element->list_link), &mode_queue); + if(mode_change_ready) + { + if(mode == PVFS_SERVER_NORMAL_MODE) { - return(-EOVERFLOW); + /* let this go through regardless */ + ret = 1; + mode_element->state = REQ_SCHEDULED; + current_mode = mode; } - *handle = req->u.mgmt_dspace_info_list.handle_array[req_index]; - *fs_id = req->u.mgmt_dspace_info_list.fs_id; - return (0); - case PVFS_SERV_MGMT_GET_DIRDATA_HANDLE: - *handle = req->u.mgmt_get_dirdata_handle.handle; - *fs_id = req->u.mgmt_get_dirdata_handle.fs_id; - return (0); - case PVFS_SERV_GETEATTR: - *handle = req->u.geteattr.handle; - *fs_id = req->u.geteattr.fs_id; - return (0); - case PVFS_SERV_SETEATTR: - *readonly_flag = 0; - *handle = req->u.seteattr.handle; - *fs_id = req->u.seteattr.fs_id; - return (0); - case PVFS_SERV_DELEATTR: - *readonly_flag = 0; - *handle = req->u.deleattr.handle; - *fs_id = req->u.deleattr.fs_id; - return (0); - case PVFS_SERV_LISTEATTR: - *handle = req->u.listeattr.handle; - *fs_id = req->u.listeattr.fs_id; - return (0); - case PVFS_SERV_STATFS: - *fs_id = req->u.statfs.fs_id; - return (1); - case PVFS_SERV_WRITE_COMPLETION: - case PVFS_SERV_PERF_UPDATE: - case PVFS_SERV_JOB_TIMER: - case PVFS_SERV_PROTO_ERROR: - case PVFS_SERV_NUM_OPS: /* sentinel */ - /* these should never show up here */ - return (-EINVAL); + else if(mode == PVFS_SERVER_ADMIN_MODE) + { + assert(sched_count > -1); + /* for this to work, we must wait for pending ops to complete */ + if(sched_count == 0) + { + ret = 1; + mode_element->state = REQ_SCHEDULED; + current_mode = mode; + } + else + { + ret = 0; + mode_element->state = REQ_QUEUED; + } + } + else + { + /* TODO: be nicer about this */ + assert(0); + } + return(ret); + } + else + { + mode_element->state = REQ_QUEUED; + return(0); + } +} + +static int PINT_req_sched_in_admin_mode(void) +{ + struct req_sched_element *mode_element = NULL; + if(!qlist_empty(&mode_queue)) + mode_element = qlist_entry(mode_queue.next, struct req_sched_element, + list_link); + if(current_mode == PVFS_SERVER_ADMIN_MODE || + (mode_element && mode_element->mode == PVFS_SERVER_ADMIN_MODE)) + { + return 1; + } + return 0; +} + +static int PINT_req_sched_schedule_mode_change(void) +{ + struct req_sched_element *next_element; + + /* prepare to schedule mode change if we can */ + /* NOTE: only transitions to admin mode are ever queued */ + if(sched_count == 0 && !qlist_empty(&mode_queue)) + { + next_element = qlist_entry(mode_queue.next, struct req_sched_element, + list_link); + next_element->state = REQ_READY_TO_SCHEDULE; + qlist_add_tail(&next_element->ready_link, &ready_queue); + } + return 0; +} + +static void PINT_req_sched_do_change_mode( + struct req_sched_element *req_sched_element) +{ + if(req_sched_element->mode_change) + { + current_mode = req_sched_element->mode; } - return (0); } /* scheduler submission */ @@ -362,48 +306,34 @@ int PINT_req_sched_target_handle( * request will be scheduled later, and -errno on failure */ int PINT_req_sched_post( - struct PVFS_server_req *in_request, - int req_index, + enum PVFS_server_op op, + PVFS_fs_id fs_id, + PVFS_handle handle, + int readonly_flag, + int schedule, void *in_user_ptr, req_sched_id * out_id) { struct qlist_head *hash_link; - PVFS_handle handle; int ret = -1; struct req_sched_element *tmp_element; struct req_sched_element *tmp_element2; struct req_sched_list *tmp_list; struct req_sched_element *next_element; struct req_sched_element *last_element; - struct req_sched_element *mode_element = NULL; - PVFS_fs_id fs_id; - enum PVFS_server_mode target_mode; - int mode_change_ready = 0; - int readonly_flag = 0; struct qlist_head *iterator; int tmp_flag; - /* find the handle */ - ret = PINT_req_sched_target_handle(in_request, req_index, &handle, &fs_id, - &readonly_flag); - if (ret < 0) + if(!schedule) { - return (ret); - } - if(ret == 1) - { - if(!readonly_flag && !PVFS_SERV_IS_MGMT_OP(in_request->op)) + if(!readonly_flag && !PVFS_SERV_IS_MGMT_OP(op)) { /* if this requests modifies the file system, we have to check * to see if we are in admin mode or about to enter admin mode */ - if(!qlist_empty(&mode_queue)) - mode_element = qlist_entry(mode_queue.next, struct req_sched_element, - list_link); - if(current_mode == PVFS_SERVER_ADMIN_MODE || (mode_element - && mode_element->req_ptr->u.mgmt_setparam.value == PVFS_SERVER_ADMIN_MODE)) + if(PINT_req_sched_in_admin_mode()) { - return(-PVFS_EAGAIN); + return (-PVFS_EAGAIN); } } @@ -425,7 +355,7 @@ int PINT_req_sched_post( return (-errno); } - tmp_element->req_ptr = in_request; + tmp_element->op = op; tmp_element->user_ptr = in_user_ptr; id_gen_fast_register(out_id, tmp_element); tmp_element->id = *out_id; @@ -434,69 +364,13 @@ int PINT_req_sched_post( tmp_element->list_head = NULL; tmp_element->readonly_flag = readonly_flag; - /* is this a request to change the server's operating mode? */ - if(in_request->op == PVFS_SERV_MGMT_SETPARAM - && in_request->u.mgmt_setparam.param == PVFS_SERV_PARAM_MODE) - { - target_mode = (enum PVFS_server_mode)in_request->u.mgmt_setparam.value; - /* will this be the front of the queue */ - if(qlist_empty(&mode_queue)) - mode_change_ready = 1; - - qlist_add_tail(&(tmp_element->list_link), &mode_queue); - if(mode_change_ready) - { - if(target_mode == PVFS_SERVER_NORMAL_MODE) - { - /* let this go through regardless */ - ret = 1; - tmp_element->state = REQ_SCHEDULED; - current_mode = target_mode; - } - else if(target_mode == PVFS_SERVER_ADMIN_MODE) - { - assert(sched_count > -1); - /* for this to work, we must wait for pending ops to complete */ - if(sched_count == 0) - { - ret = 1; - tmp_element->state = REQ_SCHEDULED; - current_mode = target_mode; - } - else - { - ret = 0; - tmp_element->state = REQ_QUEUED; - } - } - else - { - /* TODO: be nicer about this */ - assert(0); - } - return(ret); - } - else - { - tmp_element->state = REQ_QUEUED; - return(0); - } - } - - if(!readonly_flag && !PVFS_SERV_IS_MGMT_OP(in_request->op)) + if(!readonly_flag && !PVFS_SERV_IS_MGMT_OP(op)) { - /* if this requests modifies the file system, we have to check - * to see if we are in admin mode or about to enter admin mode - */ - if(!qlist_empty(&mode_queue)) - mode_element = qlist_entry(mode_queue.next, struct req_sched_element, - list_link); - if(current_mode == PVFS_SERVER_ADMIN_MODE || (mode_element - && mode_element->req_ptr->u.mgmt_setparam.value == PVFS_SERVER_ADMIN_MODE)) - { - free(tmp_element); - return(-PVFS_EAGAIN); - } + if(PINT_req_sched_in_admin_mode()) + { + free(tmp_element); + return(-PVFS_EAGAIN); + } } /* see if we have a request queue up for this handle */ @@ -545,7 +419,7 @@ int PINT_req_sched_post( last_element = qlist_entry((tmp_list->req_list.prev), struct req_sched_element, list_link); - if (in_request->op == PVFS_SERV_IO && + if (op == PVFS_SERV_IO && next_element->state == REQ_SCHEDULED && last_element->state == REQ_SCHEDULED) { @@ -558,7 +432,7 @@ int PINT_req_sched_post( { tmp_element2 = qlist_entry(iterator, struct req_sched_element, list_link); - if(tmp_element2->req_ptr->op != PVFS_SERV_IO) + if(tmp_element2->op != PVFS_SERV_IO) { tmp_flag = 1; break; @@ -611,8 +485,7 @@ int PINT_req_sched_post( ret = 0; } } - else if((in_request->op == PVFS_SERV_CRDIRENT || - in_request->op == PVFS_SERV_RMDIRENT) && + else if((op == PVFS_SERV_CRDIRENT || op == PVFS_SERV_RMDIRENT) && next_element->state == REQ_SCHEDULED && last_element->state == REQ_SCHEDULED) { @@ -682,7 +555,6 @@ int PINT_req_sched_post_timer( return (-errno); } - tmp_element->req_ptr = NULL; tmp_element->user_ptr = in_user_ptr; id_gen_fast_register(out_id, tmp_element); tmp_element->id = *out_id; @@ -806,7 +678,7 @@ int PINT_req_sched_unpost( /* keep going as long as the operations are I/O requests; * we let these all go concurrently */ - while (next_element && next_element->req_ptr->op == PVFS_SERV_IO + while (next_element && next_element->op == PVFS_SERV_IO && next_element->list_link.next != &(tmp_element->list_head->req_list)) { @@ -815,7 +687,7 @@ int PINT_req_sched_unpost( struct req_sched_element, list_link); if (next_element - && next_element->req_ptr->op == PVFS_SERV_IO) + && next_element->op == PVFS_SERV_IO) { gossip_debug( GOSSIP_REQ_SCHED_DEBUG, "REQ SCHED " @@ -835,15 +707,7 @@ int PINT_req_sched_unpost( /* destroy the unposted element */ free(tmp_element); - /* prepare to schedule mode change if we can */ - /* NOTE: only transitions to admin mode are ever queued */ - if(sched_count == 0 && !qlist_empty(&mode_queue)) - { - next_element = qlist_entry(mode_queue.next, struct req_sched_element, - list_link); - next_element->state = REQ_READY_TO_SCHEDULE; - qlist_add_tail(&next_element->ready_link, &ready_queue); - } + PINT_req_sched_schedule_mode_change(); return (0); } @@ -916,13 +780,13 @@ int PINT_req_sched_release( next_element->state = REQ_READY_TO_SCHEDULE; qlist_add_tail(&(next_element->ready_link), &ready_queue); - if(next_element->req_ptr->op == PVFS_SERV_IO) + if(next_element->op == PVFS_SERV_IO) { /* keep going as long as the operations are I/O requests; * we let these all go concurrently */ while (next_element && - (next_element->req_ptr->op == PVFS_SERV_IO) && + (next_element->op == PVFS_SERV_IO) && (next_element->list_link.next != &(tmp_list->req_list))) { next_element = @@ -930,7 +794,7 @@ int PINT_req_sched_release( struct req_sched_element, list_link); if (next_element && - (next_element->req_ptr->op == PVFS_SERV_IO)) + (next_element->op == PVFS_SERV_IO)) { gossip_debug( GOSSIP_REQ_SCHED_DEBUG, @@ -982,16 +846,7 @@ int PINT_req_sched_release( /* destroy the released request element */ free(tmp_element); - /* prepare to schedule mode change if we can */ - /* NOTE: only transitions to admin mode are ever queued */ - if(sched_count == 0 && !qlist_empty(&mode_queue)) - { - next_element = qlist_entry(mode_queue.next, struct req_sched_element, - list_link); - next_element->state = REQ_READY_TO_SCHEDULE; - qlist_add_tail(&next_element->ready_link, &ready_queue); - } - + PINT_req_sched_schedule_mode_change(); return (1); } @@ -1042,14 +897,8 @@ int PINT_req_sched_test( "handle: %llu, queue_element: %p\n", llu(tmp_element->handle), tmp_element); - /* if this is a mode change, then transition now */ - if ((tmp_element->req_ptr->op == PVFS_SERV_MGMT_SETPARAM) && - (tmp_element->req_ptr->u.mgmt_setparam.param == - PVFS_SERV_PARAM_MODE)) - { - current_mode = tmp_element->req_ptr->u.mgmt_setparam.value; - } - return (1); + PINT_req_sched_do_change_mode(tmp_element); + return (1); } else if (tmp_element->state == REQ_TIMING) { @@ -1142,13 +991,7 @@ int PINT_req_sched_testsome( "REQ SCHED SCHEDULING, handle: %llu, " "queue_element: %p\n", llu(tmp_element->handle), tmp_element); - /* if this is a mode change, then transition now */ - if(tmp_element->req_ptr->op == PVFS_SERV_MGMT_SETPARAM && - tmp_element->req_ptr->u.mgmt_setparam.param == PVFS_SERV_PARAM_MODE) - { - current_mode = tmp_element->req_ptr->u.mgmt_setparam.value; - } - + PINT_req_sched_do_change_mode(tmp_element); } else if(tmp_element->state == REQ_TIMING) { @@ -1255,12 +1098,7 @@ int PINT_req_sched_testworld( "REQ SCHED SCHEDULING, " "handle: %llu, queue_element: %p\n", llu(tmp_element->handle), tmp_element); - /* if this is a mode change, then transition now */ - if(tmp_element->req_ptr->op == PVFS_SERV_MGMT_SETPARAM && - tmp_element->req_ptr->u.mgmt_setparam.param == PVFS_SERV_PARAM_MODE) - { - current_mode = tmp_element->req_ptr->u.mgmt_setparam.value; - } + PINT_req_sched_do_change_mode(tmp_element); } if (*inout_count_p > 0) return (1); diff --git a/src/server/request-scheduler/request-scheduler.h b/src/server/request-scheduler/request-scheduler.h index f819d21..f8431da 100644 --- a/src/server/request-scheduler/request-scheduler.h +++ b/src/server/request-scheduler/request-scheduler.h @@ -33,18 +33,21 @@ int PINT_req_sched_finalize( void); /* retrieving information about incoming requests */ -int PINT_req_sched_target_handle(struct PVFS_server_req *req, - int req_index, - PVFS_handle * handle, - PVFS_fs_id * fs_id, - int* readonly_flag); - /* scheduler submission */ -int PINT_req_sched_post(struct PVFS_server_req *in_request, - int req_index, +int PINT_req_sched_post(enum PVFS_server_op op, + PVFS_fs_id fs_id, + PVFS_handle handle, + int read_only_flag, + int schedule, void *in_user_ptr, req_sched_id * out_id); +enum PVFS_server_mode PINT_req_sched_get_mode(void); + +int PINT_req_sched_change_mode(enum PVFS_server_mode mode, + void *user_ptr, + req_sched_id *id); + int PINT_req_sched_unpost(req_sched_id in_id, void **returned_user_ptr); @@ -73,8 +76,6 @@ int PINT_req_sched_testworld(int *inout_count_p, void **returned_user_ptr_array, req_sched_error_code * out_status_array); -enum PVFS_server_mode PINT_req_sched_get_mode(void); - #endif /* __REQUEST_SCHEDULER_H */ /* @} */ diff --git a/src/server/rmdirent.sm b/src/server/rmdirent.sm index 87a6baf..686df7f 100644 --- a/src/server/rmdirent.sm +++ b/src/server/rmdirent.sm @@ -108,7 +108,7 @@ static int rmdirent_verify_parent_metadata_and_read_directory_entry_handle( " reading dirdata handle (coll_id = 0x%x, handle = %llu, " "key = %s (%d), val_buf = %p (%d))\n", s_op->req->u.rmdirent.fs_id, - llu(s_op->req->u.rmdirent.parent_handle), + llu(s_op->req->u.rmdirent.handle), (char *)s_op->key.buffer, s_op->key.buffer_sz, s_op->val.buffer, @@ -116,7 +116,7 @@ static int rmdirent_verify_parent_metadata_and_read_directory_entry_handle( ret = job_trove_keyval_read( s_op->req->u.rmdirent.fs_id, - s_op->req->u.rmdirent.parent_handle, + s_op->req->u.rmdirent.handle, &s_op->key, &s_op->val, 0, @@ -216,7 +216,7 @@ static PINT_sm_action rmdirent_update_directory_attr( PVFS_object_attr_to_ds_attr(tmp_attr_ptr, ds_attr); ret = job_trove_dspace_setattr( - s_op->req->u.rmdirent.fs_id, s_op->req->u.rmdirent.parent_handle, + s_op->req->u.rmdirent.fs_id, s_op->req->u.rmdirent.handle, ds_attr, TROVE_SYNC, smcb, 0, js_p, &j_id, server_job_context); @@ -290,6 +290,18 @@ static PINT_sm_action rmdirent_cleanup( return(server_state_machine_complete(smcb)); } +PINT_GET_OBJECT_REF_DEFINE(rmdirent); + +struct PINT_server_req_params pvfs2_rmdirent_params = +{ + .string_name = "rmdirent", + .perm = PINT_SERVER_CHECK_WRITE, + .access_type = PINT_server_req_modify, + .sched_policy = PINT_SERVER_REQ_SCHEDULE, + .get_object_ref = PINT_get_object_ref_rmdirent, + .state_machine = &pvfs2_rmdirent_sm +}; + /* * Local variables: * mode: c diff --git a/src/server/set-attr.sm b/src/server/set-attr.sm index 11151ac..9e381c1 100644 --- a/src/server/set-attr.sm +++ b/src/server/set-attr.sm @@ -486,6 +486,18 @@ static PINT_sm_action setattr_cleanup( return(server_state_machine_complete(smcb)); } +PINT_GET_OBJECT_REF_DEFINE(setattr); + +struct PINT_server_req_params pvfs2_set_attr_params = +{ + .string_name = "setattr", + .perm = PINT_SERVER_CHECK_ATTR, + .access_type = PINT_server_req_modify, + .sched_policy = PINT_SERVER_REQ_SCHEDULE, + .get_object_ref = PINT_get_object_ref_setattr, + .state_machine = &pvfs2_set_attr_sm +}; + /* * Local variables: * mode: c diff --git a/src/server/set-eattr.sm b/src/server/set-eattr.sm index 55ae624..98a376f 100644 --- a/src/server/set-eattr.sm +++ b/src/server/set-eattr.sm @@ -165,6 +165,18 @@ static int seteattr_cleanup( return(server_state_machine_complete(smcb)); } +PINT_GET_OBJECT_REF_DEFINE(seteattr); + +struct PINT_server_req_params pvfs2_set_eattr_params = +{ + .string_name = "set_eattr", + .perm = PINT_SERVER_CHECK_ATTR, + .access_type = PINT_server_req_modify, + .sched_policy = PINT_SERVER_REQ_SCHEDULE, + .get_object_ref = PINT_get_object_ref_seteattr, + .state_machine = &pvfs2_set_eattr_sm +}; + /* * Local variables: * mode: c diff --git a/src/server/setparam.sm b/src/server/setparam.sm index 40d8654..d4890a3 100644 --- a/src/server/setparam.sm +++ b/src/server/setparam.sm @@ -15,6 +15,7 @@ #include "pvfs2-server.h" #include "pint-event.h" #include "pvfs2-internal.h" +#include "request-scheduler/request-scheduler.h" static int check_fs_id(PVFS_fs_id fs_id); @@ -154,9 +155,14 @@ static PINT_sm_action setparam_work( js_p->error_code = 0; return SM_ACTION_COMPLETE; case PVFS_SERV_PARAM_MODE: - /* no work to do here; request scheduler has already handled */ + + s_op->resp.u.mgmt_setparam.old_value = PINT_req_sched_get_mode(); + ret = job_req_sched_change_mode(s_op->req->u.mgmt_setparam.value, + NULL, 0, js_p, &s_op->scheduled_id, + server_job_context); + js_p->error_code = 0; - return SM_ACTION_COMPLETE; + return ret; } gossip_lerr("Error: mgmt_setparam for unknown parameter %d.\n", @@ -240,6 +246,24 @@ check_failed: return ret; } +static inline int PINT_get_object_ref_setparam( + struct PVFS_server_req *req, PVFS_fs_id *fs_id, PVFS_handle *handle) +{ + *fs_id = req->u.mgmt_setparam.fs_id; + *handle = PVFS_HANDLE_NULL; + return 0; +}; + +struct PINT_server_req_params pvfs2_setparam_params = +{ + .string_name = "mgmt_setparam", + .perm = PINT_SERVER_CHECK_NONE, + .access_type = PINT_server_req_modify, + .sched_policy = PINT_SERVER_REQ_SCHEDULE, + .get_object_ref = PINT_get_object_ref_setparam, + .state_machine = &pvfs2_setparam_sm +}; + /* * Local variables: * mode: c diff --git a/src/server/small-io.sm b/src/server/small-io.sm index 7327c97..38b78c7 100644 --- a/src/server/small-io.sm +++ b/src/server/small-io.sm @@ -241,6 +241,28 @@ static PINT_sm_action small_io_cleanup( return server_state_machine_complete(smcb); } +static inline int PINT_server_req_access_small_io( + struct PVFS_server_req *req) +{ + if(req->u.io.io_type == PVFS_IO_READ) + { + return 1; + } + return 0; +} + +PINT_GET_OBJECT_REF_DEFINE(small_io); + +struct PINT_server_req_params pvfs2_small_io_params = +{ + .string_name = "small_io", + .perm = PINT_SERVER_CHECK_NONE, + .access_type = PINT_server_req_access_small_io, + .sched_policy = PINT_SERVER_REQ_SCHEDULE, + .get_object_ref = PINT_get_object_ref_small_io, + .state_machine = &pvfs2_small_io_sm +}; + /* * Local variables: * mode: c diff --git a/src/server/statfs.sm b/src/server/statfs.sm index 95ccf02..9e62503 100644 --- a/src/server/statfs.sm +++ b/src/server/statfs.sm @@ -146,6 +146,21 @@ static PINT_sm_action statfs_cleanup( return(server_state_machine_complete(smcb)); } +static inline int PINT_get_object_ref_statfs( + struct PVFS_server_req *req, PVFS_fs_id *fs_id, PVFS_handle *handle) +{ + *fs_id = req->u.statfs.fs_id; + *handle = PVFS_HANDLE_NULL; + return 0; +} + +struct PINT_server_req_params pvfs2_statfs_params = +{ + .string_name = "statfs", + .get_object_ref = PINT_get_object_ref_statfs, + .state_machine = &pvfs2_statfs_sm +}; + /* * Local variables: diff --git a/src/server/truncate.sm b/src/server/truncate.sm index c1a4716..c154c50 100644 --- a/src/server/truncate.sm +++ b/src/server/truncate.sm @@ -79,6 +79,18 @@ static PINT_sm_action truncate_cleanup( return (server_state_machine_complete(smcb)); } +PINT_GET_OBJECT_REF_DEFINE(truncate); + +struct PINT_server_req_params pvfs2_truncate_params = +{ + .string_name = "truncate", + .perm = PINT_SERVER_CHECK_NONE, + .access_type = PINT_server_req_modify, + .sched_policy = PINT_SERVER_REQ_SCHEDULE, + .get_object_ref = PINT_get_object_ref_truncate, + .state_machine = &pvfs2_truncate_sm +}; + /* * Local variables: * mode: c diff --git a/src/server/unexpected.sm b/src/server/unexpected.sm index e1e73d6..afeda2e 100644 --- a/src/server/unexpected.sm +++ b/src/server/unexpected.sm @@ -99,6 +99,10 @@ static PINT_sm_action unexpected_map( */ gossip_lerr("Error: post unexpected failure when restarting.\n"); } + + /* Bump up the reference count on the bmi address that we are using */ + BMI_set_info(s_op->unexp_bmi_buff.addr, BMI_INC_ADDR_REF, NULL); + /* restart as new request state machine */ memset(js_p, 0, sizeof(job_status_s)); ret = server_state_machine_start(smcb, js_p); diff --git a/test/client/sysint/getattr-test-threaded.c b/test/client/sysint/getattr-test-threaded.c new file mode 100644 index 0000000..eb88e20 --- /dev/null +++ b/test/client/sysint/getattr-test-threaded.c @@ -0,0 +1,282 @@ +/* + * (C) 2001 Clemson University and The University of Chicago + * + * See COPYING in top-level directory. + */ + +/* based off of io-test.c. This is meant to exercise a bug found by Florin + * Isaila in which two concurrent threads running sys_io() will deadlock on a + * configuration struct lock ordering problem. + */ + +#include +#include +#include "client.h" +#include +#include +#include +#include +#include +#include +#include "pvfs2-util.h" +#include "pvfs2-mgmt.h" +#include "pvfs2-internal.h" + +struct thread_info +{ + PVFS_object_ref* pinode_refn; + PVFS_object_ref* pinode_refn2; + PVFS_credentials* credentials; +}; + +void* thread_fn(void* foo); +pthread_mutex_t error_count_mutex = PTHREAD_MUTEX_INITIALIZER; +int error_count = 0; + +int main(int argc, char **argv) +{ + PVFS_sysresp_lookup resp_lk; + PVFS_sysresp_create resp_cr; + int ret = -1; + int i; + PVFS_fs_id fs_id; + char name[512] = {0}; + char *entry_name = NULL; + PVFS_credentials credentials; + PVFS_object_ref parent_refn; + PVFS_sys_attr attr; + PVFS_object_ref pinode_refn; + PVFS_object_ref pinode_refn2; + struct thread_info info; + pthread_t* thread_id_array; + int num_threads = 1; + + if (argc != 4) + { + fprintf(stderr, "Usage: %s \n", argv[0]); + return (-1); + } + + if(sscanf(argv[1], "%d", &num_threads) != 1) + { + fprintf(stderr, "Usage: %s \n", argv[0]); + return (-1); + } + + thread_id_array = malloc(num_threads* sizeof(pthread_t)); + if(!thread_id_array) + { + perror("malloc"); + return(-1); + } + + ret = PVFS_util_init_defaults(); + if (ret < 0) + { + PVFS_perror("PVFS_util_init_defaults", ret); + return (-1); + } + ret = PVFS_util_get_default_fsid(&fs_id); + if (ret < 0) + { + PVFS_perror("PVFS_util_get_default_fsid", ret); + return (-1); + } + + /* FIRST FILE */ + if (argv[2][0] == '/') + { + snprintf(name, 512, "%s", argv[2]); + } + else + { + snprintf(name, 512, "/%s", argv[2]); + } + + PVFS_util_gen_credentials(&credentials); + ret = PVFS_sys_lookup(fs_id, name, &credentials, + &resp_lk, PVFS2_LOOKUP_LINK_FOLLOW); + if (ret == -PVFS_ENOENT) + { + PVFS_sysresp_getparent gp_resp; + + memset(&gp_resp, 0, sizeof(PVFS_sysresp_getparent)); + ret = PVFS_sys_getparent(fs_id, name, &credentials, &gp_resp); + if (ret < 0) + { + PVFS_perror("PVFS_sys_getparent failed", ret); + return ret; + } + + attr.owner = credentials.uid; + attr.group = credentials.gid; + attr.perms = PVFS_U_WRITE | PVFS_U_READ; + attr.atime = attr.ctime = attr.mtime = time(NULL); + attr.mask = PVFS_ATTR_SYS_ALL_SETABLE; + parent_refn = gp_resp.parent_ref; + + entry_name = rindex(name, (int)'/'); + assert(entry_name); + entry_name++; + assert(entry_name); + + ret = PVFS_sys_create(entry_name, parent_refn, attr, + &credentials, NULL, NULL, &resp_cr); + if (ret < 0) + { + PVFS_perror("PVFS_sys_create() failure", ret); + return (-1); + } + + pinode_refn.fs_id = fs_id; + pinode_refn.handle = resp_cr.ref.handle; + } + else + { + pinode_refn.fs_id = fs_id; + pinode_refn.handle = resp_lk.ref.handle; + } + + /* SECOND FILE */ + if (argv[3][0] == '/') + { + snprintf(name, 512, "%s", argv[3]); + } + else + { + snprintf(name, 512, "/%s", argv[3]); + } + + PVFS_util_gen_credentials(&credentials); + ret = PVFS_sys_lookup(fs_id, name, &credentials, + &resp_lk, PVFS2_LOOKUP_LINK_FOLLOW); + if (ret == -PVFS_ENOENT) + { + PVFS_sysresp_getparent gp_resp; + + memset(&gp_resp, 0, sizeof(PVFS_sysresp_getparent)); + ret = PVFS_sys_getparent(fs_id, name, &credentials, &gp_resp); + if (ret < 0) + { + PVFS_perror("PVFS_sys_getparent failed", ret); + return ret; + } + + attr.owner = credentials.uid; + attr.group = credentials.gid; + attr.perms = PVFS_U_WRITE | PVFS_U_READ; + attr.atime = attr.ctime = attr.mtime = time(NULL); + attr.mask = PVFS_ATTR_SYS_ALL_SETABLE; + parent_refn = gp_resp.parent_ref; + + entry_name = rindex(name, (int)'/'); + assert(entry_name); + entry_name++; + assert(entry_name); + + ret = PVFS_sys_create(entry_name, parent_refn, attr, + &credentials, NULL, NULL, &resp_cr); + if (ret < 0) + { + PVFS_perror("PVFS_sys_create() failure", ret); + return (-1); + } + + pinode_refn2.fs_id = fs_id; + pinode_refn2.handle = resp_cr.ref.handle; + } + else + { + pinode_refn2.fs_id = fs_id; + pinode_refn2.handle = resp_lk.ref.handle; + } + + + /* fill in information for threads */ + info.pinode_refn = &pinode_refn; + info.pinode_refn2 = &pinode_refn2; + info.credentials = &credentials; + + /* launch threads then wait for them to finish */ + for(i=0; ipinode_refn, PVFS_ATTR_SYS_ALL, + info->credentials, &resp_getattr); + if (ret < 0) + { + PVFS_perror("PVFS_sys_getattr failure", ret); + pthread_mutex_lock(&error_count_mutex); + error_count++; + pthread_mutex_unlock(&error_count_mutex); + return (NULL); + } + ret = PVFS_sys_getattr(*info->pinode_refn2, PVFS_ATTR_SYS_ALL, + info->credentials, &resp_getattr); + if (ret < 0) + { + PVFS_perror("PVFS_sys_getattr failure", ret); + pthread_mutex_lock(&error_count_mutex); + error_count++; + pthread_mutex_unlock(&error_count_mutex); + return (NULL); + } + } + + return(NULL); +} + +/* + * Local variables: + * c-indent-level: 4 + * c-basic-offset: 4 + * End: + * + * vim: ts=8 sts=4 sw=4 expandtab + */ diff --git a/test/client/sysint/io-test-threaded.c b/test/client/sysint/io-test-threaded.c index aec53b3..5afd52e 100644 --- a/test/client/sysint/io-test-threaded.c +++ b/test/client/sysint/io-test-threaded.c @@ -232,6 +232,8 @@ int main(int argc, char **argv) } pthread_mutex_unlock(&error_count_mutex); + free(thread_id_array); + return (ret); } @@ -300,6 +302,8 @@ void* thread_fn(void* foo) } } + free(io_buffer); + return(NULL); } diff --git a/test/client/sysint/module.mk.in b/test/client/sysint/module.mk.in index ba0270d..c5a2f73 100644 --- a/test/client/sysint/module.mk.in +++ b/test/client/sysint/module.mk.in @@ -25,6 +25,7 @@ TESTSRC += \ $(DIR)/io-test.c \ $(DIR)/io-test-offset.c \ $(DIR)/io-test-threaded.c \ + $(DIR)/getattr-test-threaded.c \ $(DIR)/initialize.c \ $(DIR)/initialize-dyn.c \ $(DIR)/getparent.c \ @@ -43,6 +44,7 @@ TESTSRC += \ MODCFLAGS_$(DIR)/io-stress.c := -D_GNU_SOURCE MODLDFLAGS_$(DIR) := -lrt MODLDFLAGS_$(DIR)/io-test-threaded := -lpthread +MODLDFLAGS_$(DIR)/getattr-test-threaded := -lpthread #$(DIR)/io-test-threaded: $(DIR)/io-test-threaded.o # $(Q) " LD $@" diff --git a/test/client/sysint/test-pint-bucket.c b/test/client/sysint/test-pint-bucket.c index 0dbafaa..f6a559d 100644 --- a/test/client/sysint/test-pint-bucket.c +++ b/test/client/sysint/test-pint-bucket.c @@ -111,7 +111,7 @@ int main(int argc, char **argv) } printf("Loading mappings of filesystem %s\n", cur_fs->file_system_name); - if (PINT_handle_load_mapping(&server_config,cur_fs)) + if (PINT_cached_config_handle_load_mapping(cur_fs)) { fprintf(stderr, "PINT_handle_load_mapping failure.\n"); return(-1); @@ -151,10 +151,8 @@ int main(int argc, char **argv) printf("\n"); for(j = 0; j < NUM_META_SERVERS_TO_QUERY; j++) { - if (PINT_cached_config_get_next_meta(&server_config, - fs_ids[i], - &m_addr, - &meta_handle_extent_array)) + if (PINT_cached_config_get_next_meta( + fs_ids[i], &m_addr, &meta_handle_extent_array)) { fprintf(stderr, "PINT_cached_config_get_next_meta failure.\n"); return(-1); @@ -172,9 +170,9 @@ int main(int argc, char **argv) } } - if (PINT_cached_config_get_next_io(&server_config, fs_ids[i], - NUM_DATA_SERVERS_TO_QUERY, - d_addr, data_handle_extent_array)) + if (PINT_cached_config_get_next_io( + fs_ids[i], NUM_DATA_SERVERS_TO_QUERY, + d_addr, data_handle_extent_array)) { fprintf(stderr, "PINT_cached_config_get_next_io failure.\n"); return(-1); diff --git a/test/io/job/module.mk.in b/test/io/job/module.mk.in index efbf79e..cb37e69 100644 --- a/test/io/job/module.mk.in +++ b/test/io/job/module.mk.in @@ -4,7 +4,6 @@ TEST_IO_JOB_DIR := io/job TEST_IO_JOB_DIR_SRC := \ $(DIR)/job-client-example.c \ $(DIR)/job-server-example.c \ - $(DIR)/req-sched-job-test.c \ $(DIR)/trove-job-create-toy.c \ $(DIR)/trove-job-io.c \ $(DIR)/trove-job-ls.c \ @@ -14,6 +13,8 @@ TEST_IO_JOB_DIR_SRC := \ $(DIR)/thread-bench2.c \ $(DIR)/thread-bench3.c +# $(DIR)/req-sched-job-test.c \ + MISCSRC += $(DIR)/job-help.c TESTSRC += $(TEST_IO_JOB_DIR_SRC) diff --git a/test/server/request-scheduler/module.mk.in b/test/server/request-scheduler/module.mk.in index bb70555..1dc94cb 100644 --- a/test/server/request-scheduler/module.mk.in +++ b/test/server/request-scheduler/module.mk.in @@ -1,5 +1,4 @@ DIR := server/request-scheduler -TESTSRC += \ - $(DIR)/request-scheduler-test.c - +#TESTSRC += \ +# $(DIR)/request-scheduler-test.c