diff --git a/ChangeLog b/ChangeLog index 8367e83..279d445 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,131 @@ ----------------------- OrangeFS Release ChangeLog ----------------------- +orangefs-2.8.5 + +SVN changes can be seen at +http://www.orangefs.org/fisheye/orangefs/changelog/orangefs/branches/orangefs-2-8-5 + +* Bug Fix: Problem: server seg faulted when the unstuff state machine tried + to unstuff a file defined as needing more datafilesthan I/O servers currently + in the system. A side affect was that this worked when there was more than + one server in the system. The correct behavior is to NEVER define more datahandles than + there are I/O servers in the system. + Correction: Modified function PINT_cached_config_get_num_dfiles to return no + more than the number of I/O servers, regardless of the number requested by the user + or needed by the distribution. This function is called during the sys-create state machine + BEFORE the number of requested datafiles is sent to the server. + SVN: Change #9082 + +* Enhancement: Added optimization. When a file is created and the requested number of dfiles is 1, + then we create the metadata without "stuffed" values,i.e., key="nd". When data + is written to this file, there is no need to execute the "unstuff" server side + state machine. + SVN: Change #9083 + +Text after "CVS: " can be prepended with "http://www.pvfs.org/fisheye/changelog/~br=Orange-Branch/PVFS/?cs=Orange-Branch:" to view related change sets in FishEye. + +* Enhancement: change to kernel source path to support SuSE style kernel sources + CVS: mtmoore:20110831005433 + +* Enhancement: add prompt after X removals during a pvfs2-fsck when -y specified + CVS: mtmoore:20110824144127 + +* Enhancement: Add sanity checks to extended attribute operations + CVS: mtmoore:20110811180653 + +* Enhancement addition of counters and application to feed SNMP counters + CVS: walt:20110628184842 + CVS: walt:20110628161840 + CVS: walt:20110617152339 + +* Enhancement: addition of scripts used for OrangeFS CI Jenkins testing + CVS: mtmoore:20110623183144 + +* Enhancement: add backtrace handler to SIGABRT + CVS: mtmoore:20110607235041 + +* Enhancement: add sanity checks during trove cleanup/initialization + CVS: mtmoore:20110607232817 + +* Enhancement: allow server log to be re-opened on SIGHUP to allow log rotation + CVS: mtmoore:20110607023901 + CVS: mtmoore:20110530143543 + +* Enhancement: allow debug mask to be reset during SIGHUP + CVS: bligon:20110504200411 + +* Enhancement: add Berkeley DB configure check for version 4.8.30 + CVS: mtmoore:20110405050554 + Additional Information: https://www.orangefs.org/trac/orangefs/wiki/DBVersionRequired + +* Enhancement add configure checks for binaries required during build + CVS: mtmoore:20110404165443 + +* Enhancement: kernel changes to support newer kernels (up to 2.6.40 tested and 3.X compiles, not tested) + CVS: mtmoore:20110831005433 + CVS: mtmoore:20110823184109 + CVS: mtmoore:20110822232017 + CVS: mtmoore:20110412175323 + CVS: mtmoore:20110525205504 + CVS: mtmoore:20110405142136 + CVS: mtmoore:20110405141506 + +* Bug Fix: man pages are now gzip'd during installation + CVS: mtmoore:20110904010919 + +* Bug Fix: berkeley db gives back unaligned pages (in custom compare/multi-key cases), use local variables to fix ARM failures + CVS: mtmoore:20110902173424 + +* Bug Fix: pointer dereference size issue in dbpf-mgmt on non-x86 platforms, Neal Ferguson + CVS: mtmoore:20110823171834 + +* Bug Fix: file corruption using direct backend when writes continuously appending to single file + CVS: elaine:20110819120934 + CVS: mtmoore:20110629130442 + +* Bug Fix: segfault in pvfs2-xattr due to mirror handle string comparison, Nick Mills + CVS: mtmoore:20110809180325 + +* Bug Fix: add backtrace functionality back in for newer distributions + CVS: mtmoore:20110801124552 + CVS: mtmoore:20110607215819 + +* Bug Fix: server-side memory leak related to operation completion + CVS: bligon:20110708194724 + +* Bug Fix: slab cache fix, Bart Taylor + CVS: bligon:20110613200154 + +* Bug Fix: duplicate handle fix in iterate-handles, Phil Carns + CVS: bligon:20110610202309 + +* Bug Fix: correctly parse pvfs2-server alias argument + CVS: mtmoore:20110608010721 + +* Bug Fix: mx_address lookup failure with multiple protocols + CVS: bligon:20110530173949 + +* Bug Fix: admin apps segfault with IB + CVS: bligon:20110512215357 + +* Bug Fix: allow pvfs2-server to re-read configuratio file regardless of absolute or relative path + CVS: mtmoore:20110506194814 + +* Bug Fix: root squash functionality, Bart Taylor + CVS: bligon:20110506173620 + +* Bug Fix: various kernel related stability and error-handling fixes + CVS: mtmoore:20110729151843 + CVS: mtmoore:20110729143317 + CVS: mtmoore:20110530154853 + CVS: mtmoore:20110412175444 + +* Bug Fix: pin memory passed in to the kernel to prevent swap pages and kernel panic + CVS: mtmoore:20110725160953 + +------------------------------------------------------------------------------- + orangefs-2.8.4 * Change verisioning to no longer include dates, just increment the sub version for every release diff --git a/Makefile.in b/Makefile.in index 8d9d924..565012e 100644 --- a/Makefile.in +++ b/Makefile.in @@ -144,7 +144,8 @@ INCLUDES := \ src/common/id-generator \ src/common/gossip \ src/common/gen-locks \ - src/common/events + src/common/events \ + src/client/usrint GENINCLUDES := \ include else @@ -157,6 +158,7 @@ INCLUDES := \ src/common/gossip \ src/common/gen-locks \ src/common/events \ + src/client/usrint \ src/io/trove \ src/io/bmi \ src/io/description \ @@ -211,6 +213,8 @@ SO_FULLVER = $(SO_VER).$(SO_MINOR).$(SO_RELEASE) CFLAGS += -D__STATIC_FLOWPROTO_MULTIQUEUE__ # turn on large file support by default CFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE + # define __GNU_SOURCE in includes to replace incorrect usage of __USE_GNU +CFLAGS += -D_GNU_SOURCE # include current directory (for pvfs2-config.h) CFLAGS += -I . # include toplevel source dir @@ -445,6 +449,8 @@ ADMINSRC_SERVER := USERSRC := # LIBSRC is source code for libpvfs2 LIBSRC := +# ULIBSRC is source code for libpvfs2 +ULIBSRC := # SERVERSRC is souce code for the pvfs2 server SERVERSRC := ifdef BUILD_BMI_ONLY @@ -496,18 +502,18 @@ ifeq ($(build_shared),yes) ifdef BUILD_BMI_ONLY BMILIBRARIES := lib/libbmi.so endif -LIBRARIES_SHARED = lib/libpvfs2.so +LIBRARIES_SHARED = lib/libpvfs2.so lib/libofs.so LIBRARIES += $(LIBRARIES_SHARED) -LIBRARIES_THREADED_SHARED += lib/libpvfs2-threaded.so +LIBRARIES_THREADED_SHARED += lib/libpvfs2-threaded.so lib/libofs-threaded.so LIBRARIES_THREADED += $(LIBRARIES_THREADED_SHARED) endif ifeq ($(build_static),yes) ifdef BUILD_BMI_ONLY BMILIBRARIES += lib/libbmi.a endif -LIBRARIES_STATIC = lib/libpvfs2.a +LIBRARIES_STATIC = lib/libpvfs2.a lib/libofs.a LIBRARIES += $(LIBRARIES_STATIC) -LIBRARIES_THREADED_STATIC += lib/libpvfs2-threaded.a +LIBRARIES_THREADED_STATIC += lib/libpvfs2-threaded.a lib/libofs-threaded.a LIBRARIES_THREADED += $(LIBRARIES_THREADED_STATIC) endif @@ -549,10 +555,16 @@ endif # LIBTHREADEDOBJS is a list of objects to put in the multithreaded client lib LIBTHREADEDOBJS := $(patsubst %.c,%-threaded.o, $(filter %.c,$(LIBSRC))) +# ULIBTHREADEDOBJS is a list of objects to put in the multithreaded ofs lib +ULIBTHREADEDOBJS := $(patsubst %.c,%-threaded.o, $(filter %.c,$(ULIBSRC))) # LIBTHREADEDPICOBJS are the same, but compiled for use in a shared library LIBTHREADEDPICOBJS := $(patsubst %.c,%-threaded.po, $(filter %.c,$(LIBSRC))) +# ULIBTHREADEDPICOBJS are the same, but compiled for use in a shared ofs library +ULIBTHREADEDPICOBJS := $(patsubst %.c,%-threaded.po, $(filter %.c,$(ULIBSRC))) # LIBTHREADEDDEPENDS is a list of dependency files for the multithreaded client lib LIBTHREADEDDEPENDS := $(patsubst %.c,%.d, $(filter %.c,$(LIBSRC))) +# ULIBTHREADEDDEPENDS is a list of dependency files for the # multithreaded ofs lib +ULIBTHREADEDDEPENDS := $(patsubst %.c,%.d, $(filter %.c,$(ULIBSRC))) # ADMINOBJS is a list of admin program objects ADMINOBJS := $(patsubst %.c,%.o, $(filter %.c,$(ADMINSRC))) # ADMINTOOLS is a list of admin program executables @@ -765,7 +777,7 @@ lib/libpvfs2-threaded.a: $(LIBTHREADEDOBJS) lib/libpvfs2.so: $(LIBPICOBJS) $(Q) " LDSO $@" $(E)$(INSTALL) -d lib - $(E)$(LDSHARED) -Wl,-soname,libpvfs2.so -o $@ $(LIBPICOBJS) $(DEPLIBS) -lpthread + $(E)$(LDSHARED) -Wl,-soname,libpvfs2.so -o $@ $(LIBPICOBJS) $(DEPLIBS) # rule for building the pvfs2 _multithreaded_ library lib/libpvfs2-threaded.so: $(LIBTHREADEDPICOBJS) @@ -773,6 +785,30 @@ lib/libpvfs2-threaded.so: $(LIBTHREADEDPICOBJS) $(E)$(INSTALL) -d lib $(E)$(LDSHARED) -Wl,-soname,libpvfs2-threaded.so -o $@ $(LIBTHREADEDPICOBJS) $(DEPLIBS) +# rule for building the ofs library +lib/libofs.a: $(ULIBOBJS) + $(Q) " RANLIB $@" + $(E)$(INSTALL) -d lib + $(E)ar rcs $@ $(ULIBOBJS) + +# rule for building the _multithreaded_ ofs library +lib/libofs-threaded.a: $(ULIBTHREADEDOBJS) + $(Q) " RANLIBTHREADED $@" + $(E)$(INSTALL) -d lib + $(E)ar rcs $@ $(ULIBTHREADEDOBJS) + +# rule for building the ofs library +lib/libofs.so: $(ULIBPICOBJS) + $(Q) " LDSO $@" + $(E)$(INSTALL) -d lib + $(E)$(LDSHARED) -Wl,-soname,libofs.so -o $@ $(ULIBPICOBJS) $(DEPLIBS) + +# rule for building the ofs _multithreaded_ library +lib/libofs-threaded.so: $(ULIBTHREADEDPICOBJS) + $(Q) " LDSO $@" + $(E)$(INSTALL) -d lib + $(E)$(LDSHARED) -Wl,-soname,libofs-threaded.so -o $@ $(ULIBTHREADEDPICOBJS) $(DEPLIBS) + # rule for building the pvfs2 server library lib/libpvfs2-server.a: $(SERVEROBJS) $(Q) " RANLIB $@" @@ -947,6 +983,7 @@ endif clean:: $(Q) " CLEAN" $(E)rm -f $(LIBOBJS) $(LIBTHREADEDOBJS) \ + $(ULIBOBJS) $(ULIBTHREADEDOBJS) \ $(SERVEROBJS) $(SERVERBINOBJS) $(MISCOBJS) \ $(LIBRARIES) $(LIBRARIES_THREADED) $(DEPENDS) $(SERVER) \ $(ADMINOBJS) $(ADMINOBJS_SERVER) $(ADMINTOOLS)\ @@ -1073,8 +1110,12 @@ endif install_doc: install -d $(mandir)/man1 install -d $(mandir)/man5 + rm -f ${mandir}/man1/*.gz + rm -f ${mandir}/man5/*.gz install -m 644 $(srcdir)/doc/man/*.1 $(mandir)/man1 install -m 644 $(srcdir)/doc/man/*.5 $(mandir)/man5 + gzip ${mandir}/man1/* + gzip ${mandir}/man5/* ifdef BUILD_BMI_ONLY install:: all @@ -1205,11 +1246,14 @@ just_kmod24_install: just_kmod24 install -d $(KMOD_DIR) install -m 755 src/kernel/linux-2.4/pvfs2.o $(KMOD_DIR) -.PHONY: kmod24_install -kmod24_install: kmod24 kernapps just_kmod24_install +.PHONY: just_kmod24_apps_install +just_kmod24_apps_install: kmod24 kernapps install -d $(sbindir) install -m 755 $(KERNAPPS) $(KERNAPPSTHR) $(sbindir) install -m 755 src/apps/kernel/linux/mount.pvfs2 $(sbindir) + +.PHONY: kmod24_install +kmod24_install: kmod24 kernapps just_kmod24_install just_kmod24_apps_install @echo "" @echo "For improved linux-2.4 support," @echo "install $(sbindir)/mount.pvfs2 to /sbin/mount.pvfs2" diff --git a/config.save b/config.save index 1ab0d63..4ba69e8 100755 --- a/config.save +++ b/config.save @@ -89,6 +89,7 @@ fi IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. +as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -134,19 +135,19 @@ export LANGUAGE (unset CDPATH) >/dev/null 2>&1 && unset CDPATH -# as_fn_error ERROR [LINENO LOG_FD] -# --------------------------------- +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the -# script with status $?, using 1 if that was 0. +# script with STATUS, using 1 if that was 0. as_fn_error () { - as_status=$?; test $as_status -eq 0 && as_status=1 - if test "$3"; then - as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3 + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi - $as_echo "$as_me: error: $1" >&2 + $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error @@ -342,7 +343,7 @@ $as_echo X"$as_dir" | test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p @@ -392,7 +393,7 @@ exec 6>&1 # values after options handling. ac_log=" This file was extended by $as_me, which was -generated by GNU Autoconf 2.65. Invocation command line was +generated by GNU Autoconf 2.68. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -404,7 +405,7 @@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " # Files that config.status was made for. -config_files=" include/pvfs2.h Makefile module.mk src/apps/admin/module.mk src/apps/admin/pvfs2-config src/apps/devel/module.mk src/apps/karma/module.mk src/apps/vis/module.mk src/apps/fuse/module.mk src/apps/kernel/linux/module.mk src/apps/user/module.mk src/io/trove/module.mk src/io/trove/trove-handle-mgmt/module.mk src/io/trove/trove-dbpf/module.mk src/common/misc/module.mk src/common/quickhash/module.mk src/common/quicklist/module.mk src/common/dotconf/module.mk src/common/id-generator/module.mk src/common/gossip/module.mk src/common/gen-locks/module.mk src/common/llist/module.mk src/common/statecomp/module.mk src/common/events/module.mk src/common/mgmt/module.mk src/io/bmi/module.mk src/io/bmi/bmi_tcp/module.mk src/io/bmi/bmi_gm/module.mk src/io/bmi/bmi_mx/module.mk src/io/bmi/bmi_ib/module.mk src/io/bmi/bmi_osd/module.mk src/io/bmi/bmi_portals/module.mk src/io/bmi/bmi_zoid/module.mk src/io/description/module.mk src/io/flow/module.mk src/io/flow/flowproto-bmi-trove/module.mk src/io/flow/flowproto-template/module.mk src/io/flow/flowproto-dump-offsets/module.mk src/io/flow/flowproto-bmi-cache/module.mk src/io/buffer/module.mk src/io/job/module.mk src/io/dev/module.mk src/proto/module.mk src/server/module.mk src/server/request-scheduler/module.mk src/client/sysint/module.mk src/kernel/linux-2.6/Makefile src/kernel/linux-2.4/Makefile doc/module.mk doc/coding/module.mk doc/design/module.mk doc/random/module.mk examples/pvfs2-server.rc doc/doxygen/pvfs2-doxygen.conf" +config_files=" include/pvfs2.h Makefile module.mk src/apps/admin/module.mk src/apps/admin/pvfs2-config src/apps/devel/module.mk src/apps/karma/module.mk src/apps/vis/module.mk src/apps/fuse/module.mk src/apps/kernel/linux/module.mk src/apps/user/module.mk src/io/trove/module.mk src/io/trove/trove-handle-mgmt/module.mk src/io/trove/trove-dbpf/module.mk src/common/misc/module.mk src/common/quickhash/module.mk src/common/quicklist/module.mk src/common/dotconf/module.mk src/common/id-generator/module.mk src/common/gossip/module.mk src/common/gen-locks/module.mk src/common/llist/module.mk src/common/statecomp/module.mk src/common/events/module.mk src/common/mgmt/module.mk src/io/bmi/module.mk src/io/bmi/bmi_tcp/module.mk src/io/bmi/bmi_gm/module.mk src/io/bmi/bmi_mx/module.mk src/io/bmi/bmi_ib/module.mk src/io/bmi/bmi_osd/module.mk src/io/bmi/bmi_portals/module.mk src/io/bmi/bmi_zoid/module.mk src/io/description/module.mk src/io/flow/module.mk src/io/flow/flowproto-bmi-trove/module.mk src/io/flow/flowproto-template/module.mk src/io/flow/flowproto-dump-offsets/module.mk src/io/flow/flowproto-bmi-cache/module.mk src/io/buffer/module.mk src/io/job/module.mk src/io/dev/module.mk src/proto/module.mk src/server/module.mk src/server/request-scheduler/module.mk src/client/sysint/module.mk src/client/usrint/module.mk src/kernel/linux-2.6/Makefile src/kernel/linux-2.4/Makefile doc/module.mk doc/coding/module.mk doc/design/module.mk doc/random/module.mk examples/pvfs2-server.rc doc/doxygen/pvfs2-doxygen.conf" config_headers=" pvfs2-config.h" ac_cs_usage="\ @@ -437,10 +438,10 @@ Report bugs to the package provider." ac_cs_config="" ac_cs_version="\ config.status -configured by ./configure, generated by GNU Autoconf 2.65, +configured by ./configure, generated by GNU Autoconf 2.68, with options \"$ac_cs_config\" -Copyright (C) 2009 Free Software Foundation, Inc. +Copyright (C) 2010 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." @@ -453,11 +454,16 @@ ac_need_defaults=: while test $# != 0 do case $1 in - --*=*) + --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; + --*=) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg= + ac_shift=: + ;; *) ac_option=$1 ac_optarg=$2 @@ -479,6 +485,7 @@ do $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; @@ -491,7 +498,7 @@ do ac_need_defaults=false;; --he | --h) # Conflict between --help and --header - as_fn_error "ambiguous option: \`$1' + as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; @@ -500,7 +507,7 @@ Try \`$0 --help' for more information.";; ac_cs_silent=: ;; # This is an error. - -*) as_fn_error "unrecognized option: \`$1' + -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" @@ -587,6 +594,7 @@ do "src/server/module.mk") CONFIG_FILES="$CONFIG_FILES src/server/module.mk" ;; "src/server/request-scheduler/module.mk") CONFIG_FILES="$CONFIG_FILES src/server/request-scheduler/module.mk" ;; "src/client/sysint/module.mk") CONFIG_FILES="$CONFIG_FILES src/client/sysint/module.mk" ;; + "src/client/usrint/module.mk") CONFIG_FILES="$CONFIG_FILES src/client/usrint/module.mk" ;; "src/kernel/linux-2.6/Makefile") CONFIG_FILES="$CONFIG_FILES src/kernel/linux-2.6/Makefile" ;; "src/kernel/linux-2.4/Makefile") CONFIG_FILES="$CONFIG_FILES src/kernel/linux-2.4/Makefile" ;; "doc/module.mk") CONFIG_FILES="$CONFIG_FILES doc/module.mk" ;; @@ -596,7 +604,7 @@ do "examples/pvfs2-server.rc") CONFIG_FILES="$CONFIG_FILES examples/pvfs2-server.rc" ;; "doc/doxygen/pvfs2-doxygen.conf") CONFIG_FILES="$CONFIG_FILES doc/doxygen/pvfs2-doxygen.conf" ;; - *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;; + *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done @@ -618,9 +626,10 @@ fi # after its creation but before its name has been assigned to `$tmp'. $debug || { - tmp= + tmp= ac_tmp= trap 'exit_status=$? - { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status + : "${ac_tmp:=$tmp}" + { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } @@ -628,12 +637,13 @@ $debug || { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && - test -n "$tmp" && test -d "$tmp" + test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") -} || as_fn_error "cannot create a temporary directory in ." "$LINENO" 5 +} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 +ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. @@ -650,13 +660,13 @@ if test "x$ac_cr" = x; then fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then - ac_cs_awk_cr='\r' + ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi -echo 'BEGIN {' >"$tmp/subs1.awk" && -cat >>"$tmp/subs1.awk" <<\_ACAWK && +echo 'BEGIN {' >"$ac_tmp/subs1.awk" && +cat >>"$ac_tmp/subs1.awk" <<\_ACAWK && S["LTLIBOBJS"]="" S["LIBOBJS"]="" S["VISLIBS"]="" @@ -751,10 +761,11 @@ S["build_os"]="linux-gnu" S["build_vendor"]="unknown" S["build_cpu"]="x86_64" S["build"]="x86_64-unknown-linux-gnu" -S["PVFS2_VERSION_SUB"]="4" +S["PVFS2_VERSION_RELEASE"]="orangefs" +S["PVFS2_VERSION_SUB"]="5" S["PVFS2_VERSION_MINOR"]="8" S["PVFS2_VERSION_MAJOR"]="2" -S["PVFS2_VERSION"]="2.8.4-orangefs" +S["PVFS2_VERSION"]="2.8.5-orangefs" S["target_alias"]="" S["host_alias"]="" S["build_alias"]="" @@ -794,7 +805,7 @@ S["PACKAGE_NAME"]="" S["PATH_SEPARATOR"]=":" S["SHELL"]="/bin/bash" _ACAWK -cat >>"$tmp/subs1.awk" <<_ACAWK && +cat >>"$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" @@ -824,15 +835,15 @@ if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat -fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ - || as_fn_error "could not setup config files machinery" "$LINENO" 5 +fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ + || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then -cat >"$tmp/defines.awk" <<\_ACAWK || +cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { D["PACKAGE_NAME"]=" \"\"" D["PACKAGE_TARNAME"]=" \"\"" @@ -842,7 +853,7 @@ D["PACKAGE_BUGREPORT"]=" \"\"" D["PACKAGE_URL"]=" \"\"" D["PVFS2_VERSION_MAJOR"]=" 2" D["PVFS2_VERSION_MINOR"]=" 8" -D["PVFS2_VERSION_SUB"]=" 4" +D["PVFS2_VERSION_SUB"]=" 5" D["STDC_HEADERS"]=" 1" D["HAVE_SYS_TYPES_H"]=" 1" D["HAVE_SYS_STAT_H"]=" 1" @@ -923,7 +934,7 @@ D["HAVE_EXECINFO_H"]=" 1" } { print } _ACAWK - as_fn_error "could not setup config headers machinery" "$LINENO" 5 + as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" @@ -936,7 +947,7 @@ do esac case $ac_mode$ac_tag in :[FHL]*:*);; - :L* | :C*:*) as_fn_error "invalid tag \`$ac_tag'" "$LINENO" 5;; + :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac @@ -955,7 +966,7 @@ do for ac_f do case $ac_f in - -) ac_f="$tmp/stdin";; + -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. @@ -964,7 +975,7 @@ do [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || - as_fn_error "cannot find input file: \`$ac_f'" "$LINENO" 5;; + as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" @@ -990,8 +1001,8 @@ $as_echo "$as_me: creating $ac_file" >&6;} esac case $ac_tag in - *:-:* | *:-) cat >"$tmp/stdin" \ - || as_fn_error "could not create $ac_file" "$LINENO" 5 ;; + *:-:* | *:-) cat >"$ac_tmp/stdin" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac @@ -1091,12 +1102,20 @@ $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir set s&@mandir@&${datarootdir}/man&g s&\${datarootdir}&${prefix}/share&g' ;; esac -ac_sed_extra="/^[ ]*VPATH[ ]*=/{ -s/:*\$(srcdir):*/:/ -s/:*\${srcdir}:*/:/ -s/:*@srcdir@:*/:/ -s/^\([^=]*=[ ]*\):*/\1/ +ac_sed_extra="/^[ ]*VPATH[ ]*=[ ]*/{ +h +s/// +s/^/:/ +s/[ ]*$/:/ +s/:\$(srcdir):/:/g +s/:\${srcdir}:/:/g +s/:@srcdir@:/:/g +s/^:*// s/:*$// +x +s/\(=[ ]*\).*/\1/ +G +s/\n// s/^[^=]*=[ ]*$// } @@ -1115,23 +1134,24 @@ s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t $ac_datarootdir_hack " -eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \ - || as_fn_error "could not create $ac_file" "$LINENO" 5 +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ + >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && - { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && - { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && + { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ + "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined." >&5 +which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined." >&2;} +which seems to be undefined. Please make sure it is defined" >&2;} - rm -f "$tmp/stdin" + rm -f "$ac_tmp/stdin" case $ac_file in - -) cat "$tmp/out" && rm -f "$tmp/out";; - *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; + -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; + *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ - || as_fn_error "could not create $ac_file" "$LINENO" 5 + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # @@ -1140,21 +1160,21 @@ which seems to be undefined. Please make sure it is defined." >&2;} if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ - && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" - } >"$tmp/config.h" \ - || as_fn_error "could not create $ac_file" "$LINENO" 5 - if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" + } >"$ac_tmp/config.h" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" - mv "$tmp/config.h" "$ac_file" \ - || as_fn_error "could not create $ac_file" "$LINENO" 5 + mv "$ac_tmp/config.h" "$ac_file" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ - && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \ - || as_fn_error "could not create -" "$LINENO" 5 + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ + || as_fn_error $? "could not create -" "$LINENO" 5 fi ;; diff --git a/configure b/configure index 3e8091e..9159a5b 100755 --- a/configure +++ b/configure @@ -1,11 +1,11 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.65. +# Generated by GNU Autoconf 2.68. # # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, -# Inc. +# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software +# Foundation, Inc. # # # This configure script is free software; the Free Software Foundation @@ -89,6 +89,7 @@ fi IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. +as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -214,11 +215,18 @@ IFS=$as_save_IFS # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. + # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV export CONFIG_SHELL - exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} + case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; + esac + exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"} fi if test x$as_have_required = xno; then : @@ -316,7 +324,7 @@ $as_echo X"$as_dir" | test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p @@ -356,19 +364,19 @@ else fi # as_fn_arith -# as_fn_error ERROR [LINENO LOG_FD] -# --------------------------------- +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the -# script with status $?, using 1 if that was 0. +# script with STATUS, using 1 if that was 0. as_fn_error () { - as_status=$?; test $as_status -eq 0 && as_status=1 - if test "$3"; then - as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3 + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi - $as_echo "$as_me: error: $1" >&2 + $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error @@ -530,7 +538,7 @@ test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. -# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, +# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` @@ -685,6 +693,7 @@ build_os build_vendor build_cpu build +PVFS2_VERSION_RELEASE PVFS2_VERSION_SUB PVFS2_VERSION_MINOR PVFS2_VERSION_MAJOR @@ -851,8 +860,9 @@ do fi case $ac_option in - *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; - *) ac_optarg=yes ;; + *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *=) ac_optarg= ;; + *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. @@ -897,7 +907,7 @@ do ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error "invalid feature name: $ac_useropt" + as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -923,7 +933,7 @@ do ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error "invalid feature name: $ac_useropt" + as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -1127,7 +1137,7 @@ do ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error "invalid package name: $ac_useropt" + as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -1143,7 +1153,7 @@ do ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error "invalid package name: $ac_useropt" + as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -1173,8 +1183,8 @@ do | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; - -*) as_fn_error "unrecognized option: \`$ac_option' -Try \`$0 --help' for more information." + -*) as_fn_error $? "unrecognized option: \`$ac_option' +Try \`$0 --help' for more information" ;; *=*) @@ -1182,7 +1192,7 @@ Try \`$0 --help' for more information." # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) - as_fn_error "invalid variable name: \`$ac_envvar'" ;; + as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; @@ -1192,7 +1202,7 @@ Try \`$0 --help' for more information." $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 - : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} + : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac @@ -1200,13 +1210,13 @@ done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` - as_fn_error "missing argument to $ac_option" + as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; - fatal) as_fn_error "unrecognized options: $ac_unrecognized_opts" ;; + fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi @@ -1229,7 +1239,7 @@ do [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac - as_fn_error "expected an absolute directory name for --$ac_var: $ac_val" + as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' @@ -1243,8 +1253,8 @@ target=$target_alias if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe - $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. - If a cross compiler is detected then cross compile mode will be used." >&2 + $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host. + If a cross compiler is detected then cross compile mode will be used" >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi @@ -1259,9 +1269,9 @@ test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || - as_fn_error "working directory cannot be determined" + as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || - as_fn_error "pwd does not report name of working directory" + as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. @@ -1300,11 +1310,11 @@ else fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." - as_fn_error "cannot find sources ($ac_unique_file) in $srcdir" + as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( - cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error "$ac_msg" + cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then @@ -1344,7 +1354,7 @@ Configuration: --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit - -q, --quiet, --silent do not print \`checking...' messages + -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files @@ -1554,9 +1564,9 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF configure -generated by GNU Autoconf 2.65 +generated by GNU Autoconf 2.68 -Copyright (C) 2009 Free Software Foundation, Inc. +Copyright (C) 2010 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF @@ -1600,7 +1610,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_compile @@ -1626,7 +1636,7 @@ $as_echo "$ac_try_echo"; } >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } >/dev/null && { + test $ac_status = 0; } > conftest.i && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : @@ -1637,7 +1647,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_cpp @@ -1650,10 +1660,10 @@ fi ac_fn_c_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : + if eval \${$3+:} false; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : +if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 @@ -1689,7 +1699,7 @@ if ac_fn_c_try_cpp "$LINENO"; then : else ac_header_preproc=no fi -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } @@ -1716,7 +1726,7 @@ $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : +if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" @@ -1725,7 +1735,7 @@ eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_mongrel @@ -1766,7 +1776,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_run @@ -1780,7 +1790,7 @@ ac_fn_c_check_header_compile () as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : +if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -1798,7 +1808,7 @@ fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_compile @@ -1975,7 +1985,7 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ rm -f conftest.val fi - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_compute_int @@ -2021,7 +2031,7 @@ fi # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_link @@ -2034,7 +2044,7 @@ ac_fn_c_check_func () as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : +if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -2089,7 +2099,7 @@ fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_func cat >config.log <<_ACEOF @@ -2097,7 +2107,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by $as_me, which was -generated by GNU Autoconf 2.65. Invocation command line was +generated by GNU Autoconf 2.68. Invocation command line was $ $0 $@ @@ -2207,11 +2217,9 @@ trap 'exit_status=$? { echo - cat <<\_ASBOX -## ---------------- ## + $as_echo "## ---------------- ## ## Cache variables. ## -## ---------------- ## -_ASBOX +## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( @@ -2245,11 +2253,9 @@ $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; ) echo - cat <<\_ASBOX -## ----------------- ## + $as_echo "## ----------------- ## ## Output variables. ## -## ----------------- ## -_ASBOX +## ----------------- ##" echo for ac_var in $ac_subst_vars do @@ -2262,11 +2268,9 @@ _ASBOX echo if test -n "$ac_subst_files"; then - cat <<\_ASBOX -## ------------------- ## + $as_echo "## ------------------- ## ## File substitutions. ## -## ------------------- ## -_ASBOX +## ------------------- ##" echo for ac_var in $ac_subst_files do @@ -2280,11 +2284,9 @@ _ASBOX fi if test -s confdefs.h; then - cat <<\_ASBOX -## ----------- ## + $as_echo "## ----------- ## ## confdefs.h. ## -## ----------- ## -_ASBOX +## ----------- ##" echo cat confdefs.h echo @@ -2339,7 +2341,12 @@ _ACEOF ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then - ac_site_file1=$CONFIG_SITE + # We do not want a PATH search for config.site. + case $CONFIG_SITE in #(( + -*) ac_site_file1=./$CONFIG_SITE;; + */*) ac_site_file1=$CONFIG_SITE;; + *) ac_site_file1=./$CONFIG_SITE;; + esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site @@ -2354,7 +2361,11 @@ do { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 - . "$ac_site_file" + . "$ac_site_file" \ + || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "failed to load site script $ac_site_file +See \`config.log' for more details" "$LINENO" 5; } fi done @@ -2430,7 +2441,7 @@ if $ac_cache_corrupted; then $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} - as_fn_error "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 + as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## @@ -2446,16 +2457,22 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_aux_dir= for ac_dir in maint/config "$srcdir"/maint/config; do - for ac_t in install-sh install.sh shtool; do - if test -f "$ac_dir/$ac_t"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/$ac_t -c" - break 2 - fi - done + if test -f "$ac_dir/install-sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f "$ac_dir/install.sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + elif test -f "$ac_dir/shtool"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/shtool install -c" + break + fi done if test -z "$ac_aux_dir"; then - as_fn_error "cannot find install-sh, install.sh, or shtool in maint/config \"$srcdir\"/maint/config" "$LINENO" 5 + as_fn_error $? "cannot find install-sh, install.sh, or shtool in maint/config \"$srcdir\"/maint/config" "$LINENO" 5 fi # These three variables are undocumented and unsupported, @@ -2471,13 +2488,12 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. CONFIGURE_TIME=`date -u +"%Y-%m-%d-%H%M%S"` PVFS2_VERSION_MAJOR=2 PVFS2_VERSION_MINOR=8 -PVFS2_VERSION_SUB=4 +PVFS2_VERSION_SUB=5 PVFS2_VERSION_RELEASE="orangefs" #PVFS2_PRE="" -#PVFS2_VERSION_PRE="-$CONFIGURE_TIME" - -PVFS2_VERSION=$PVFS2_VERSION_MAJOR.$PVFS2_VERSION_MINOR.$PVFS2_VERSION_SUB-$PVFS2_VERSION_RELEASE$PVFS2_VERSION_PRE +#PVFS2_VERSION_PRE="orangefs-$CONFIGURE_TIME" +PVFS2_VERSION=$PVFS2_VERSION_MAJOR.$PVFS2_VERSION_MINOR.$PVFS2_VERSION_SUB-$PVFS2_VERSION_RELEASE cat >>confdefs.h <<_ACEOF @@ -2498,32 +2514,32 @@ _ACEOF -#AC_SUBST(PVFS2_VERSION_RELEASE) + # Make sure we can run config.sub. $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || - as_fn_error "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 + as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 $as_echo_n "checking build system type... " >&6; } -if test "${ac_cv_build+set}" = set; then : +if ${ac_cv_build+:} false; then : $as_echo_n "(cached) " >&6 else ac_build_alias=$build_alias test "x$ac_build_alias" = x && ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` test "x$ac_build_alias" = x && - as_fn_error "cannot guess build type; you must specify one" "$LINENO" 5 + as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || - as_fn_error "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 + as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 $as_echo "$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; -*) as_fn_error "invalid value of canonical build" "$LINENO" 5;; +*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; esac build=$ac_cv_build ac_save_IFS=$IFS; IFS='-' @@ -2541,14 +2557,14 @@ case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 $as_echo_n "checking host system type... " >&6; } -if test "${ac_cv_host+set}" = set; then : +if ${ac_cv_host+:} false; then : $as_echo_n "(cached) " >&6 else if test "x$host_alias" = x; then ac_cv_host=$ac_cv_build else ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || - as_fn_error "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 + as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 fi fi @@ -2556,7 +2572,7 @@ fi $as_echo "$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; -*) as_fn_error "invalid value of canonical host" "$LINENO" 5;; +*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; esac host=$ac_cv_host ac_save_IFS=$IFS; IFS='-' @@ -2591,7 +2607,7 @@ if test -n "$ac_tool_prefix"; then set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : +if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -2631,7 +2647,7 @@ if test -z "$ac_cv_prog_CC"; then set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : +if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then @@ -2684,7 +2700,7 @@ if test -z "$CC"; then set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : +if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -2724,7 +2740,7 @@ if test -z "$CC"; then set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : +if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -2783,7 +2799,7 @@ if test -z "$CC"; then set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : +if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -2827,7 +2843,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : +if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then @@ -2881,8 +2897,8 @@ fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "no acceptable C compiler found in \$PATH -See \`config.log' for more details." "$LINENO" 5; } +as_fn_error $? "no acceptable C compiler found in \$PATH +See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 @@ -2996,9 +3012,8 @@ sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ as_fn_set_status 77 -as_fn_error "C compiler cannot create executables -See \`config.log' for more details." "$LINENO" 5; }; } +as_fn_error 77 "C compiler cannot create executables +See \`config.log' for more details" "$LINENO" 5; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } @@ -3040,8 +3055,8 @@ done else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details." "$LINENO" 5; } +as_fn_error $? "cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 @@ -3098,9 +3113,9 @@ $as_echo "$ac_try_echo"; } >&5 else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "cannot run C compiled programs. +as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. -See \`config.log' for more details." "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5; } fi fi fi @@ -3111,7 +3126,7 @@ rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } -if test "${ac_cv_objext+set}" = set; then : +if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -3151,8 +3166,8 @@ sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "cannot compute suffix of object files: cannot compile -See \`config.log' for more details." "$LINENO" 5; } +as_fn_error $? "cannot compute suffix of object files: cannot compile +See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi @@ -3162,7 +3177,7 @@ OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } -if test "${ac_cv_c_compiler_gnu+set}" = set; then : +if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -3199,7 +3214,7 @@ ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } -if test "${ac_cv_prog_cc_g+set}" = set; then : +if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag @@ -3277,7 +3292,7 @@ else fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } -if test "${ac_cv_prog_cc_c89+set}" = set; then : +if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no @@ -3385,7 +3400,7 @@ if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then - if test "${ac_cv_prog_CPP+set}" = set; then : + if ${ac_cv_prog_CPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded @@ -3415,7 +3430,7 @@ else # Broken: fails on valid input. continue fi -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. @@ -3431,11 +3446,11 @@ else ac_preproc_ok=: break fi -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.err conftest.$ac_ext +rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi @@ -3474,7 +3489,7 @@ else # Broken: fails on valid input. continue fi -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. @@ -3490,18 +3505,18 @@ else ac_preproc_ok=: break fi -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.err conftest.$ac_ext +rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details." "$LINENO" 5; } +as_fn_error $? "C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c @@ -3513,7 +3528,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } -if test "${ac_cv_path_GREP+set}" = set; then : +if ${ac_cv_path_GREP+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then @@ -3562,7 +3577,7 @@ esac done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then - as_fn_error "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP @@ -3576,7 +3591,7 @@ $as_echo "$ac_cv_path_GREP" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } -if test "${ac_cv_path_EGREP+set}" = set; then : +if ${ac_cv_path_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 @@ -3628,7 +3643,7 @@ esac done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then - as_fn_error "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP @@ -3643,7 +3658,7 @@ $as_echo "$ac_cv_path_EGREP" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } -if test "${ac_cv_header_stdc+set}" = set; then : +if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -3760,8 +3775,7 @@ do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " -eval as_val=\$$as_ac_Header - if test "x$as_val" = x""yes; then : +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF @@ -3772,7 +3786,7 @@ done ac_fn_c_check_header_mongrel "$LINENO" "pwd.h" "ac_cv_header_pwd_h" "$ac_includes_default" -if test "x$ac_cv_header_pwd_h" = x""yes; then : +if test "x$ac_cv_header_pwd_h" = xyes; then : $as_echo "#define HAVE_GETPWUID 1" >>confdefs.h @@ -3780,7 +3794,7 @@ fi ac_fn_c_check_header_mongrel "$LINENO" "sys/vfs.h" "ac_cv_header_sys_vfs_h" "$ac_includes_default" -if test "x$ac_cv_header_sys_vfs_h" = x""yes; then : +if test "x$ac_cv_header_sys_vfs_h" = xyes; then : $as_echo "#define HAVE_SYS_VFS_H 1" >>confdefs.h @@ -3788,7 +3802,7 @@ fi ac_fn_c_check_header_mongrel "$LINENO" "sys/mount.h" "ac_cv_header_sys_mount_h" "$ac_includes_default" -if test "x$ac_cv_header_sys_mount_h" = x""yes; then : +if test "x$ac_cv_header_sys_mount_h" = xyes; then : $as_echo "#define HAVE_SYS_MOUNT_H 1" >>confdefs.h @@ -3800,8 +3814,7 @@ for ac_header in mntent.h, fstab.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" -eval as_val=\$$as_ac_Header - if test "x$as_val" = x""yes; then : +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF @@ -3814,7 +3827,7 @@ done for ac_header in stdarg.h do : ac_fn_c_check_header_mongrel "$LINENO" "stdarg.h" "ac_cv_header_stdarg_h" "$ac_includes_default" -if test "x$ac_cv_header_stdarg_h" = x""yes; then : +if test "x$ac_cv_header_stdarg_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STDARG_H 1 _ACEOF @@ -3827,7 +3840,7 @@ done for ac_header in attr/xattr.h do : ac_fn_c_check_header_mongrel "$LINENO" "attr/xattr.h" "ac_cv_header_attr_xattr_h" "$ac_includes_default" -if test "x$ac_cv_header_attr_xattr_h" = x""yes; then : +if test "x$ac_cv_header_attr_xattr_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_ATTR_XATTR_H 1 _ACEOF @@ -3839,7 +3852,7 @@ done for ac_header in sys/xattr.h do : ac_fn_c_check_header_mongrel "$LINENO" "sys/xattr.h" "ac_cv_header_sys_xattr_h" "$ac_includes_default" -if test "x$ac_cv_header_sys_xattr_h" = x""yes; then : +if test "x$ac_cv_header_sys_xattr_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SYS_XATTR_H 1 _ACEOF @@ -3855,7 +3868,7 @@ done # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long int" >&5 $as_echo_n "checking size of long int... " >&6; } -if test "${ac_cv_sizeof_long_int+set}" = set; then : +if ${ac_cv_sizeof_long_int+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long int))" "ac_cv_sizeof_long_int" "$ac_includes_default"; then : @@ -3864,9 +3877,8 @@ else if test "$ac_cv_type_long_int" = yes; then { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ as_fn_set_status 77 -as_fn_error "cannot compute sizeof (long int) -See \`config.log' for more details." "$LINENO" 5; }; } +as_fn_error 77 "cannot compute sizeof (long int) +See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_long_int=0 fi @@ -3901,7 +3913,7 @@ _ACEOF { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 $as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then -if test "${ac_cv_path_install+set}" = set; then : +if ${ac_cv_path_install+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -3987,7 +3999,7 @@ if test -n "$ac_tool_prefix"; then set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : +if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -4027,7 +4039,7 @@ if test -z "$ac_cv_prog_CC"; then set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : +if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then @@ -4080,7 +4092,7 @@ if test -z "$CC"; then set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : +if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -4120,7 +4132,7 @@ if test -z "$CC"; then set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : +if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -4179,7 +4191,7 @@ if test -z "$CC"; then set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : +if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -4223,7 +4235,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : +if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then @@ -4277,8 +4289,8 @@ fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "no acceptable C compiler found in \$PATH -See \`config.log' for more details." "$LINENO" 5; } +as_fn_error $? "no acceptable C compiler found in \$PATH +See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 @@ -4307,7 +4319,7 @@ done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } -if test "${ac_cv_c_compiler_gnu+set}" = set; then : +if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -4344,7 +4356,7 @@ ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } -if test "${ac_cv_prog_cc_g+set}" = set; then : +if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag @@ -4422,7 +4434,7 @@ else fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } -if test "${ac_cv_prog_cc_c89+set}" = set; then : +if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no @@ -4521,7 +4533,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for required gcc" >&5 $as_echo_n "checking for required gcc... " >&6; } if test "x$GCC" = "x"; then - as_fn_error "no" "$LINENO" 5 + as_fn_error $? "no" "$LINENO" 5 fi CFLAGS=$USR_CFLAGS @@ -4538,7 +4550,7 @@ if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then - if test "${ac_cv_prog_CPP+set}" = set; then : + if ${ac_cv_prog_CPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded @@ -4568,7 +4580,7 @@ else # Broken: fails on valid input. continue fi -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. @@ -4584,11 +4596,11 @@ else ac_preproc_ok=: break fi -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.err conftest.$ac_ext +rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi @@ -4627,7 +4639,7 @@ else # Broken: fails on valid input. continue fi -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. @@ -4643,18 +4655,18 @@ else ac_preproc_ok=: break fi -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.err conftest.$ac_ext +rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details." "$LINENO" 5; } +as_fn_error $? "C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c @@ -4667,7 +4679,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu set dummy perl; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_HAVE_PERL+set}" = set; then : +if ${ac_cv_prog_HAVE_PERL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$HAVE_PERL"; then @@ -4701,11 +4713,15 @@ $as_echo "no" >&6; } fi +if test $HAVE_PERL = "no"; then + as_fn_error $? "\"perl required in PATH to complete build\"" "$LINENO" 5 +fi + # Extract the first word of "find", so it can be a program name with args. set dummy find; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_HAVE_FIND+set}" = set; then : +if ${ac_cv_prog_HAVE_FIND+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$HAVE_FIND"; then @@ -4739,11 +4755,15 @@ $as_echo "no" >&6; } fi +if test $HAVE_FIND = "no"; then + as_fn_error $? "\"find required in PATH complete build\"" "$LINENO" 5 +fi + # Extract the first word of "bison", so it can be a program name with args. set dummy bison; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_HAVE_BISON+set}" = set; then : +if ${ac_cv_prog_HAVE_BISON+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$HAVE_BISON"; then @@ -4777,11 +4797,15 @@ $as_echo "no" >&6; } fi +if test $HAVE_BISON = "no"; then + as_fn_error $? "\"bison required in PATH to complete build\"" "$LINENO" 5 +fi + # Extract the first word of "flex", so it can be a program name with args. set dummy flex; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_HAVE_FLEX+set}" = set; then : +if ${ac_cv_prog_HAVE_FLEX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$HAVE_FLEX"; then @@ -4815,13 +4839,15 @@ $as_echo "no" >&6; } fi - +if test $HAVE_FLEX = "no"; then + as_fn_error $? "\"flex required in PATH to complete build\"" "$LINENO" 5 +fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for required Math::BigInt perl module" >&5 $as_echo_n "checking for required Math::BigInt perl module... " >&6; } perl -e "use Math::BigInt" 2>&1 > /dev/null if test $? != 0; then - as_fn_error "no" "$LINENO" 5 + as_fn_error $? "no" "$LINENO" 5 else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } @@ -4834,7 +4860,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_BUILD_CC+set}" = set; then : +if ${ac_cv_prog_BUILD_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$BUILD_CC"; then @@ -4993,7 +5019,7 @@ _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else - as_fn_error "Invalid openssl path specified. No openssl/bio.h found." "$LINENO" 5 + as_fn_error $? "Invalid openssl path specified. No openssl/bio.h found." "$LINENO" 5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext @@ -5012,7 +5038,7 @@ if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else - as_fn_error "could not find openssl libs" "$LINENO" 5 + as_fn_error $? "could not find openssl libs" "$LINENO" 5 fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext @@ -5024,7 +5050,7 @@ $as_echo "#define WITH_OPENSSL 1" >>confdefs.h for ac_header in openssl/evp.h do : ac_fn_c_check_header_mongrel "$LINENO" "openssl/evp.h" "ac_cv_header_openssl_evp_h" "$ac_includes_default" -if test "x$ac_cv_header_openssl_evp_h" = x""yes; then : +if test "x$ac_cv_header_openssl_evp_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_OPENSSL_EVP_H 1 _ACEOF @@ -5036,7 +5062,7 @@ done for ac_header in openssl/crypto.h do : ac_fn_c_check_header_mongrel "$LINENO" "openssl/crypto.h" "ac_cv_header_openssl_crypto_h" "$ac_includes_default" -if test "x$ac_cv_header_openssl_crypto_h" = x""yes; then : +if test "x$ac_cv_header_openssl_crypto_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_OPENSSL_CRYPTO_H 1 _ACEOF @@ -5097,7 +5123,7 @@ rm -f core conftest.err conftest.$ac_objext \ for ac_header in openssl/evp.h do : ac_fn_c_check_header_mongrel "$LINENO" "openssl/evp.h" "ac_cv_header_openssl_evp_h" "$ac_includes_default" -if test "x$ac_cv_header_openssl_evp_h" = x""yes; then : +if test "x$ac_cv_header_openssl_evp_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_OPENSSL_EVP_H 1 _ACEOF @@ -5109,7 +5135,7 @@ done for ac_header in openssl/crypto.h do : ac_fn_c_check_header_mongrel "$LINENO" "openssl/crypto.h" "ac_cv_header_openssl_crypto_h" "$ac_includes_default" -if test "x$ac_cv_header_openssl_crypto_h" = x""yes; then : +if test "x$ac_cv_header_openssl_crypto_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_OPENSSL_CRYPTO_H 1 _ACEOF @@ -5185,7 +5211,7 @@ test_for_karma() set dummy pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_HAVE_PKGCONFIG+set}" = set; then : +if ${ac_cv_prog_HAVE_PKGCONFIG+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$HAVE_PKGCONFIG"; then @@ -5317,7 +5343,7 @@ $as_echo_n "checking for tagged Redhat releases (must patch)... " >&6; } $as_echo "yes" >&6; } if test "$set_redhat24" = 0 || test "$set_nptl_workaround" = 0 ; then - as_fn_error " + as_fn_error $? " You appear to be configuring PVFS2 on a RedHat distribution that likely ships with a heavily modified kernel and c library. You must specify two configure arguments to provide necessary information before @@ -5430,7 +5456,7 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 $as_echo_n "checking whether byte ordering is bigendian... " >&6; } -if test "${ac_cv_c_bigendian+set}" = set; then : +if ${ac_cv_c_bigendian+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_c_bigendian=unknown @@ -5648,7 +5674,7 @@ $as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h ;; #( *) - as_fn_error "unknown endianness + as_fn_error $? "unknown endianness presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;; esac @@ -5659,7 +5685,7 @@ $as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of void *" >&5 $as_echo_n "checking size of void *... " >&6; } -if test "${ac_cv_sizeof_void_p+set}" = set; then : +if ${ac_cv_sizeof_void_p+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (void *))" "ac_cv_sizeof_void_p" "$ac_includes_default"; then : @@ -5668,9 +5694,8 @@ else if test "$ac_cv_type_void_p" = yes; then { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ as_fn_set_status 77 -as_fn_error "cannot compute sizeof (void *) -See \`config.log' for more details." "$LINENO" 5; }; } +as_fn_error 77 "cannot compute sizeof (void *) +See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_void_p=0 fi @@ -5716,14 +5741,14 @@ BUILD_TAU= # Check whether --with-tau was given. if test "${with_tau+set}" = set; then : withval=$with_tau; if test "x$withval" = "xyes" ; then - as_fn_error "--with-tau must be given a pathname" "$LINENO" 5 + as_fn_error $? "--with-tau must be given a pathname" "$LINENO" 5 else TAU_INCS="-I$withval/include" CFLAGS="$CFLAGS $TAU_INCS -D__PVFS2_ENABLE_EVENT__" LDFLAGS="$LDFLAGS -L$withval/$(uname -m)/lib" tau_mkfile=$withval/$(uname -m)/lib/Makefile.*-profile-trace if test ! -f $tau_mkfile; then - as_fn_error "TAU not compiled with profiling and tracing support" "$LINENO" 5 + as_fn_error $? "TAU not compiled with profiling and tracing support" "$LINENO" 5 fi tau_config=$(echo $tau_mkfile | sed -e "s|.*Makefile.tau-||") LIBS="$LIBS -lTAU_tf -lTAU_traceinput-$tau_config -ltau-$tau_config -lpthread -lstdc++" @@ -5745,13 +5770,13 @@ BUILD_KERNEL= # Check whether --with-kernel was given. if test "${with_kernel+set}" = set; then : withval=$with_kernel; if test "x$withval" = "xyes" -o "x$withval" = "x" ; then - as_fn_error "--with-kernel must be given the path to your kernel source." "$LINENO" 5 + as_fn_error $? "--with-kernel must be given the path to your kernel source." "$LINENO" 5 fi if ! test -d $withval ; then - as_fn_error "The --with-kernel path $withval is not a directory." "$LINENO" 5 + as_fn_error $? "The --with-kernel path $withval is not a directory." "$LINENO" 5 fi if ! test -r $withval/include/linux/version.h ; then - as_fn_error "The kernel source tree must have been configured." "$LINENO" 5 + as_fn_error $? "The kernel source tree must have been configured." "$LINENO" 5 fi if test -r $withval/include/linux/version.h && grep -q UTS_RELEASE..2\\.6\\. $withval/include/linux/version.h ; then @@ -5760,8 +5785,11 @@ if test "${with_kernel+set}" = set; then : vers=`sed -n '/UTS_RELEASE/{; s/.*"\(0-9\.0-9\).*".*/\1/; p; }' $withval/include/linux/utsrelease.h` elif test -r $withval/include/generated/utsrelease.h && grep -q UTS_RELEASE..2\\.6\\. $withval/include/generated/utsrelease.h; then vers=`sed -n '/UTS_RELEASE/{; s/.*"\(0-9\.0-9\).*".*/\1/; p; }' $withval/include/generated/utsrelease.h` + elif test -r $withval/include/generated/utsrelease.h && grep -qE UTS_RELEASE..3\\. $withval/include/generated/utsrelease.h; then + vers=`sed -n '/UTS_RELEASE/{; s/.*"\(0-9\.0-9\).*".*/\1/; p; }' $withval/include/generated/utsrelease.h` else - as_fn_error "The kernel source tree does not appear to be 2.6" "$LINENO" 5 + as_fn_error $? "The kernel source tree does not appear to be 2.6 or 3.X" "$LINENO" 5 + fi # At least up through 2.6.3 needed to write .__modpost.cmd; this changed @@ -5780,17 +5808,17 @@ fi # Check whether --with-kernel24 was given. if test "${with_kernel24+set}" = set; then : withval=$with_kernel24; if test "x$withval" = "xyes" -o "x$withval" = "x" ; then - as_fn_error "--with-kernel24 must be given the path to your kernel 2.4.x source." "$LINENO" 5 + as_fn_error $? "--with-kernel24 must be given the path to your kernel 2.4.x source." "$LINENO" 5 fi if ! test -d $withval ; then - as_fn_error "The --with-kernel path $withval is not a directory." "$LINENO" 5 + as_fn_error $? "The --with-kernel path $withval is not a directory." "$LINENO" 5 fi if ! test -r $withval/include/linux/version.h ; then - as_fn_error "The kernel source tree must have been configured." "$LINENO" 5 + as_fn_error $? "The kernel source tree must have been configured." "$LINENO" 5 fi vers=`sed -n '/UTS_RELEASE/{; s/.*"\(0-9\.0-9\).*".*/\1/; p; }' $withval/include/linux/version.h` if ! grep -q UTS_RELEASE..2\\.4\\. $withval/include/linux/version.h ; then - as_fn_error "The kernel source tree does not appear to be 2.4" "$LINENO" 5 + as_fn_error $? "The kernel source tree does not appear to be 2.4" "$LINENO" 5 fi k24_minor_ver=`echo $vers | cut -b 26- | sed -n 's/\"//p' | head -n 1` tmp_k24_minor_ver=`echo $k24_minor_ver | grep \-` @@ -5839,18 +5867,25 @@ if test -n "$lk_src" ; then + NOSTDINCFLAGS="-Werror-implicit-function-declaration -nostdinc -isystem `$CC -print-file-name=include`" - 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)" + if test -d $lk_src/source; then + lk_src_source="$lk_src/source" + else + lk_src_source=$lk_src + fi - if test -f $lk_src/include/generated/autoconf.h ; then + CFLAGS="$USR_CFLAGS $NOSTDINCFLAGS -I$lk_src_source/include -I$lk_src_source/include/asm/mach-default -DKBUILD_STR(s)=#s -DKBUILD_BASENAME=KBUILD_STR(empty) -DKBUILD_MODNAME=KBUILD_STR(empty)" + + if test -f $lk_src/include/generated/autoconf.h ; then CFLAGS="$CFLAGS -imacros $lk_src/include/generated/autoconf.h" else CFLAGS="$CFLAGS -imacros $lk_src/include/linux/autoconf.h" fi if test -n "${ARCH}" ; then - CFLAGS="$CFLAGS -I$lk_src/arch/${ARCH}/include -I$lk_src/arch/${ARCH}/include/asm/mach-default" + CFLAGS="$CFLAGS -I$lk_src_source/arch/${ARCH}/include -I$lk_src_source/arch/${ARCH}/include/asm/mach-default" else SUBARCH=`uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \ -e s/arm.*/arm/ -e s/sa110/arm/ \ @@ -5867,9 +5902,44 @@ if test -n "$lk_src" ; then ARCH=$SUBARCH fi - CFLAGS="$CFLAGS -I$lk_src/arch/${ARCH}/include -I$lk_src/arch/${ARCH}/include/asm/mach-default" + CFLAGS="$CFLAGS -I$lk_src_source/arch/${ARCH}/include -I$lk_src_source/arch/${ARCH}/include/asm/mach-default" + fi + if test "$lk_src" != "$lk_src_source"; then + CFLAGS="$CFLAGS -I$lk_src/include" + fi + + need_optimize_flag=0 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sanity of linux/fs.h include" >&5 +$as_echo_n "checking for sanity of linux/fs.h include... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #define __KERNEL__ + #include + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + need_optimize_flag=1 +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + if test $need_optimize_flag -eq 1; then + CFLAGS="-Os $CFLAGS" + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for i_size_write in kernel" >&5 $as_echo_n "checking for i_size_write in kernel... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -6721,14 +6791,16 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi + CFLAGS="$CFLAGS -Werror" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dentry argument in kernel super_operations statfs" >&5 $as_echo_n "checking for dentry argument in kernel super_operations statfs... " >&6; } - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define __KERNEL__ #include - int vfs_statfs(struct dentry *de, struct kstatfs *kfs) + struct super_operations sop; + int s(struct dentry *de, struct kstatfs *kfs) { return 0; } @@ -6737,6 +6809,8 @@ int main () { + sop.statfs = s; + ; return 0; } @@ -6753,6 +6827,7 @@ $as_echo "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS=$tmp_cflags { $as_echo "$as_me:${as_lineno-$LINENO}: checking for vfsmount argument in kernel file_system_type get_sb" >&5 $as_echo_n "checking for vfsmount argument in kernel file_system_type get_sb... " >&6; } @@ -6788,6 +6863,117 @@ else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for get_sb_nodev" >&5 +$as_echo_n "checking for get_sb_nodev... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #define __KERNEL__ + #include + int v_fill_sb(struct super_block *sb, void *data, int s) + { + return 0; + } + +int +main () +{ + + int ret = 0; + struct super_block *sb = NULL; +#ifdef HAVE_VFSMOUNT_GETSB + ret = get_sb_nodev(NULL, 0, NULL, v_fill_sb, NULL ); +#else + sb = get_sb_nodev(NULL, 0, NULL, v_fill_sb); +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +$as_echo "#define HAVE_GETSB_NODEV 1" >>confdefs.h + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file_system_type get_sb" >&5 +$as_echo_n "checking for file_system_type get_sb... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #define __KERNEL__ + #include + +int +main () +{ + + struct file_system_type f; + f.get_sb = NULL; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +$as_echo "#define HAVE_FSTYPE_GET_SB 1" >>confdefs.h + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file_system_type mount exclusively" >&5 +$as_echo_n "checking for file_system_type mount exclusively... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #define __KERNEL__ + #include + +int +main () +{ + +#ifdef HAVE_FSTYPE_GET_SB + assert(0); +#else + struct file_system_type f; + f.mount = NULL; +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +$as_echo "#define HAVE_FSTYPE_MOUNT_ONLY 1" >>confdefs.h + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext @@ -6953,7 +7139,7 @@ do : #endif " -if test "x$ac_cv_header_linux_posix_acl_h" = x""yes; then : +if test "x$ac_cv_header_linux_posix_acl_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LINUX_POSIX_ACL_H 1 _ACEOF @@ -6972,7 +7158,7 @@ do : #endif " -if test "x$ac_cv_header_linux_posix_acl_xattr_h" = x""yes; then : +if test "x$ac_cv_header_linux_posix_acl_xattr_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LINUX_POSIX_ACL_XATTR_H 1 _ACEOF @@ -6991,7 +7177,7 @@ do : #endif " -if test "x$ac_cv_header_linux_xattr_acl_h" = x""yes; then : +if test "x$ac_cv_header_linux_xattr_acl_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LINUX_XATTR_ACL_H 1 _ACEOF @@ -7007,7 +7193,7 @@ do : #include " -if test "x$ac_cv_header_linux_mount_h" = x""yes; then : +if test "x$ac_cv_header_linux_mount_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LINUX_MOUNT_H 1 _ACEOF @@ -7022,7 +7208,7 @@ do : #include " -if test "x$ac_cv_header_linux_ioctl32_h" = x""yes; then : +if test "x$ac_cv_header_linux_ioctl32_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LINUX_IOCTL32_H 1 _ACEOF @@ -7037,7 +7223,7 @@ do : #include " -if test "x$ac_cv_header_linux_compat_h" = x""yes; then : +if test "x$ac_cv_header_linux_compat_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LINUX_COMPAT_H 1 _ACEOF @@ -7052,7 +7238,7 @@ do : #include " -if test "x$ac_cv_header_linux_syscalls_h" = x""yes; then : +if test "x$ac_cv_header_linux_syscalls_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LINUX_SYSCALLS_H 1 _ACEOF @@ -7067,7 +7253,7 @@ do : #include " -if test "x$ac_cv_header_asm_ioctl32_h" = x""yes; then : +if test "x$ac_cv_header_asm_ioctl32_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_ASM_IOCTL32_H 1 _ACEOF @@ -7082,7 +7268,7 @@ do : #include " -if test "x$ac_cv_header_linux_exportfs_h" = x""yes; then : +if test "x$ac_cv_header_linux_exportfs_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LINUX_EXPORTFS_H 1 _ACEOF @@ -7092,6 +7278,16 @@ fi done + ac_fn_c_check_header_compile "$LINENO" "linux/smp_lock.h" "ac_cv_header_linux_smp_lock_h" "#define __KERNEL__ + #include + +" +if test "x$ac_cv_header_linux_smp_lock_h" = xyes; then : + +fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for generic_file_readv api in kernel" >&5 $as_echo_n "checking for generic_file_readv api in kernel... " >&6; } @@ -7155,6 +7351,40 @@ $as_echo "yes" >&6; } $as_echo "#define HAVE_GENERIC_PERMISSION 1" >>confdefs.h +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + tmp_cflags=$CFLAGS + CFLAGS="$CFLAGS -Werror" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for four-param generic_permission" >&5 +$as_echo_n "checking for four-param generic_permission... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #define __KERNEL__ + #include + struct inode *f; + +int +main () +{ + + generic_permission(f, 0, 0, NULL); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +$as_echo "#define HAVE_FOUR_PARAM_GENERIC_PERMISSION 1" >>confdefs.h + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext @@ -8630,43 +8860,455 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext CFLAGS=$tmp_cflags - CFLAGS=$oldcflags + tmp_cflags=$CFLAGS + CFLAGS="$CFLAGS -Werror" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for unlocked_ioctl in file_operations" >&5 +$as_echo_n "checking for unlocked_ioctl in file_operations... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #define __KERNEL__ + #include + static struct file_operations f; +int +main () +{ + f.unlocked_ioctl = NULL; -$as_echo "#define WITH_LINUX_KMOD 1" >>confdefs.h + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } -fi +$as_echo "#define HAVE_UNLOCKED_IOCTL_HANDLER 1" >>confdefs.h -# 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 +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS=$tmp_cflags + tmp_cflags=$CFLAGS + CFLAGS="$CFLAGS -Werror" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inode_setattr" >&5 +$as_echo_n "checking for inode_setattr... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + #define __KERNEL__ + #include + struct iattr *iattr; + struct inode *inode; + int ret; -BUILD_ABSOLUTE_TOP=`pwd` -SRC_RELATIVE_TOP=`echo $0 | sed -e "s|configure$||"` -SRC_ABSOLUTE_TOP=`cd $SRC_RELATIVE_TOP ; pwd` +int +main () +{ + ret = inode_setattr(inode, iattr); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +$as_echo "#define HAVE_INODE_SETATTR 1" >>confdefs.h +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS=$tmp_cflags + tmp_cflags=$CFLAGS + CFLAGS="$CFLAGS -Werror" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for three-param dentry_operations.d_hash" >&5 +$as_echo_n "checking for three-param dentry_operations.d_hash... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + #define __KERNEL__ + #include + #include + static struct dentry_operations d; + static int d_hash_t(const struct dentry *d, + const struct inode *i, + struct qstr * q) + { return 0; } -# Check whether --enable-fast was given. -if test "${enable_fast+set}" = set; then : - enableval=$enable_fast; -if test "x$USR_CFLAGS_SET" = "xno"; then - CFLAGS="$CFLAGS -DNDEBUG -O3 -DGOSSIP_DISABLE_DEBUG" -fi +int +main () +{ -fi + d.d_hash = d_hash_t; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +$as_echo "#define HAVE_THREE_PARAM_D_HASH 1" >>confdefs.h + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS=$tmp_cflags + + + tmp_cflags=$CFLAGS + CFLAGS="$CFLAGS -Werror" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for seven-param dentry_operations.d_compare" >&5 +$as_echo_n "checking for seven-param dentry_operations.d_compare... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #define __KERNEL__ + #include + #include + static struct dentry_operations d; + static int d_compare_t(const struct dentry *d1, + const struct inode *i1, + const struct dentry *d2, + const struct inode *i2, + unsigned int len, + const char *str, + const struct qstr *qstr) + { return 0; } + +int +main () +{ + + d.d_compare = d_compare_t; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +$as_echo "#define HAVE_SEVEN_PARAM_D_COMPARE 1" >>confdefs.h + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS=$tmp_cflags + + + tmp_cflags=$CFLAGS + CFLAGS="$CFLAGS -Werror" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for constified dentry_operations.d_delete" >&5 +$as_echo_n "checking for constified dentry_operations.d_delete... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #define __KERNEL__ + #include + #include + static struct dentry_operations d; + static int d_delete_t(const struct dentry *d) + { return 0; } + +int +main () +{ + + d.d_delete = d_delete_t; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +$as_echo "#define HAVE_D_DELETE_CONST 1" >>confdefs.h + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS=$tmp_cflags + + tmp_cflags=$CFLAGS + CFLAGS="$CFLAGS -Werror" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dentry.d_count atomic_t type" >&5 +$as_echo_n "checking for dentry.d_count atomic_t type... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #define __KERNEL__ + #include + #include + struct dentry d; + atomic_t x; + +int +main () +{ + + x = d.d_count; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +$as_echo "#define HAVE_DENTRY_D_COUNT_ATOMIC 1" >>confdefs.h + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS=$tmp_cflags + + tmp_cflags=$CFLAGS + CFLAGS="$CFLAGS -Werror" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for three-param inode_operations permission" >&5 +$as_echo_n "checking for three-param inode_operations permission... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #define __KERNEL__ + #include + struct inode_operations i; + int p(struct inode *i, int mode, unsigned int flags) + { return 0; } + +int +main () +{ + + i.permission = p; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +$as_echo "#define HAVE_THREE_PARAM_PERMISSION_WITH_FLAG 1" >>confdefs.h + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS=$tmp_cflags + + tmp_cflags=$CFLAGS + CFLAGS="$CFLAGS -Werror" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for three-param acl_check of generic_permission" >&5 +$as_echo_n "checking for three-param acl_check of generic_permission... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #define __KERNEL__ + #include + struct inode *i; + int p(struct inode *i, int mode, unsigned int flags) + { return 0; } + +int +main () +{ + + generic_permission(i, 0, 0, p); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +$as_echo "#define HAVE_THREE_PARAM_ACL_CHECK 1" >>confdefs.h + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS=$tmp_cflags + + tmp_cflags=$CFLAGS + CFLAGS="$CFLAGS -Werror" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for SPIN_LOCK_UNLOCKED " >&5 +$as_echo_n "checking for SPIN_LOCK_UNLOCKED ... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #define __KERNEL__ + #include + spinlock_t test_lock = SPIN_LOCK_UNLOCKED; + struct inode *i; + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +$as_echo "#define HAVE_SPIN_LOCK_UNLOCKED 1" >>confdefs.h + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS=$tmp_cflags + + tmp_cflags=$CFLAGS + CFLAGS="$CFLAGS -Werror" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for get_sb " >&5 +$as_echo_n "checking for get_sb ... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #define __KERNEL__ + #include + struct file_system_type f; + +int +main () +{ + + f.get_sb = NULL; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +$as_echo "#define HAVE_GET_SB_MEMBER_FILE_SYSTEM_TYPE 1" >>confdefs.h + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dirty_inode flag" >&5 +$as_echo_n "checking for dirty_inode flag... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #define __KERNEL__ + #include + void di(struct inode *i, int f) + { + return; + } + +int +main () +{ + + struct super_operations s; + s.dirty_inode = di; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +$as_echo "#define HAVE_DIRTY_INODE_FLAGS 1" >>confdefs.h + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS=$tmp_cflags + + CFLAGS=$oldcflags + + + +$as_echo "#define WITH_LINUX_KMOD 1" >>confdefs.h + +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=`echo $0 | sed -e "s|configure$||"` +SRC_ABSOLUTE_TOP=`cd $SRC_RELATIVE_TOP ; pwd` + + + + + + + + +# Check whether --enable-fast was given. +if test "${enable_fast+set}" = set; then : + enableval=$enable_fast; +if test "x$USR_CFLAGS_SET" = "xno"; then + CFLAGS="$CFLAGS -DNDEBUG -O3 -DGOSSIP_DISABLE_DEBUG" +fi + +fi test_for_fuse() @@ -8675,7 +9317,7 @@ test_for_fuse() set dummy pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_HAVE_PKGCONFIG+set}" = set; then : +if ${ac_cv_prog_HAVE_PKGCONFIG+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$HAVE_PKGCONFIG"; then @@ -8723,10 +9365,10 @@ $as_echo "yes" >&6; } BUILD_FUSE="1" else - as_fn_error "FUSE: FUSE library not found. Check LD_LIBRARY_PATH." "$LINENO" 5 + as_fn_error $? "FUSE: FUSE library not found. Check LD_LIBRARY_PATH." "$LINENO" 5 fi else - as_fn_error "FUSE: pkg-config not available. Please install pkg-config." "$LINENO" 5 + as_fn_error $? "FUSE: pkg-config not available. Please install pkg-config." "$LINENO" 5 fi } @@ -8772,7 +9414,7 @@ test_for_epoll() for ac_header in sys/epoll.h do : ac_fn_c_check_header_mongrel "$LINENO" "sys/epoll.h" "ac_cv_header_sys_epoll_h" "$ac_includes_default" -if test "x$ac_cv_header_sys_epoll_h" = x""yes; then : +if test "x$ac_cv_header_sys_epoll_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SYS_EPOLL_H 1 _ACEOF @@ -8876,7 +9518,7 @@ fi if test "x$build_shared" = "xno" -a "x$build_static" = "xno" ; then - as_fn_error "Must do --enable-shared or --enable-static or both." "$LINENO" 5 + as_fn_error $? "Must do --enable-shared or --enable-static or both." "$LINENO" 5 fi INTELC= @@ -8925,7 +9567,7 @@ if test "${with_efence+set}" = set; then : fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for malloc in -lefence" >&5 $as_echo_n "checking for malloc in -lefence... " >&6; } -if test "${ac_cv_lib_efence_malloc+set}" = set; then : +if ${ac_cv_lib_efence_malloc+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -8959,7 +9601,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_efence_malloc" >&5 $as_echo "$ac_cv_lib_efence_malloc" >&6; } -if test "x$ac_cv_lib_efence_malloc" = x""yes; then : +if test "x$ac_cv_lib_efence_malloc" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBEFENCE 1 _ACEOF @@ -9070,8 +9712,8 @@ if ac_fn_c_try_compile "$LINENO"; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "Invalid libdb path specified. No db.h found. -See \`config.log' for more details." "$LINENO" 5; } +as_fn_error $? "Invalid libdb path specified. No db.h found. +See \`config.log' for more details" "$LINENO" 5; } fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi @@ -9125,7 +9767,7 @@ rm -f core conftest.err conftest.$ac_objext \ LIBS=$oldlibs if test "x$lib" = "xnotfound" ; then - as_fn_error "could not find DB libraries" "$LINENO" 5 + as_fn_error $? "could not find DB libraries" "$LINENO" 5 else { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lib" >&5 $as_echo "$lib" >&6; } @@ -9424,6 +10066,39 @@ $as_echo "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: checking Berkeley DB version" >&5 +$as_echo_n "checking Berkeley DB version... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #include + +int +main () +{ + + #if DB_VERSION_MAJOR < 4 || \ + (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR < 8) || \ + (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 8 && \ + DB_VERSION_PATCH < 30) + #error "Recommend version of Berkeley DB at least 4.8.30" + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + HAVE_DB_OLD=0 +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + HAVE_DB_OLD=1 + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext CFLAGS="$oldcflags" else @@ -9460,8 +10135,8 @@ if ac_fn_c_try_compile "$LINENO"; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "Invalid libdb path specified. No db.h found. -See \`config.log' for more details." "$LINENO" 5; } +as_fn_error $? "Invalid libdb path specified. No db.h found. +See \`config.log' for more details" "$LINENO" 5; } fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi @@ -9515,7 +10190,7 @@ rm -f core conftest.err conftest.$ac_objext \ LIBS=$oldlibs if test "x$lib" = "xnotfound" ; then - as_fn_error "could not find DB libraries" "$LINENO" 5 + as_fn_error $? "could not find DB libraries" "$LINENO" 5 else { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lib" >&5 $as_echo "$lib" >&6; } @@ -9814,6 +10489,39 @@ $as_echo "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: checking Berkeley DB version" >&5 +$as_echo_n "checking Berkeley DB version... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #include + +int +main () +{ + + #if DB_VERSION_MAJOR < 4 || \ + (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR < 8) || \ + (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 8 && \ + DB_VERSION_PATCH < 30) + #error "Recommend version of Berkeley DB at least 4.8.30" + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + HAVE_DB_OLD=0 +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + HAVE_DB_OLD=1 + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext CFLAGS="$oldcflags" fi @@ -9864,7 +10572,7 @@ if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else - as_fn_error "failed attempting to link lio_listio" "$LINENO" 5 + as_fn_error $? "failed attempting to link lio_listio" "$LINENO" 5 fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext @@ -9897,7 +10605,7 @@ esac for ac_header in netdb.h do : ac_fn_c_check_header_mongrel "$LINENO" "netdb.h" "ac_cv_header_netdb_h" "$ac_includes_default" -if test "x$ac_cv_header_netdb_h" = x""yes; then : +if test "x$ac_cv_header_netdb_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_NETDB_H 1 _ACEOF @@ -9909,7 +10617,7 @@ done for ac_header in arpa/inet.h do : ac_fn_c_check_header_mongrel "$LINENO" "arpa/inet.h" "ac_cv_header_arpa_inet_h" "$ac_includes_default" -if test "x$ac_cv_header_arpa_inet_h" = x""yes; then : +if test "x$ac_cv_header_arpa_inet_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_ARPA_INET_H 1 _ACEOF @@ -9921,7 +10629,7 @@ done for ac_header in sys/socket.h do : ac_fn_c_check_header_mongrel "$LINENO" "sys/socket.h" "ac_cv_header_sys_socket_h" "$ac_includes_default" -if test "x$ac_cv_header_sys_socket_h" = x""yes; then : +if test "x$ac_cv_header_sys_socket_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SYS_SOCKET_H 1 _ACEOF @@ -10003,7 +10711,7 @@ if test "${with_bmi_tcp+set}" = set; then : elif test "$withval" = no ; then BUILD_BMI_TCP= else - as_fn_error "Option --with-tcp requires yes/no argument." "$LINENO" 5 + as_fn_error $? "Option --with-tcp requires yes/no argument." "$LINENO" 5 fi fi @@ -10016,7 +10724,7 @@ fi # Check whether --with-gm was given. if test "${with_gm+set}" = set; then : withval=$with_gm; if test -z "$withval" -o "$withval" = yes ; then - as_fn_error "Option --with-gm requires the path to your GM tree." "$LINENO" 5 + as_fn_error $? "Option --with-gm requires the path to your GM tree." "$LINENO" 5 elif test "$withval" != no ; then gm_home="$withval" fi @@ -10027,7 +10735,7 @@ fi # 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 - as_fn_error "Option --with-gm-includes requires path to GM headers." "$LINENO" 5 + as_fn_error $? "Option --with-gm-includes requires path to GM headers." "$LINENO" 5 elif test "$withval" != no ; then GM_INCDIR="$withval" fi @@ -10038,7 +10746,7 @@ 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 - as_fn_error "Option --with-gm-libs requires path to GM libraries." "$LINENO" 5 + as_fn_error $? "Option --with-gm-libs requires path to GM libraries." "$LINENO" 5 elif test "$withval" != no ; then GM_LIBDIR="$withval" fi @@ -10060,16 +10768,16 @@ fi save_cppflags="$CPPFLAGS" CPPFLAGS="$CPPFLAGS -I$GM_INCDIR -I$GM_INCDIR/gm" ac_fn_c_check_header_mongrel "$LINENO" "gm.h" "ac_cv_header_gm_h" "$ac_includes_default" -if test "x$ac_cv_header_gm_h" = x""yes; then : +if test "x$ac_cv_header_gm_h" = xyes; then : else - as_fn_error "Header gm.h not found." "$LINENO" 5 + as_fn_error $? "Header gm.h not found." "$LINENO" 5 fi if test ! -f $GM_LIBDIR/libgm.so ; then if test ! -f $GM_LIBDIR/libgm.a ; then - as_fn_error "Neither GM library libgm.so or libgm.a found." "$LINENO" 5 + as_fn_error $? "Neither GM library libgm.so or libgm.a found." "$LINENO" 5 fi fi BUILD_GM=1 @@ -10086,7 +10794,7 @@ fi # Check whether --with-mx was given. if test "${with_mx+set}" = set; then : withval=$with_mx; if test -z "$withval" -o "$withval" = yes ; then - as_fn_error "Option --with-mx requires the path to your MX tree." "$LINENO" 5 + as_fn_error $? "Option --with-mx requires the path to your MX tree." "$LINENO" 5 elif test "$withval" != no ; then mx_home="$withval" fi @@ -10097,7 +10805,7 @@ 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 - as_fn_error "Option --with-mx-includes requires path to MX headers." "$LINENO" 5 + as_fn_error $? "Option --with-mx-includes requires path to MX headers." "$LINENO" 5 elif test "$withval" != no ; then MX_INCDIR="$withval" fi @@ -10108,7 +10816,7 @@ 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 - as_fn_error "Option --with-mx-libs requires path to MX libraries." "$LINENO" 5 + as_fn_error $? "Option --with-mx-libs requires path to MX libraries." "$LINENO" 5 elif test "$withval" != no ; then MX_LIBDIR="$withval" fi @@ -10130,16 +10838,16 @@ fi save_cppflags="$CPPFLAGS" CPPFLAGS="$CPPFLAGS -I$MX_INCDIR -I$MX_INCDIR/mx" ac_fn_c_check_header_mongrel "$LINENO" "myriexpress.h" "ac_cv_header_myriexpress_h" "$ac_includes_default" -if test "x$ac_cv_header_myriexpress_h" = x""yes; then : +if test "x$ac_cv_header_myriexpress_h" = xyes; then : else - as_fn_error "Header myriexpress.h not found." "$LINENO" 5 + as_fn_error $? "Header myriexpress.h not found." "$LINENO" 5 fi if test ! -f $MX_LIBDIR/libmyriexpress.so ; then if test ! -f $MX_LIBDIR/libmyriexpress.a ; then - as_fn_error "Neither MX library libmyriexpress.so or libmyriexpress.a found." "$LINENO" 5 + as_fn_error $? "Neither MX library libmyriexpress.so or libmyriexpress.a found." "$LINENO" 5 fi fi BUILD_MX=1 @@ -10182,7 +10890,7 @@ $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } - as_fn_error "Function mx_decompose_endpoint_addr2() not found." "$LINENO" 5 + as_fn_error $? "Function mx_decompose_endpoint_addr2() not found." "$LINENO" 5 fi rm -f core conftest.err conftest.$ac_objext \ @@ -10200,7 +10908,7 @@ rm -f core conftest.err conftest.$ac_objext \ # Check whether --with-ib was given. if test "${with_ib+set}" = set; then : withval=$with_ib; if test -z "$withval" -o "$withval" = yes ; then - as_fn_error "Option --with-ib requires the path to your IB tree." "$LINENO" 5 + as_fn_error $? "Option --with-ib requires the path to your IB tree." "$LINENO" 5 elif test "$withval" != no ; then ib_home="$withval" fi @@ -10211,7 +10919,7 @@ fi # Check whether --with-ib-includes was given. if test "${with_ib_includes+set}" = set; then : withval=$with_ib_includes; if test -z "$withval" -o "$withval" = yes ; then - as_fn_error "Option --with-ib-includes requires path to IB headers." "$LINENO" 5 + as_fn_error $? "Option --with-ib-includes requires path to IB headers." "$LINENO" 5 elif test "$withval" != no ; then IB_INCDIR="$withval" fi @@ -10222,7 +10930,7 @@ fi # Check whether --with-ib-libs was given. if test "${with_ib_libs+set}" = set; then : withval=$with_ib_libs; if test -z "$withval" -o "$withval" = yes ; then - as_fn_error "Option --with-ib-libs requires path to IB libraries." "$LINENO" 5 + as_fn_error $? "Option --with-ib-libs requires path to IB libraries." "$LINENO" 5 elif test "$withval" != no ; then IB_LIBDIR="$withval" fi @@ -10244,22 +10952,22 @@ fi save_cppflags="$CPPFLAGS" CPPFLAGS="$CPPFLAGS -I$IB_INCDIR" ac_fn_c_check_header_mongrel "$LINENO" "vapi.h" "ac_cv_header_vapi_h" "$ac_includes_default" -if test "x$ac_cv_header_vapi_h" = x""yes; then : +if test "x$ac_cv_header_vapi_h" = xyes; then : else - as_fn_error "Header vapi.h not found." "$LINENO" 5 + as_fn_error $? "Header vapi.h not found." "$LINENO" 5 fi if test ! -f $IB_LIBDIR/libvapi.so ; then if test ! -f $IB_LIBDIR/libvapi.a ; then - as_fn_error "Infiniband library libvapi.so not found." "$LINENO" 5 + as_fn_error $? "Infiniband library libvapi.so not found." "$LINENO" 5 fi fi BUILD_IB=1 ac_fn_c_check_header_compile "$LINENO" "wrap_common.h" "ac_cv_header_wrap_common_h" "#include " -if test "x$ac_cv_header_wrap_common_h" = x""yes; then : +if test "x$ac_cv_header_wrap_common_h" = xyes; then : $as_echo "#define HAVE_IB_WRAP_COMMON_H 1" >>confdefs.h @@ -10277,7 +10985,7 @@ fi # Check whether --with-openib was given. if test "${with_openib+set}" = set; then : withval=$with_openib; if test -z "$withval" -o "$withval" = yes ; then - as_fn_error "Option --with-openib requires the path to your OpenIB tree." "$LINENO" 5 + as_fn_error $? "Option --with-openib requires the path to your OpenIB tree." "$LINENO" 5 elif test "$withval" != no ; then openib_home="$withval" fi @@ -10288,7 +10996,7 @@ fi # Check whether --with-openib-includes was given. if test "${with_openib_includes+set}" = set; then : withval=$with_openib_includes; if test -z "$withval" -o "$withval" = yes ; then - as_fn_error "Option --with-openib-includes requires path to OpenIB headers." "$LINENO" 5 + as_fn_error $? "Option --with-openib-includes requires path to OpenIB headers." "$LINENO" 5 elif test "$withval" != no ; then OPENIB_INCDIR="$withval" fi @@ -10299,7 +11007,7 @@ fi # Check whether --with-openib-libs was given. if test "${with_openib_libs+set}" = set; then : withval=$with_openib_libs; if test -z "$withval" -o "$withval" = yes ; then - as_fn_error "Option --with-openib-libs requires path to OpenIB libraries." "$LINENO" 5 + as_fn_error $? "Option --with-openib-libs requires path to OpenIB libraries." "$LINENO" 5 elif test "$withval" != no ; then OPENIB_LIBDIR="$withval" fi @@ -10321,16 +11029,16 @@ fi save_cppflags="$CPPFLAGS" CPPFLAGS="$CPPFLAGS -I$OPENIB_INCDIR" ac_fn_c_check_header_mongrel "$LINENO" "infiniband/verbs.h" "ac_cv_header_infiniband_verbs_h" "$ac_includes_default" -if test "x$ac_cv_header_infiniband_verbs_h" = x""yes; then : +if test "x$ac_cv_header_infiniband_verbs_h" = xyes; then : else - as_fn_error "Header infiniband/verbs.h not found." "$LINENO" 5 + as_fn_error $? "Header infiniband/verbs.h not found." "$LINENO" 5 fi if test ! -f $OPENIB_LIBDIR/libibverbs.so ; then if test ! -f $OPENIB_LIBDIR/libibverbs.a ; then - as_fn_error "OpenIB library libibverbs.so not found." "$LINENO" 5 + as_fn_error $? "OpenIB library libibverbs.so not found." "$LINENO" 5 fi fi BUILD_OPENIB=1 @@ -10430,7 +11138,7 @@ fi # Check whether --with-portals-includes was given. if test "${with_portals_includes+set}" = set; then : withval=$with_portals_includes; if test -z "$withval" -o "$withval" = yes ; then - as_fn_error "Option --with-portals-includes requires an argument." "$LINENO" 5 + as_fn_error $? "Option --with-portals-includes requires an argument." "$LINENO" 5 elif test "$withval" != no ; then incs="$withval" fi @@ -10441,7 +11149,7 @@ fi # Check whether --with-portals-libs was given. if test "${with_portals_libs+set}" = set; then : withval=$with_portals_libs; if test -z "$withval" -o "$withval" = yes ; then - as_fn_error "Option --with-portals-libs requires an argument." "$LINENO" 5 + as_fn_error $? "Option --with-portals-libs requires an argument." "$LINENO" 5 elif test "$withval" != no ; then libs="$withval" fi @@ -10499,7 +11207,7 @@ $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } - as_fn_error "Header portals/portals3.h not found." "$LINENO" 5 + as_fn_error $? "Header portals/portals3.h not found." "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for portals libraries" >&5 @@ -10571,7 +11279,7 @@ $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } - as_fn_error "Could not link Portals library." "$LINENO" 5 + as_fn_error $? "Could not link Portals library." "$LINENO" 5 fi # @@ -10580,7 +11288,7 @@ $as_echo "no" >&6; } for ac_func in PtlErrorStr do : ac_fn_c_check_func "$LINENO" "PtlErrorStr" "ac_cv_func_PtlErrorStr" -if test "x$ac_cv_func_PtlErrorStr" = x""yes; then : +if test "x$ac_cv_func_PtlErrorStr" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_PTLERRORSTR 1 _ACEOF @@ -10591,7 +11299,7 @@ done for ac_func in PtlEventKindStr do : ac_fn_c_check_func "$LINENO" "PtlEventKindStr" "ac_cv_func_PtlEventKindStr" -if test "x$ac_cv_func_PtlEventKindStr" = x""yes; then : +if test "x$ac_cv_func_PtlEventKindStr" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_PTLEVENTKINDSTR 1 _ACEOF @@ -10633,7 +11341,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # Check whether --with-zoid was given. if test "${with_zoid+set}" = set; then : withval=$with_zoid; if test -z "$withval" -o "$withval" = yes ; then - as_fn_error "Option --with-zoid requires the path to your ZOID source tree." "$LINENO" 5 + as_fn_error $? "Option --with-zoid requires the path to your ZOID source tree." "$LINENO" 5 elif test "$withval" != no ; then ZOID_SRCDIR="$withval" fi @@ -10644,26 +11352,26 @@ fi save_cppflags="$CPPFLAGS" CPPFLAGS="$CPPFLAGS -Isrc/io/bmi -I$ZOID_SRCDIR/include -I$ZOID_SRCDIR/zbmi -I$ZOID_SRCDIR/zbmi/implementation" ac_fn_c_check_header_mongrel "$LINENO" "zbmi.h" "ac_cv_header_zbmi_h" "$ac_includes_default" -if test "x$ac_cv_header_zbmi_h" = x""yes; then : +if test "x$ac_cv_header_zbmi_h" = xyes; then : else - as_fn_error "Header zbmi.h not found." "$LINENO" 5 + as_fn_error $? "Header zbmi.h not found." "$LINENO" 5 fi ac_fn_c_check_header_mongrel "$LINENO" "zoid_api.h" "ac_cv_header_zoid_api_h" "$ac_includes_default" -if test "x$ac_cv_header_zoid_api_h" = x""yes; then : +if test "x$ac_cv_header_zoid_api_h" = xyes; then : else - as_fn_error "Header zoid_api.h not found." "$LINENO" 5 + as_fn_error $? "Header zoid_api.h not found." "$LINENO" 5 fi ac_fn_c_check_header_mongrel "$LINENO" "zbmi_protocol.h" "ac_cv_header_zbmi_protocol_h" "$ac_includes_default" -if test "x$ac_cv_header_zbmi_protocol_h" = x""yes; then : +if test "x$ac_cv_header_zbmi_protocol_h" = xyes; then : else - as_fn_error "Header zbmi_protocol.h not found." "$LINENO" 5 + as_fn_error $? "Header zbmi_protocol.h not found." "$LINENO" 5 fi @@ -10711,7 +11419,7 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_fn_c_check_header_mongrel "$LINENO" "sys/sysinfo.h" "ac_cv_header_sys_sysinfo_h" "$ac_includes_default" -if test "x$ac_cv_header_sys_sysinfo_h" = x""yes; then : +if test "x$ac_cv_header_sys_sysinfo_h" = xyes; then : $as_echo "#define HAVE_SYSINFO 1" >>confdefs.h @@ -10723,7 +11431,7 @@ fi for ac_func in strnlen do : ac_fn_c_check_func "$LINENO" "strnlen" "ac_cv_func_strnlen" -if test "x$ac_cv_func_strnlen" = x""yes; then : +if test "x$ac_cv_func_strnlen" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRNLEN 1 _ACEOF @@ -10734,7 +11442,7 @@ done for ac_func in strtoull do : ac_fn_c_check_func "$LINENO" "strtoull" "ac_cv_func_strtoull" -if test "x$ac_cv_func_strtoull" = x""yes; then : +if test "x$ac_cv_func_strtoull" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRTOULL 1 _ACEOF @@ -10745,7 +11453,7 @@ done for ac_func in strstr do : ac_fn_c_check_func "$LINENO" "strstr" "ac_cv_func_strstr" -if test "x$ac_cv_func_strstr" = x""yes; then : +if test "x$ac_cv_func_strstr" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRSTR 1 _ACEOF @@ -10756,7 +11464,7 @@ done for ac_func in fgetxattr do : ac_fn_c_check_func "$LINENO" "fgetxattr" "ac_cv_func_fgetxattr" -if test "x$ac_cv_func_fgetxattr" = x""yes; then : +if test "x$ac_cv_func_fgetxattr" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_FGETXATTR 1 _ACEOF @@ -10767,7 +11475,7 @@ done for ac_func in fsetxattr do : ac_fn_c_check_func "$LINENO" "fsetxattr" "ac_cv_func_fsetxattr" -if test "x$ac_cv_func_fsetxattr" = x""yes; then : +if test "x$ac_cv_func_fsetxattr" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_FSETXATTR 1 _ACEOF @@ -10893,7 +11601,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # -lseq on Dynix/PTX, -lgen on Unixware. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing getmntent" >&5 $as_echo_n "checking for library containing getmntent... " >&6; } -if test "${ac_cv_search_getmntent+set}" = set; then : +if ${ac_cv_search_getmntent+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS @@ -10927,11 +11635,11 @@ for ac_lib in '' sun seq gen; do fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext - if test "${ac_cv_search_getmntent+set}" = set; then : + if ${ac_cv_search_getmntent+:} false; then : break fi done -if test "${ac_cv_search_getmntent+set}" = set; then : +if ${ac_cv_search_getmntent+:} false; then : else ac_cv_search_getmntent=no @@ -10957,7 +11665,7 @@ fi for ac_header in malloc.h do : ac_fn_c_check_header_mongrel "$LINENO" "malloc.h" "ac_cv_header_malloc_h" "$ac_includes_default" -if test "x$ac_cv_header_malloc_h" = x""yes; then : +if test "x$ac_cv_header_malloc_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_MALLOC_H 1 _ACEOF @@ -10969,7 +11677,7 @@ done for ac_header in mntent.h do : ac_fn_c_check_header_mongrel "$LINENO" "mntent.h" "ac_cv_header_mntent_h" "$ac_includes_default" -if test "x$ac_cv_header_mntent_h" = x""yes; then : +if test "x$ac_cv_header_mntent_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_MNTENT_H 1 _ACEOF @@ -10998,7 +11706,7 @@ fi for ac_header in execinfo.h do : ac_fn_c_check_header_mongrel "$LINENO" "execinfo.h" "ac_cv_header_execinfo_h" "$ac_includes_default" -if test "x$ac_cv_header_execinfo_h" = x""yes; then : +if test "x$ac_cv_header_execinfo_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_EXECINFO_H 1 _ACEOF @@ -11024,7 +11732,7 @@ $as_echo "yes" >&6; } for ac_header in SDL_ttf.h do : ac_fn_c_check_header_mongrel "$LINENO" "SDL_ttf.h" "ac_cv_header_SDL_ttf_h" "$ac_includes_default" -if test "x$ac_cv_header_SDL_ttf_h" = x""yes; then : +if test "x$ac_cv_header_SDL_ttf_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SDL_TTF_H 1 _ACEOF @@ -11034,7 +11742,7 @@ else for ac_header in SDL/SDL_ttf.h do : ac_fn_c_check_header_mongrel "$LINENO" "SDL/SDL_ttf.h" "ac_cv_header_SDL_SDL_ttf_h" "$ac_includes_default" -if test "x$ac_cv_header_SDL_SDL_ttf_h" = x""yes; then : +if test "x$ac_cv_header_SDL_SDL_ttf_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SDL_SDL_TTF_H 1 _ACEOF @@ -11092,7 +11800,7 @@ for d in src/apps src/io src/common src/client src/kernel \ install -d $d; done -ac_config_files="$ac_config_files include/pvfs2.h Makefile module.mk src/apps/admin/module.mk src/apps/admin/pvfs2-config src/apps/devel/module.mk src/apps/karma/module.mk src/apps/vis/module.mk src/apps/fuse/module.mk src/apps/kernel/linux/module.mk src/apps/user/module.mk src/io/trove/module.mk src/io/trove/trove-handle-mgmt/module.mk src/io/trove/trove-dbpf/module.mk src/common/misc/module.mk src/common/quickhash/module.mk src/common/quicklist/module.mk src/common/dotconf/module.mk src/common/id-generator/module.mk src/common/gossip/module.mk src/common/gen-locks/module.mk src/common/llist/module.mk src/common/statecomp/module.mk src/common/events/module.mk src/common/mgmt/module.mk src/io/bmi/module.mk src/io/bmi/bmi_tcp/module.mk src/io/bmi/bmi_gm/module.mk src/io/bmi/bmi_mx/module.mk src/io/bmi/bmi_ib/module.mk src/io/bmi/bmi_osd/module.mk src/io/bmi/bmi_portals/module.mk src/io/bmi/bmi_zoid/module.mk src/io/description/module.mk src/io/flow/module.mk src/io/flow/flowproto-bmi-trove/module.mk src/io/flow/flowproto-template/module.mk src/io/flow/flowproto-dump-offsets/module.mk src/io/flow/flowproto-bmi-cache/module.mk src/io/buffer/module.mk src/io/job/module.mk src/io/dev/module.mk src/proto/module.mk src/server/module.mk src/server/request-scheduler/module.mk src/client/sysint/module.mk src/kernel/linux-2.6/Makefile src/kernel/linux-2.4/Makefile doc/module.mk doc/coding/module.mk doc/design/module.mk doc/random/module.mk examples/pvfs2-server.rc doc/doxygen/pvfs2-doxygen.conf" +ac_config_files="$ac_config_files include/pvfs2.h Makefile module.mk src/apps/admin/module.mk src/apps/admin/pvfs2-config src/apps/devel/module.mk src/apps/karma/module.mk src/apps/vis/module.mk src/apps/fuse/module.mk src/apps/kernel/linux/module.mk src/apps/user/module.mk src/io/trove/module.mk src/io/trove/trove-handle-mgmt/module.mk src/io/trove/trove-dbpf/module.mk src/common/misc/module.mk src/common/quickhash/module.mk src/common/quicklist/module.mk src/common/dotconf/module.mk src/common/id-generator/module.mk src/common/gossip/module.mk src/common/gen-locks/module.mk src/common/llist/module.mk src/common/statecomp/module.mk src/common/events/module.mk src/common/mgmt/module.mk src/io/bmi/module.mk src/io/bmi/bmi_tcp/module.mk src/io/bmi/bmi_gm/module.mk src/io/bmi/bmi_mx/module.mk src/io/bmi/bmi_ib/module.mk src/io/bmi/bmi_osd/module.mk src/io/bmi/bmi_portals/module.mk src/io/bmi/bmi_zoid/module.mk src/io/description/module.mk src/io/flow/module.mk src/io/flow/flowproto-bmi-trove/module.mk src/io/flow/flowproto-template/module.mk src/io/flow/flowproto-dump-offsets/module.mk src/io/flow/flowproto-bmi-cache/module.mk src/io/buffer/module.mk src/io/job/module.mk src/io/dev/module.mk src/proto/module.mk src/server/module.mk src/server/request-scheduler/module.mk src/client/sysint/module.mk src/client/usrint/module.mk src/kernel/linux-2.6/Makefile src/kernel/linux-2.4/Makefile doc/module.mk doc/coding/module.mk doc/design/module.mk doc/random/module.mk examples/pvfs2-server.rc doc/doxygen/pvfs2-doxygen.conf" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure @@ -11158,10 +11866,21 @@ $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then - test "x$cache_file" != "x/dev/null" && + if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} - cat confcache >$cache_file + if test ! -f "$cache_file" || test -h "$cache_file"; then + cat confcache >"$cache_file" + else + case $cache_file in #( + */* | ?:*) + mv -f confcache "$cache_file"$$ && + mv -f "$cache_file"$$ "$cache_file" ;; #( + *) + mv -f confcache "$cache_file" ;; + esac + fi + fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} @@ -11177,6 +11896,7 @@ DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= +U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' @@ -11193,7 +11913,7 @@ LTLIBOBJS=$ac_ltlibobjs -: ${CONFIG_STATUS=./config.status} +: "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" @@ -11294,6 +12014,7 @@ fi IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. +as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -11339,19 +12060,19 @@ export LANGUAGE (unset CDPATH) >/dev/null 2>&1 && unset CDPATH -# as_fn_error ERROR [LINENO LOG_FD] -# --------------------------------- +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the -# script with status $?, using 1 if that was 0. +# script with STATUS, using 1 if that was 0. as_fn_error () { - as_status=$?; test $as_status -eq 0 && as_status=1 - if test "$3"; then - as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3 + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi - $as_echo "$as_me: error: $1" >&2 + $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error @@ -11547,7 +12268,7 @@ $as_echo X"$as_dir" | test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p @@ -11601,7 +12322,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # values after options handling. ac_log=" This file was extended by $as_me, which was -generated by GNU Autoconf 2.65. Invocation command line was +generated by GNU Autoconf 2.68. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -11663,10 +12384,10 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ config.status -configured by $0, generated by GNU Autoconf 2.65, +configured by $0, generated by GNU Autoconf 2.68, with options \\"\$ac_cs_config\\" -Copyright (C) 2009 Free Software Foundation, Inc. +Copyright (C) 2010 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." @@ -11682,11 +12403,16 @@ ac_need_defaults=: while test $# != 0 do case $1 in - --*=*) + --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; + --*=) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg= + ac_shift=: + ;; *) ac_option=$1 ac_optarg=$2 @@ -11708,6 +12434,7 @@ do $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; @@ -11720,7 +12447,7 @@ do ac_need_defaults=false;; --he | --h) # Conflict between --help and --header - as_fn_error "ambiguous option: \`$1' + as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; @@ -11729,7 +12456,7 @@ Try \`$0 --help' for more information.";; ac_cs_silent=: ;; # This is an error. - -*) as_fn_error "unrecognized option: \`$1' + -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" @@ -11825,6 +12552,7 @@ do "src/server/module.mk") CONFIG_FILES="$CONFIG_FILES src/server/module.mk" ;; "src/server/request-scheduler/module.mk") CONFIG_FILES="$CONFIG_FILES src/server/request-scheduler/module.mk" ;; "src/client/sysint/module.mk") CONFIG_FILES="$CONFIG_FILES src/client/sysint/module.mk" ;; + "src/client/usrint/module.mk") CONFIG_FILES="$CONFIG_FILES src/client/usrint/module.mk" ;; "src/kernel/linux-2.6/Makefile") CONFIG_FILES="$CONFIG_FILES src/kernel/linux-2.6/Makefile" ;; "src/kernel/linux-2.4/Makefile") CONFIG_FILES="$CONFIG_FILES src/kernel/linux-2.4/Makefile" ;; "doc/module.mk") CONFIG_FILES="$CONFIG_FILES doc/module.mk" ;; @@ -11834,7 +12562,7 @@ do "examples/pvfs2-server.rc") CONFIG_FILES="$CONFIG_FILES examples/pvfs2-server.rc" ;; "doc/doxygen/pvfs2-doxygen.conf") CONFIG_FILES="$CONFIG_FILES doc/doxygen/pvfs2-doxygen.conf" ;; - *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;; + *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done @@ -11856,9 +12584,10 @@ fi # after its creation but before its name has been assigned to `$tmp'. $debug || { - tmp= + tmp= ac_tmp= trap 'exit_status=$? - { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status + : "${ac_tmp:=$tmp}" + { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } @@ -11866,12 +12595,13 @@ $debug || { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && - test -n "$tmp" && test -d "$tmp" + test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") -} || as_fn_error "cannot create a temporary directory in ." "$LINENO" 5 +} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 +ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. @@ -11888,12 +12618,12 @@ if test "x$ac_cr" = x; then fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then - ac_cs_awk_cr='\r' + ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi -echo 'BEGIN {' >"$tmp/subs1.awk" && +echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF @@ -11902,18 +12632,18 @@ _ACEOF echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || - as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 -ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'` + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 +ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || - as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then - as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi @@ -11921,7 +12651,7 @@ done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -cat >>"\$tmp/subs1.awk" <<\\_ACAWK && +cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h @@ -11969,7 +12699,7 @@ t delim rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK -cat >>"\$tmp/subs1.awk" <<_ACAWK && +cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" @@ -12001,21 +12731,29 @@ if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat -fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ - || as_fn_error "could not setup config files machinery" "$LINENO" 5 +fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ + || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF -# VPATH may cause trouble with some makes, so we remove $(srcdir), -# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and +# VPATH may cause trouble with some makes, so we remove sole $(srcdir), +# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=/{ -s/:*\$(srcdir):*/:/ -s/:*\${srcdir}:*/:/ -s/:*@srcdir@:*/:/ -s/^\([^=]*=[ ]*\):*/\1/ + ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ +h +s/// +s/^/:/ +s/[ ]*$/:/ +s/:\$(srcdir):/:/g +s/:\${srcdir}:/:/g +s/:@srcdir@:/:/g +s/^:*// s/:*$// +x +s/\(=[ ]*\).*/\1/ +G +s/\n// s/^[^=]*=[ ]*$// }' fi @@ -12027,7 +12765,7 @@ fi # test -n "$CONFIG_FILES" # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then -cat >"$tmp/defines.awk" <<\_ACAWK || +cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF @@ -12039,11 +12777,11 @@ _ACEOF # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do - ac_t=`sed -n "/$ac_delim/p" confdefs.h` - if test -z "$ac_t"; then + ac_tt=`sed -n "/$ac_delim/p" confdefs.h` + if test -z "$ac_tt"; then break elif $ac_last_try; then - as_fn_error "could not make $CONFIG_HEADERS" "$LINENO" 5 + as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi @@ -12128,7 +12866,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 - as_fn_error "could not setup config headers machinery" "$LINENO" 5 + as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" @@ -12141,7 +12879,7 @@ do esac case $ac_mode$ac_tag in :[FHL]*:*);; - :L* | :C*:*) as_fn_error "invalid tag \`$ac_tag'" "$LINENO" 5;; + :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac @@ -12160,7 +12898,7 @@ do for ac_f do case $ac_f in - -) ac_f="$tmp/stdin";; + -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. @@ -12169,7 +12907,7 @@ do [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || - as_fn_error "cannot find input file: \`$ac_f'" "$LINENO" 5;; + as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" @@ -12195,8 +12933,8 @@ $as_echo "$as_me: creating $ac_file" >&6;} esac case $ac_tag in - *:-:* | *:-) cat >"$tmp/stdin" \ - || as_fn_error "could not create $ac_file" "$LINENO" 5 ;; + *:-:* | *:-) cat >"$ac_tmp/stdin" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac @@ -12326,23 +13064,24 @@ s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t $ac_datarootdir_hack " -eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \ - || as_fn_error "could not create $ac_file" "$LINENO" 5 +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ + >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && - { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && - { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && + { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ + "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined." >&5 +which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined." >&2;} +which seems to be undefined. Please make sure it is defined" >&2;} - rm -f "$tmp/stdin" + rm -f "$ac_tmp/stdin" case $ac_file in - -) cat "$tmp/out" && rm -f "$tmp/out";; - *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; + -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; + *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ - || as_fn_error "could not create $ac_file" "$LINENO" 5 + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # @@ -12351,21 +13090,21 @@ which seems to be undefined. Please make sure it is defined." >&2;} if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ - && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" - } >"$tmp/config.h" \ - || as_fn_error "could not create $ac_file" "$LINENO" 5 - if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" + } >"$ac_tmp/config.h" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" - mv "$tmp/config.h" "$ac_file" \ - || as_fn_error "could not create $ac_file" "$LINENO" 5 + mv "$ac_tmp/config.h" "$ac_file" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ - && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \ - || as_fn_error "could not create -" "$LINENO" 5 + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ + || as_fn_error $? "could not create -" "$LINENO" 5 fi ;; @@ -12380,7 +13119,7 @@ _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || - as_fn_error "write failure creating $CONFIG_STATUS" "$LINENO" 5 + as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. @@ -12401,7 +13140,7 @@ if test "$no_create" != yes; then exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. - $ac_cs_success || as_fn_exit $? + $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 @@ -12466,11 +13205,11 @@ $as_echo "PVFS2 configured to use FUSE : no" >&6; } fi if test "x$LINUX_KERNEL_SRC" = "x" -a "x$BUILD_BMI_ONLY" != "x1"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: PVFS2 configured for the 2.6.x kernel module : no" >&5 -$as_echo "PVFS2 configured for the 2.6.x kernel module : no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: PVFS2 configured for the 2.6/3 kernel module : no" >&5 +$as_echo "PVFS2 configured for the 2.6/3 kernel module : no" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: PVFS2 configured for the 2.6.x kernel module : yes" >&5 -$as_echo "PVFS2 configured for the 2.6.x kernel module : yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: PVFS2 configured for the 2.6/3 kernel module : yes" >&5 +$as_echo "PVFS2 configured for the 2.6/3 kernel module : yes" >&6; } fi if test "x$LINUX24_KERNEL_SRC" = "x" -a "x$BUILD_BMI_ONLY" != "x1"; then @@ -12565,6 +13304,17 @@ $as_echo "$as_me: WARNING: You have selected to build $PKGSTR to use a \"fast\" fi fi +if test x$HAVE_DB_OLD = x1; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: The detected version of Berkeley DB is not at least 4.8.30. + Metadata corruption has been documented in versions prior + to 4.8.30. It is highly recommended that you update the + version of Berkeley DB you are building against." >&5 +$as_echo "$as_me: WARNING: The detected version of Berkeley DB is not at least 4.8.30. + Metadata corruption has been documented in versions prior + to 4.8.30. It is highly recommended that you update the + version of Berkeley DB you are building against." >&2;} +fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: " >&5 $as_echo "" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKGSTR version string: $PVFS2_VERSION" >&5 diff --git a/configure.in b/configure.in index 07c807d..7eec399 100644 --- a/configure.in +++ b/configure.in @@ -18,13 +18,12 @@ dnl An @ in the date string can confuse e.g. scp and 'make kmod' CONFIGURE_TIME=`date -u +"%Y-%m-%d-%H%M%S"` PVFS2_VERSION_MAJOR=2 PVFS2_VERSION_MINOR=8 -PVFS2_VERSION_SUB=4 +PVFS2_VERSION_SUB=5 PVFS2_VERSION_RELEASE="orangefs" #PVFS2_PRE="" -#PVFS2_VERSION_PRE="-$CONFIGURE_TIME" - -PVFS2_VERSION=$PVFS2_VERSION_MAJOR.$PVFS2_VERSION_MINOR.$PVFS2_VERSION_SUB-$PVFS2_VERSION_RELEASE$PVFS2_VERSION_PRE +#PVFS2_VERSION_PRE="orangefs-$CONFIGURE_TIME" +PVFS2_VERSION=$PVFS2_VERSION_MAJOR.$PVFS2_VERSION_MINOR.$PVFS2_VERSION_SUB-$PVFS2_VERSION_RELEASE AC_SUBST(PVFS2_VERSION) AC_DEFINE_UNQUOTED(PVFS2_VERSION_MAJOR, $PVFS2_VERSION_MAJOR, major version number) AC_DEFINE_UNQUOTED(PVFS2_VERSION_MINOR, $PVFS2_VERSION_MINOR, minor version number) @@ -33,7 +32,7 @@ AC_DEFINE_UNQUOTED(PVFS2_VERSION_SUB, $PVFS2_VERSION_SUB, sub version number) AC_SUBST(PVFS2_VERSION_MAJOR) AC_SUBST(PVFS2_VERSION_MINOR) AC_SUBST(PVFS2_VERSION_SUB) -#AC_SUBST(PVFS2_VERSION_RELEASE) +AC_SUBST(PVFS2_VERSION_RELEASE) dnl BMI_ONLY_TAG @@ -77,10 +76,24 @@ CFLAGS=$USR_CFLAGS AC_PROG_CPP AC_CHECK_PROG(HAVE_PERL, perl, yes, no) +if test $HAVE_PERL = "no"; then + AC_MSG_ERROR("perl required in PATH to complete build") +fi + AC_CHECK_PROG(HAVE_FIND, find, yes, no) +if test $HAVE_FIND = "no"; then + AC_MSG_ERROR("find required in PATH complete build") +fi + AC_CHECK_PROG(HAVE_BISON, bison, yes, no) -AC_CHECK_PROG(HAVE_FLEX, flex, yes, no) +if test $HAVE_BISON = "no"; then + AC_MSG_ERROR("bison required in PATH to complete build") +fi +AC_CHECK_PROG(HAVE_FLEX, flex, yes, no) +if test $HAVE_FLEX = "no"; then + AC_MSG_ERROR("flex required in PATH to complete build") +fi AC_MSG_CHECKING([for required Math::BigInt perl module]) perl -e "use Math::BigInt" 2>&1 > /dev/null @@ -520,8 +533,11 @@ AC_ARG_WITH(kernel, vers=`sed -n '/UTS_RELEASE/{; s/.*"\([0-9]\.[0-9]\).*".*/\1/; p; }' $withval/include/linux/utsrelease.h` elif test -r $withval/include/generated/utsrelease.h && grep -q UTS_RELEASE..2\\.6\\. $withval/include/generated/utsrelease.h; then vers=`sed -n '/UTS_RELEASE/{; s/.*"\([0-9]\.[0-9]\).*".*/\1/; p; }' $withval/include/generated/utsrelease.h` + elif test -r $withval/include/generated/utsrelease.h && grep -qE UTS_RELEASE..3\\. $withval/include/generated/utsrelease.h; then + vers=`sed -n '/UTS_RELEASE/{; s/.*"\([0-9]\.[0-9]\).*".*/\1/; p; }' $withval/include/generated/utsrelease.h` else - AC_MSG_ERROR(The kernel source tree does not appear to be 2.6) + AC_MSG_ERROR(The kernel source tree does not appear to be 2.6 or 3.X) + fi # At least up through 2.6.3 needed to write .__modpost.cmd; this changed @@ -1159,6 +1175,7 @@ src/proto/module.mk src/server/module.mk src/server/request-scheduler/module.mk src/client/sysint/module.mk +src/client/usrint/module.mk src/kernel/linux-2.6/Makefile src/kernel/linux-2.4/Makefile doc/module.mk @@ -1212,9 +1229,9 @@ else fi if test "x$LINUX_KERNEL_SRC" = "x" -a "x$BUILD_BMI_ONLY" != "x1"; then - AC_MSG_RESULT([PVFS2 configured for the 2.6.x kernel module : no]) + AC_MSG_RESULT([PVFS2 configured for the 2.6/3 kernel module : no]) else - AC_MSG_RESULT([PVFS2 configured for the 2.6.x kernel module : yes]) + AC_MSG_RESULT([PVFS2 configured for the 2.6/3 kernel module : yes]) fi if test "x$LINUX24_KERNEL_SRC" = "x" -a "x$BUILD_BMI_ONLY" != "x1"; then @@ -1295,6 +1312,13 @@ if test x$BUILD_GM = x1 -o x$BUILD_MX = x1 -o x$BUILD_IB = x1 -o \ fi fi +if test x$HAVE_DB_OLD = x1; then + AC_MSG_WARN([The detected version of Berkeley DB is not at least 4.8.30. + Metadata corruption has been documented in versions prior + to 4.8.30. It is highly recommended that you update the + version of Berkeley DB you are building against.]) +fi + AC_MSG_RESULT() AC_MSG_RESULT([$PKGSTR version string: $PVFS2_VERSION]) diff --git a/doc/design/concepts.tex b/doc/design/concepts.tex index 6991fd1..c4dc70e 100644 --- a/doc/design/concepts.tex +++ b/doc/design/concepts.tex @@ -23,7 +23,7 @@ \begin{document} \maketitle -\begin{verbatim}$Id: concepts.tex,v 1.3 2006/09/13 20:22:43 vilayann Exp $\end{verbatim} +\begin{verbatim}$Id: concepts.tex,v 1.3 2006-09-13 20:22:43 vilayann Exp $\end{verbatim} \section{Introduction} PVFS2 represents a complete redesign and reimplementation of the diff --git a/doc/design/figs/getconfiginit.eps b/doc/design/figs/getconfiginit.eps index 88b5728..47b160b 100644 --- a/doc/design/figs/getconfiginit.eps +++ b/doc/design/figs/getconfiginit.eps @@ -7,7 +7,7 @@ gsave 27 104 translate 0.910714 -0.910714 scale -% $Id: getconfiginit.eps,v 1.1 2003/01/24 23:29:21 pcarns Exp $ +% $Id: getconfiginit.eps,v 1.1 2003-01-24 23:29:21 pcarns Exp $ % Header for DDD PostScript Box output % Copyright (C) 1995-1998 Technische Universitaet Braunschweig, Germany. @@ -406,7 +406,7 @@ setfont 300 75 576 75 576 76 300 76 box* %(300, 75)(276, 1) %%Trailer -% $Id: getconfiginit.eps,v 1.1 2003/01/24 23:29:21 pcarns Exp $ +% $Id: getconfiginit.eps,v 1.1 2003-01-24 23:29:21 pcarns Exp $ % Trailer for DDD PostScript Box output grestore diff --git a/doc/design/figs/getconfigservop.eps b/doc/design/figs/getconfigservop.eps index 238f315..d895677 100644 --- a/doc/design/figs/getconfigservop.eps +++ b/doc/design/figs/getconfigservop.eps @@ -7,7 +7,7 @@ gsave 39 239 translate 0.382309 -0.382309 scale -% $Id: getconfigservop.eps,v 1.1 2003/01/24 23:29:21 pcarns Exp $ +% $Id: getconfigservop.eps,v 1.1 2003-01-24 23:29:21 pcarns Exp $ % Header for DDD PostScript Box output % Copyright (C) 1995-1998 Technische Universitaet Braunschweig, Germany. @@ -649,7 +649,7 @@ setfont 441 530 1341 530 1341 531 441 531 box* %(441, 530)(900, 1) %%Trailer -% $Id: getconfigservop.eps,v 1.1 2003/01/24 23:29:21 pcarns Exp $ +% $Id: getconfigservop.eps,v 1.1 2003-01-24 23:29:21 pcarns Exp $ % Trailer for DDD PostScript Box output grestore diff --git a/doc/design/handle-allocator.tex b/doc/design/handle-allocator.tex index a1a4f95..af9f281 100644 --- a/doc/design/handle-allocator.tex +++ b/doc/design/handle-allocator.tex @@ -21,7 +21,7 @@ \begin{document} \maketitle -\begin{verbatim}$Id: handle-allocator.tex,v 1.1 2003/01/24 23:29:18 pcarns Exp $\end{verbatim} +\begin{verbatim}$Id: handle-allocator.tex,v 1.1 2003-01-24 23:29:18 pcarns Exp $\end{verbatim} \section{Introduction} diff --git a/doc/pvfs2-faq.tex b/doc/pvfs2-faq.tex index 22e0d76..ee4a3ab 100644 --- a/doc/pvfs2-faq.tex +++ b/doc/pvfs2-faq.tex @@ -45,6 +45,97 @@ \subsection{What is PVFS?} allowing for easy inclusion of new hardware support and new algorithms. This makes PVFS a perfect research testbed as well. +\subsection{What is the history of PVFS?} + +PVFS was first developed at Clemson University in 1993 +by Walt Ligon and Eric Blumer as a parallel file system for +Parallel Virtual Machine (PVM). It was developed as part of a +NASA grant to study the I/O patterns of parallel programs. PVFS version +0 was based on Vesta, a parallel file system developed at IBM T. J. +Watson Research Center. Starting in 1994 Rob Ross re-wrote PVFS to +use TCP/IP and departed from many of the original Vesta design points. +PVFS version 1 was targeted to a cluster of DEC Alpha workstations +networked using switched FDDI. Like Vesta, PVFS striped data across +multiple servers and allowed I/O requests based on a file view that +described a strided access pattern. Unlike Vesta, the striping and view +were not dependent on a common record size. Ross' research focused on +scheduling of disk I/O when multiple clients were accessing the same +file. Previous results had show than scheduling according the best +possible disk access pattern was preferable. Ross showed that this +depended on a number of factors including the relative speed of the +network and the details of the file view. In some cases a scheduling +that based on network traffic was preferable, thus a dynamically +adaptable schedule provided the best overall performance. + +In late 1994 Ligon met with Thomas Sterling and John Dorband at Goddard +Space Flight Center (GSFC) and discussed their plans to build the first +Beowulf computer. It was agreed that PVFS would be ported to Linux +and be featured on the new machine. Over the next several years Ligon +and Ross worked with the GSFC group including Donald Becker, Dan Ridge, +and Eric Hendricks. In 1997 at a cluster meeting in Pasadena, CA +Sterling asked that PVFS be released as an open source package. + +In 1999 Ligon proposed the development of a new version of PVFS +initially dubbed PVFS2000 and later PVFS2. The design was initially +developed by Ligon, Ross, and Phil Carns. Ross completed his PhD in 2000 +and moved to Argonne National Laboratory and the design and +implementation was carried out by Ligon, Carns, Dale Witchurch, and +Harish Ramachandran at Clemson University, Ross, Neil Miller, and Rob +Lathrum at Argonne National Laboratory, and Pete Wyckoff at Ohio +Supercomputer Center. The new file system was released in 2003. The +new design featured object servers, distributed metadata, views based on +MPI, support for multiple network types, and a software architecture for +easy experimentation and extensibility. + +PVFS version 1 was retired in 2005. PVFS version 2 is still supported by +Clemson and Argonne. Carns completed his PhD in 2006 and joined Axicom, +Inc. where PVFS was deployed on several thousand nodes for data mining. +In 2008 Carns moved to Argonne and continues to work on PVFS along with +Ross, Latham, and Sam Lang. Brad Settlemyer developed a mirroring +subsystem at Clemson, and later a detailed simulation of PVFS used for +researching new developments. Settlemyer is now at Oak Ridge National +Laboratory. in 2007 Argonne began porting PVFS for use on an IBM Blue +Gene/P. In 2008 Clemson began developing extensions for supporting +large directories of small files, security enhancements, and redundancy +capabilities. As many of these goals conflicted with development for +Blue Gene, a second branch of the CVS source tree was created and dubbed +"Orange" and the original branch was dubbed "Blue." PVFS and OrangeFS +tracked each other very closely, but represent two different groups of +user requirements. + +\subsection{What is OrangeFS?} + +Simply put, OrangeFS is PVFS. OrangeFS is a branch of PVFS created by +the Clemson team PVFS developers to investigate new features and +implementations of PVFS. As of fall 2010 OrangeFS has become the main +branch of PVFS. So why the name change? PVFS was originally conceived +as a research parallel file system and later developed for production on +large high performance machines such as the BG/P at Argonne National +Lab. OrangeFS is taking a slightly different approach to support a +broader range of large and medium systems and a number of issues PVFS +was not concerned with including security, redundancy, and a broader +range of applications. The new name reflects this new focus, but for +now at least, OrangeFS is PVFS. + +The PVFS web site is still maintained. The PVFS mailing lists for +users and developers have not changed and will be used for OrangeFS. +At some point in the future +another group may decide to branch from the main but the PVFS site will +remain the home for the community. + +\subsection{What is Omnibond?} + +Omnibond is a software company that for years has worked with Clemson +University to market software developed at the university. As of fall +2010 Omnibond is offering commercial support for OrangeFS/PVFS. +OrangeFS is open source and will always be free; and the code, as +always, is developed and maintained by the PVFS community. Omnibond is +offering profesional services to those who are intersted in it, and +directly supports the PVFS community. Omnibond offers its customers the +option of dedicated support services and the opportunity to support the +development of new features that they feel are critical. Omnibond gives +back to the community through their support and development. + \subsection{What does the ``V'' in PVFS stand for?} The ``V'' in PVFS stands for virtual. This is a holdover from the original diff --git a/doc/pvfs2-quickstart.tex b/doc/pvfs2-quickstart.tex index d1c325a..59eddd7 100755 --- a/doc/pvfs2-quickstart.tex +++ b/doc/pvfs2-quickstart.tex @@ -64,11 +64,15 @@ \subsection{Dependencies} The following software packages are currently required by PVFS2: \begin{itemize} -\item Berkely DB (version 3 or 4) +\item Berkely DB with development libraries (version 3 or 4) \item aio support (provided by glibc and librt) \item pthreads \item gcc 2.96 or newer (DO NOT USE gcc 2.95! gcc 3.x recommended) \item GNU Make +\item flex +\item bison +\item kernel sources (for client kernel interface) +\item GTK+ (for Karma) \end{itemize} The following software packages are currently recommended for use with PVFS2: @@ -184,16 +188,16 @@ \subsection{Server configuration} root@testhost:~# /usr/bin/pvfs2-genconfig \ /etc/pvfs2-fs.conf ********************************************************************** - Welcome to the PVFS2 Configuration Generator: + Welcome to the PVFS2 Configuration Generator: This interactive script will generate configuration files suitable for use with a new PVFS2 file system. Please see the PVFS2 quickstart guide for details. ********************************************************************** - You must first select the network protocol that your file system will use. -The only currently supported options are "tcp", "gm", and "ib". +The only currently supported options are "tcp", "gm", "mx", "ib", and "portals". +(For multi-homed configurations, use e.g. "ib,tcp".) * Enter protocol type [Default is tcp]: @@ -202,15 +206,26 @@ \subsection{Server configuration} * Enter port number [Default is 3334]: +Choose a directory for each server to store data in. + +* Enter directory name: [Default is /pvfs2-storage-space]: + +Choose a directory for each server to store metadata in. + +* Enter directory name: [Default is /pvfs2-storage-space]: + +Choose a file for each server to write log messages to. + +* Enter log file location [Default is /tmp/pvfs2-server.log]: + Next you must list the hostnames of the machines that will act as I/O servers. Acceptable syntax is "node1, node2, ..." or "node{#-#,#,#}". * Enter hostnames [Default is localhost]: testhost -Now list the hostnames of the machines that will act as Metadata -servers. This list may or may not overlap with the I/O server list. +Use same servers for metadata? (recommended) -* Enter hostnames [Default is localhost]: testhost +* Enter yes or no [Default is yes]: Configured a total of 1 servers: 1 of them are I/O servers. @@ -218,17 +233,7 @@ \subsection{Server configuration} * Would you like to verify server list (y/n) [Default is n]? -Choose a file for each server to write log messages to. - -* Enter log file location [Default is /tmp/pvfs2-server.log]: - -Choose a directory for each server to store data in. - -* Enter directory name: [Default is /pvfs2-storage-space]: - -Writing fs config file... Done. - -Configuration complete! +Writing fs config file... done \end{verbatim} The generated config file will have conservative default values. The PVFS2 @@ -281,11 +286,11 @@ \subsubsection{Automatic server startup and shutdown} \begin{verbatim} bash-2.05b# cp /usr/src/pvfs2/examples/pvfs2-server.rc \ - /etc/rc.d/init.d/pvfs2-server -bash-2.05b# chmod a+x /etc/rc.d/init.d/pvfs2-server + /etc/init.d/pvfs2-server +bash-2.05b# chmod a+x /etc/init.d/pvfs2-server bash-2.05b# chkconfig pvfs2-server on -bash-2.05b# ls -al /etc/rc.d/rc3.d/S35pvfs2-server -lrwxrwxrwx 1 root root 22 Sep 21 13:11 /etc/rc.d/rc3.d/S35pvfs2-server \ +bash-2.05b# ls -al /etc/rc3.d/S35pvfs2-server +lrwxrwxrwx 1 root root 22 Sep 21 13:11 /etc/rc3.d/S35pvfs2-server \ -> ../init.d/pvfs2-server \end{verbatim} @@ -294,14 +299,14 @@ \subsubsection{Automatic server startup and shutdown} To manually start the server, you can run the following command: \begin{verbatim} -bash-2.05b# /etc/rc.d/init.d/pvfs2-server start +bash-2.05b# /etc/init.d/pvfs2-server start Starting PVFS2 server: [ OK ] \end{verbatim} To manually stop the server: \begin{verbatim} -bash-2.05b# /etc/rc.d/init.d/pvfs2-server stop +bash-2.05b# /etc/init.d/pvfs2-server stop Stopping PVFS2 server: [ OK ] \end{verbatim} @@ -554,7 +559,7 @@ \subsection{Server configuration} root@cluster1:~# for i in `seq 1 8`; do > scp /etc/pvfs2-fs.conf cluster\${i}:/etc/ > scp /usr/src/pvfs2/examples/pvfs2-server.rc \ - cluster\${i}:/etc/rc.d/init.d/pvfs2-server + cluster\${i}:/etc/init.d/pvfs2-server > ssh cluster\${i} /sbin/chkconfig pvfs2-server on > done \end{verbatim} diff --git a/include/pvfs2-debug.h b/include/pvfs2-debug.h index 1bcfda8..3309322 100644 --- a/include/pvfs2-debug.h +++ b/include/pvfs2-debug.h @@ -76,7 +76,8 @@ #define GOSSIP_DIRECTIO_DEBUG ((uint64_t)1 << 54) #define GOSSIP_MGMT_DEBUG ((uint64_t)1 << 55) #define GOSSIP_MIRROR_DEBUG ((uint64_t)1 << 56) -#define GOSSIP_BMI_DEBUG_OSD ((uint64_t)1 << 57) +#define GOSSIP_WIN_CLIENT_DEBUG ((uint64_t)1 << 57) +#define GOSSIP_BMI_DEBUG_OSD ((uint64_t)1 << 58) #define GOSSIP_BMI_DEBUG_ALL (uint64_t) \ (GOSSIP_BMI_DEBUG_TCP + GOSSIP_BMI_DEBUG_CONTROL + \ @@ -217,6 +218,8 @@ static __keyword_mask_t s_keyword_mask_map[] = {"directio", GOSSIP_DIRECTIO_DEBUG}, /* Debug mirroring process */ {"mirror",GOSSIP_MIRROR_DEBUG}, + /* Windows client */ + {"win_client", GOSSIP_WIN_CLIENT_DEBUG}, /* Everything except the periodic events. Useful for debugging */ { "verbose", (__DEBUG_ALL & ~(GOSSIP_PERFCOUNTER_DEBUG | GOSSIP_STATE_MACHINE_DEBUG | diff --git a/include/pvfs2-dist-basic.h b/include/pvfs2-dist-basic.h index 6f28539..86132c7 100644 --- a/include/pvfs2-dist-basic.h +++ b/include/pvfs2-dist-basic.h @@ -12,6 +12,9 @@ #define PVFS_DIST_BASIC_NAME_SIZE 11 struct PVFS_basic_params_s { +#ifdef WIN32 + int field; +#endif }; typedef struct PVFS_basic_params_s PVFS_basic_params; diff --git a/include/pvfs2-hint.h b/include/pvfs2-hint.h index b6e457f..8bd54aa 100644 --- a/include/pvfs2-hint.h +++ b/include/pvfs2-hint.h @@ -20,17 +20,15 @@ typedef struct PVFS_hint_s *PVFS_hint; #define PVFS_HINT_NULL NULL -int PVFS_hint_add( - PVFS_hint *hint, - const char *type, - int length, - void *value); - -int PVFS_hint_replace( - PVFS_hint *hint, - const char *type, - int length, - void *value); +int PVFS_hint_add(PVFS_hint *hint, + const char *type, + int length, + void *value); + +int PVFS_hint_replace(PVFS_hint *hint, + const char *type, + int length, + void *value); int PVFS_hint_copy(PVFS_hint old_hint, PVFS_hint *new_hint); diff --git a/include/pvfs2-mgmt.h b/include/pvfs2-mgmt.h index 7961b3f..09b37c8 100644 --- a/include/pvfs2-mgmt.h +++ b/include/pvfs2-mgmt.h @@ -25,6 +25,7 @@ #include "pvfs2-sysint.h" #include "pvfs2-types.h" +#include "pint-uid-mgmt.h" /* non-blocking mgmt operation handle */ typedef PVFS_id_gen_t PVFS_mgmt_op_id; @@ -49,32 +50,29 @@ struct PVFS_mgmt_server_stat }; /* performance monitoring statistics */ -struct PVFS_mgmt_perf_stat + +/* + * defines all of the keys known to PVFS + * performance monitoring subsystem + * keys defined here must also appear + * in the table in src/common/misc/pint-perf-counter.c + * with the same index + */ +enum PINT_server_perf_keys { - int32_t valid_flag; /* is this entry valid? */ - uint32_t id; /* timestep id */ - uint64_t start_time_ms; /* start time of perf set, ms since epoch */ - int64_t write; /* bytes written */ - int64_t read; /* bytes read */ - int64_t metadata_write; /* # of modifying metadata ops */ - int64_t metadata_read; /* # of non-modifying metadata ops */ - int32_t dspace_queue; /* # of metadata dspace ops in the queue */ - int32_t keyval_queue; /* # of metadata keyval ops in the queue */ - int32_t reqsched; /* # of currently scheduled request posted */ + PINT_PERF_READ = 0, /* bytes read */ + PINT_PERF_WRITE = 1, /* bytes written */ + PINT_PERF_METADATA_READ = 2, /* metadata read ops */ + PINT_PERF_METADATA_WRITE = 3, /* metadata write ops */ + PINT_PERF_METADATA_DSPACE_OPS = 4, /* metadata dspace ops */ + PINT_PERF_METADATA_KEYVAL_OPS = 5, /* metadata keyval ops */ + PINT_PERF_REQSCHED = 6, /* instantaneous active requests */ + PINT_PERF_REQUESTS = 7, /* requests received */ + PINT_PERF_SMALL_READ = 8, /* bytes read by small_io */ + PINT_PERF_SMALL_WRITE = 9, /* bytes written by small_io */ + PINT_PERF_FLOW_READ = 10, /* bytes read by flow */ + PINT_PERF_FLOW_WRITE = 11, /* bytes written by flow */ }; -endecode_fields_11_struct( - PVFS_mgmt_perf_stat, - int32_t, valid_flag, - uint32_t, id, - uint64_t, start_time_ms, - int64_t, write, - int64_t, read, - int64_t, metadata_write, - int64_t, metadata_read, - int32_t, dspace_queue, - int32_t, keyval_queue, - int32_t, reqsched, - skip4,); /* low level information about individual server level objects */ struct PVFS_mgmt_dspace_info @@ -227,11 +225,12 @@ PVFS_error PVFS_mgmt_statfs_all( PVFS_error PVFS_imgmt_perf_mon_list( PVFS_fs_id fs_id, PVFS_credentials *credentials, - struct PVFS_mgmt_perf_stat **perf_matrix, + int64_t **perf_matrix, uint64_t *end_time_ms_array, PVFS_BMI_addr_t *addr_array, uint32_t* next_id_array, int server_count, + int *key_count, int history_count, PVFS_error_details *details, PVFS_mgmt_op_id *op_id, @@ -241,11 +240,12 @@ PVFS_error PVFS_imgmt_perf_mon_list( PVFS_error PVFS_mgmt_perf_mon_list( PVFS_fs_id fs_id, PVFS_credentials *credentials, - struct PVFS_mgmt_perf_stat** perf_matrix, + int64_t **perf_matrix, uint64_t *end_time_ms_array, PVFS_BMI_addr_t *addr_array, uint32_t *next_id_array, int server_count, + int *key_count, int history_count, PVFS_error_details *details, PVFS_hint hints); @@ -414,6 +414,30 @@ PVFS_error PVFS_mgmt_map_handle( PVFS_handle handle, PVFS_BMI_addr_t *addr); +PVFS_error PVFS_imgmt_get_uid_list( + PVFS_fs_id fs_id, + PVFS_credentials *credentials, + int server_count, + PVFS_BMI_addr_t *addr_array, + uint32_t history, + PVFS_uid_info_s **uid_info_array, + uint32_t *uid_count, + PVFS_mgmt_op_id *op_id, + PVFS_hint hints, + void *user_ptr); + +PVFS_error PVFS_mgmt_get_uid_list( + PVFS_fs_id fs_id, + PVFS_credentials *credentials, + int server_count, + PVFS_BMI_addr_t *addr_array, + uint32_t history, + PVFS_uid_info_s **uid_info_array, + uint32_t *uid_count, + PVFS_hint hints, + void *user_ptr); + + #endif /* __PVFS2_MGMT_H */ /* @} */ diff --git a/include/pvfs2-sysint.h b/include/pvfs2-sysint.h index 091d11e..b4d10b6 100644 --- a/include/pvfs2-sysint.h +++ b/include/pvfs2-sysint.h @@ -46,11 +46,12 @@ struct PVFS_sys_attr_s PVFS_time mtime; PVFS_time ctime; PVFS_size size; - PVFS2_ALIGN_VAR(char *, link_target);/* NOTE: caller must free if valid */ + PVFS_handle cid; + PVFS2_ALIGN_VAR(char *, link_target);/**< NOTE: caller must free if valid */ PVFS2_ALIGN_VAR(int32_t, dfile_count); /* Changed to int32_t so that size of structure does not change */ PVFS2_ALIGN_VAR(uint32_t, mirror_copies_count); - PVFS2_ALIGN_VAR(char*, dist_name); /* NOTE: caller must free if valid */ - PVFS2_ALIGN_VAR(char*, dist_params); /* NOTE: caller must free if valid */ + PVFS2_ALIGN_VAR(char*, dist_name); /**< NOTE: caller must free if valid */ + PVFS2_ALIGN_VAR(char*, dist_params); /**< NOTE: caller must free if valid */ PVFS_size dirent_count; PVFS_ds_type objtype; PVFS_flags flags; @@ -62,23 +63,20 @@ typedef struct PVFS_sys_attr_s PVFS_sys_attr; /** Describes a PVFS2 file system. */ struct PVFS_sys_mntent { - char **pvfs_config_servers; /* addresses of servers with config info */ - int32_t num_pvfs_config_servers; /* changed to int32_t so that size of structure does not change */ - char *the_pvfs_config_server; /* first of the entries above that works */ - char *pvfs_fs_name; /* name of PVFS2 file system */ - enum PVFS_flowproto_type flowproto; /* flow protocol */ - enum PVFS_encoding_type encoding; /* wire data encoding */ - /* fs id, filled in by system interface when it looks up the fs */ - PVFS_fs_id fs_id; - - /* Default number of dfiles mount option value */ - int32_t default_num_dfiles; /* int32_t for portable, fixed size structure */ - /* Check to determine whether the mount process must perform the integrity checks on the config files */ - int32_t integrity_check; + char **pvfs_config_servers; /**< addresses of servers with config info */ + int32_t num_pvfs_config_servers; /**< changed to int32_t so that size of structure does not change */ + char *the_pvfs_config_server; /**< first of the entries above that works */ + char *pvfs_fs_name; /**< name of PVFS2 file system */ + enum PVFS_flowproto_type flowproto; /**< flow protocol */ + enum PVFS_encoding_type encoding; /**< wire data encoding */ + PVFS_fs_id fs_id; /**< fs id, filled in by system interface when it looks up the fs */ + /* int32_t for portable, fixed size structure */ + int32_t default_num_dfiles; /**< Default number of dfiles mount option value */ + int32_t integrity_check; /**< Check to determine whether the mount process must perform the integrity checks on the config files */ /* the following fields are included for convenience; * useful if the file system is "mounted" */ - char *mnt_dir; /* local mount path */ - char *mnt_opts; /* full option list */ + char *mnt_dir; /**< local mount path */ + char *mnt_opts; /**< full option list */ }; /** Describes file distribution parameters. */ @@ -94,9 +92,14 @@ typedef struct PVFS_sys_dist_s PVFS_sys_dist; /**********************************************************************/ /** Holds results of a lookup operation (reference to object). */ +/* if error_path is passed in NULL then nothing returned on error */ +/* otherwise up to error_path_size chars of unresolved path */ +/* segments are passed out in null terminated string */ struct PVFS_sysresp_lookup_s { PVFS_object_ref ref; + char *error_path; /* on error, the unresolved path segments */ + int error_path_size; /* size of the buffer provided by the user */ }; typedef struct PVFS_sysresp_lookup_s PVFS_sysresp_lookup; @@ -171,7 +174,7 @@ struct PVFS_sysresp_readdirplus_s { PVFS_ds_position token; PVFS_dirent *dirent_array; - uint32_t pvfs_dirent_outcount; /* uint32_t for portable, fixed size structure */ + uint32_t pvfs_dirent_outcount; /**< uint32_t for portable, fixed size structure */ uint64_t directory_version; PVFS_error *stat_err_array; PVFS_sys_attr *attr_array; @@ -455,9 +458,11 @@ PVFS_error PVFS_isys_io( PVFS_hint hints, void *user_ptr); +/** Macro for convenience read is a call to io */ #define PVFS_isys_read(x1,x2,x3,x4,x5,x6,y,x7,x8,x9) \ PVFS_isys_io(x1,x2,x3,x4,x5,x6,y,PVFS_IO_READ,x7,x8,x9) +/** Macro for convenience write is a call to io */ #define PVFS_isys_write(x1,x2,x3,x4,x5,x6,y,x7,x8,x9) \ PVFS_isys_io(x1,x2,x3,x4,x5,x6,y,PVFS_IO_WRITE,x7,x8,x9) @@ -472,9 +477,11 @@ PVFS_error PVFS_sys_io( enum PVFS_io_type type, PVFS_hint hints); +/** Macro for convenience read is a call to io */ #define PVFS_sys_read(x1,x2,x3,x4,x5,x6,y,z) \ PVFS_sys_io(x1,x2,x3,x4,x5,x6,y,PVFS_IO_READ,z) +/** Macro for convenience write is a call to io */ #define PVFS_sys_write(x1,x2,x3,x4,x5,x6,y,z) \ PVFS_sys_io(x1,x2,x3,x4,x5,x6,y,PVFS_IO_WRITE,z) diff --git a/include/pvfs2-types.h b/include/pvfs2-types.h index dfb87a8..cb13e24 100644 --- a/include/pvfs2-types.h +++ b/include/pvfs2-types.h @@ -18,7 +18,11 @@ #else #include #include +#ifdef WIN32 +#include "wincommon.h" +#else #include +#endif #include #include #endif @@ -31,6 +35,9 @@ #ifndef NAME_MAX #define NAME_MAX 255 #endif +#ifndef PATH_MAX +#define PATH_MAX 4096 +#endif /* figure out the size of a pointer */ #if defined(__WORDSIZE) @@ -43,6 +50,10 @@ #elif INTPTR_MIN == INT64_MIN #define PVFS2_SIZEOF_VOIDP 64 #endif +#elif defined(_WIN64) + #define PVFS2_SIZEOF_VOIDP 64 +#elif defined(WIN32) + #define PVFS2_SIZEOF_VOIDP 32 #else #error "Unhandled size of void pointer" #endif @@ -72,9 +83,16 @@ typedef int64_t PVFS_id_gen_t; /** Opaque value representing a destination address. */ typedef int64_t PVFS_BMI_addr_t; +/* Windows - inline functions can't be exported */ +#ifdef WIN32 +void encode_PVFS_BMI_addr_t(char **pptr, const PVFS_BMI_addr_t *x); +int encode_PVFS_BMI_addr_t_size_check(const PVFS_BMI_addr_t *x); +void decode_PVFS_BMI_addr_t(char **pptr, PVFS_BMI_addr_t *x); +#else inline void encode_PVFS_BMI_addr_t(char **pptr, const PVFS_BMI_addr_t *x); inline int encode_PVFS_BMI_addr_t_size_check(const PVFS_BMI_addr_t *x); inline void decode_PVFS_BMI_addr_t(char **pptr, PVFS_BMI_addr_t *x); +#endif #define encode_PVFS_error encode_int32_t #define decode_PVFS_error decode_int32_t @@ -145,10 +163,13 @@ typedef uint32_t PVFS_gid; typedef uint64_t PVFS_time; typedef uint32_t PVFS_permissions; typedef uint64_t PVFS_flags; +typedef uint64_t PVFS_cid; #define encode_PVFS_uid encode_uint32_t #define decode_PVFS_uid decode_uint32_t #define encode_PVFS_gid encode_uint32_t #define decode_PVFS_gid decode_uint32_t +#define encode_PVFS_cid encode_uint64_t +#define decode_PVFS_cid decode_uint64_t #define encode_PVFS_time encode_int64_t #define decode_PVFS_time decode_int64_t #define encode_PVFS_permissions encode_uint32_t @@ -225,8 +246,13 @@ typedef struct PVFS_sys_layout_s } PVFS_sys_layout; #define extra_size_PVFS_sys_layout PVFS_REQ_LIMIT_LAYOUT +#ifdef WIN32 +void encode_PVFS_sys_layout(char **pptr, const struct PVFS_sys_layout_s *x); +void decode_PVFS_sys_layout(char **pptr, struct PVFS_sys_layout_s *x); +#else inline void encode_PVFS_sys_layout(char **pptr, const struct PVFS_sys_layout_s *x); inline void decode_PVFS_sys_layout(char **pptr, struct PVFS_sys_layout_s *x); +#endif /* predefined special values for types */ #define PVFS_CONTEXT_NULL ((PVFS_context_id)-1) @@ -396,11 +422,12 @@ typedef struct #define PVFS_ATTR_SYS_TYPE (1 << 6) #define PVFS_ATTR_SYS_ATIME_SET (1 << 7) #define PVFS_ATTR_SYS_MTIME_SET (1 << 8) +#define PVFS_ATTR_SYS_CID (1 << 9) #define PVFS_ATTR_SYS_COMMON_ALL \ (PVFS_ATTR_SYS_UID | PVFS_ATTR_SYS_GID | \ PVFS_ATTR_SYS_PERM | PVFS_ATTR_SYS_ATIME | \ PVFS_ATTR_SYS_CTIME | PVFS_ATTR_SYS_MTIME | \ - PVFS_ATTR_SYS_TYPE) + PVFS_ATTR_SYS_TYPE | PVFS_ATTR_SYS_CID) #define PVFS_ATTR_SYS_ALL \ (PVFS_ATTR_SYS_COMMON_ALL | PVFS_ATTR_SYS_SIZE | \ @@ -463,12 +490,16 @@ typedef struct { PVFS_handle handle; PVFS_fs_id fs_id; + uint64_t cid; int32_t __pad1; } PVFS_object_ref; /** Credentials (stubbed for future authentication methods). */ typedef struct { +#ifdef WIN32 + /* TODO - store username string? */ +#endif PVFS_uid uid; PVFS_gid gid; } PVFS_credentials; @@ -483,6 +514,9 @@ endecode_fields_2( #define PVFS_NAME_MAX 256 /* max len of individual path element */ #define PVFS_SEGMENT_MAX PVFS_NAME_MAX +/* max len of an entire path */ +/* note protocol only handles a segment, not a path */ +#define PVFS_PATH_MAX 4096 /* max extended attribute name len as imposed by the VFS and exploited for the * upcall request types. @@ -497,7 +531,7 @@ endecode_fields_2( by */ #define PVFS_MAX_XATTR_VALUELEN 8192 /* Not the same as XATTR_SIZE_MAX defined by */ -#define PVFS_MAX_XATTR_LISTLEN 8 /* Not the same as XATTR_LIST_MAX +#define PVFS_MAX_XATTR_LISTLEN 16 /* Not the same as XATTR_LIST_MAX defined by */ /* This structure is used by the VFS-client interaction alone */ @@ -595,6 +629,8 @@ typedef struct { int PVFS_strerror_r(int errnum, char *buf, int n); void PVFS_perror(const char *text, int retcode); void PVFS_perror_gossip(const char* text, int retcode); +void PVFS_perror_gossip_silent(void); +void PVFS_perror_gossip_verbose(void); PVFS_error PVFS_get_errno_mapping(PVFS_error error); PVFS_error PVFS_errno_to_error(int err); @@ -700,6 +736,7 @@ PVFS_error PVFS_errno_to_error(int err); #define PVFS_EADDRNTFD (5|(PVFS_NON_ERRNO_ERROR_BIT|PVFS_ERROR_BIT)) #define PVFS_ENORECVR (6|(PVFS_NON_ERRNO_ERROR_BIT|PVFS_ERROR_BIT)) #define PVFS_ETRYAGAIN (7|(PVFS_NON_ERRNO_ERROR_BIT|PVFS_ERROR_BIT)) +#define PVFS_ENOTPVFS (8|(PVFS_NON_ERRNO_ERROR_BIT|PVFS_ERROR_BIT)) /* NOTE: PLEASE DO NOT ARBITRARILY ADD NEW ERRNO ERROR CODES! * @@ -820,6 +857,7 @@ const char *PINT_non_errno_strerror_mapping[] = { \ "No address associated with name", \ "Unknown server error", \ "Host name lookup failure", \ + "Path contains non-PVFS elements", \ }; \ PVFS_error PINT_non_errno_mapping[] = { \ 0, /* leave this one empty */ \ @@ -830,6 +868,7 @@ PVFS_error PINT_non_errno_mapping[] = { \ PVFS_EADDRNTFD, /* 5 */ \ PVFS_ENORECVR, /* 6 */ \ PVFS_ETRYAGAIN, /* 7 */ \ + PVFS_ENOTPVFS, /* 8 */ \ } /* diff --git a/include/pvfs2-util.h b/include/pvfs2-util.h index 84f54bc..ff314c0 100644 --- a/include/pvfs2-util.h +++ b/include/pvfs2-util.h @@ -73,6 +73,11 @@ int PVFS_util_resolve( PVFS_fs_id* out_fs_id, char* out_fs_path, int out_fs_path_max); +int PVFS_util_resolve_absolute( + const char* local_path, + PVFS_fs_id* out_fs_id, + char* out_fs_path, + int out_fs_path_max); int PVFS_util_get_default_fsid( PVFS_fs_id* out_fs_id); diff --git a/include/pvfs2.h b/include/pvfs2.h index 12f9e29..d15b23b 100644 --- a/include/pvfs2.h +++ b/include/pvfs2.h @@ -15,7 +15,7 @@ #ifndef PVFS2_VERSION_MAJOR #define PVFS2_VERSION_MAJOR 2 #define PVFS2_VERSION_MINOR 8 -#define PVFS2_VERSION_SUB 4 +#define PVFS2_VERSION_SUB 5 #endif #include "pvfs2-types.h" diff --git a/maint/config/bdb.m4 b/maint/config/bdb.m4 index 9e17735..239e0f1 100644 --- a/maint/config/bdb.m4 +++ b/maint/config/bdb.m4 @@ -231,5 +231,24 @@ AC_DEFUN([AX_BERKELEY_DB], AC_DEFINE(HAVE_DB_GET_PAGESIZE, 1, [Define if DB has get_pagesize function]), AC_MSG_RESULT(no)) + dnl Check BDB version here since it's just a warning + AC_MSG_CHECKING([Berkeley DB version]) + AC_TRY_COMPILE( + [ + #include + ], + [ + #if DB_VERSION_MAJOR < 4 || \ + (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR < 8) || \ + (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 8 && \ + DB_VERSION_PATCH < 30) + #error "Recommend version of Berkeley DB at least 4.8.30" + #endif + ], + AC_MSG_RESULT(yes) + HAVE_DB_OLD=0, + AC_MSG_RESULT(no) + HAVE_DB_OLD=1 + ) CFLAGS="$oldcflags" ]) diff --git a/maint/config/kernel.m4 b/maint/config/kernel.m4 index 51e00e1..e2780d4 100644 --- a/maint/config/kernel.m4 +++ b/maint/config/kernel.m4 @@ -13,11 +13,30 @@ AC_DEFUN([AX_KERNEL_FEATURES], dnl 'implicit function declaration' usually ends up in an undefined dnl symbol somewhere. + dnl opensuse11.2 32bit only reports the correct include path when in + dnl specific directories, must be some search path broken-ness? + dnl switching to / fixes the problem and shouldn't break others + NOSTDINCFLAGS="-Werror-implicit-function-declaration -nostdinc -isystem `$CC -print-file-name=include`" - 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)" + dnl SuSE and other distros that have a separate kernel obj directory + dnl need to have include files from both the obj directory and the + dnl full source listed in the includes. Kbuild handles this when + dnl compiling but the configure checks don't handle this on their own. + dnl The strategy here is just to set a new variable, lk_src_source, + dnl when the provided kernel source has a source directory. If it + dnl doesn't exist just set it lk_src. There may be a cleaner way to do + dnl this, for now, this appears to do the trick. + if test -d $lk_src/source; then + lk_src_source="$lk_src/source" + else + lk_src_source=$lk_src + fi + + CFLAGS="$USR_CFLAGS $NOSTDINCFLAGS -I$lk_src_source/include -I$lk_src_source/include/asm/mach-default -DKBUILD_STR(s)=#s -DKBUILD_BASENAME=KBUILD_STR(empty) -DKBUILD_MODNAME=KBUILD_STR(empty)" dnl kernels > 2.6.32 now use generated/autoconf.h + dnl look in lk_src for the generated autoconf.h if test -f $lk_src/include/generated/autoconf.h ; then CFLAGS="$CFLAGS -imacros $lk_src/include/generated/autoconf.h" else @@ -27,7 +46,7 @@ AC_DEFUN([AX_KERNEL_FEATURES], 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 -I$lk_src/arch/${ARCH}/include/asm/mach-default" + CFLAGS="$CFLAGS -I$lk_src_source/arch/${ARCH}/include -I$lk_src_source/arch/${ARCH}/include/asm/mach-default" else SUBARCH=`uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \ -e s/arm.*/arm/ -e s/sa110/arm/ \ @@ -44,8 +63,33 @@ AC_DEFUN([AX_KERNEL_FEATURES], ARCH=$SUBARCH fi - CFLAGS="$CFLAGS -I$lk_src/arch/${ARCH}/include -I$lk_src/arch/${ARCH}/include/asm/mach-default" + CFLAGS="$CFLAGS -I$lk_src_source/arch/${ARCH}/include -I$lk_src_source/arch/${ARCH}/include/asm/mach-default" + fi + + dnl if there are two different include paths (lk_src/include and + dnl lk_src_source/include) add the lk_src/include path to the CFLAGS + dnl here. + if test "$lk_src" != "$lk_src_source"; then + CFLAGS="$CFLAGS -I$lk_src/include" + fi + + dnl in 2.6.40 (maybe .39 too) inclusion of linux/fs.h breaks unless + dnl optimization flag of some sort is set. To complicate matters + dnl checks in earlier versions break when optimization is turned on. + need_optimize_flag=0 + AC_MSG_CHECKING(for sanity of linux/fs.h include) + AC_TRY_COMPILE([ + #define __KERNEL__ + #include + ], [], + AC_MSG_RESULT(yes), + AC_MSG_RESULT(no) + need_optimize_flag=1, + ) + if test $need_optimize_flag -eq 1; then + CFLAGS="-Os $CFLAGS" + fi AC_MSG_CHECKING(for i_size_write in kernel) dnl if this test passes, the kernel does not have it @@ -453,6 +497,7 @@ AC_DEFUN([AX_KERNEL_FEATURES], fi + CFLAGS="$CFLAGS -Werror" AC_MSG_CHECKING(for dentry argument in kernel super_operations statfs) dnl Rely on the fact that there is an external vfs_statfs that is dnl of the same type as the .statfs in struct super_operations to @@ -468,18 +513,28 @@ AC_DEFUN([AX_KERNEL_FEATURES], dnl If this test passes, the kernel uses a struct dentry argument. dnl If this test fails, the kernel uses something else (old struct dnl super_block perhaps). + dnl + dnl Need to use the second approach because vfs_statfs changes without + dnl a cooresponding change in statfs in super_operations. I'm not that + dnl concerned with reliance on Werror since we use it heavily + dnl throughout these checks AC_TRY_COMPILE([ #define __KERNEL__ #include - int vfs_statfs(struct dentry *de, struct kstatfs *kfs) + struct super_operations sop; + int s(struct dentry *de, struct kstatfs *kfs) { return 0; } - ], [], + ], + [ + sop.statfs = s; + ], AC_MSG_RESULT(yes) AC_DEFINE(HAVE_DENTRY_STATFS_SOP, 1, Define if super_operations statfs has dentry argument), AC_MSG_RESULT(no) ) + CFLAGS=$tmp_cflags AC_MSG_CHECKING(for vfsmount argument in kernel file_system_type get_sb) dnl Same trick as above. A single commit changed mayn things at once: @@ -508,6 +563,63 @@ AC_DEFUN([AX_KERNEL_FEATURES], AC_MSG_RESULT(no) ) + AC_MSG_CHECKING(for get_sb_nodev) + AC_TRY_COMPILE([ + #define __KERNEL__ + #include + int v_fill_sb(struct super_block *sb, void *data, int s) + { + return 0; + } + ], + [ + int ret = 0; + struct super_block *sb = NULL; +#ifdef HAVE_VFSMOUNT_GETSB + ret = get_sb_nodev(NULL, 0, NULL, v_fill_sb, NULL ); +#else + sb = get_sb_nodev(NULL, 0, NULL, v_fill_sb); +#endif + ], + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_GETSB_NODEV, 1, Define if get_sb_nodev function exists ), + AC_MSG_RESULT(no) + ) + + AC_MSG_CHECKING(for file_system_type get_sb) + AC_TRY_COMPILE([ + #define __KERNEL__ + #include + ], + [ + struct file_system_type f; + f.get_sb = NULL; + ], + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_FSTYPE_GET_SB, 1, Define if only filesystem_type has get_sb), + AC_MSG_RESULT(no) + ) + + + + AC_MSG_CHECKING(for file_system_type mount exclusively) + AC_TRY_COMPILE([ + #define __KERNEL__ + #include + ], + [ +#ifdef HAVE_FSTYPE_GET_SB + assert(0); +#else + struct file_system_type f; + f.mount = NULL; +#endif + ], + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_FSTYPE_MOUNT_ONLY, 1, Define if only filesystem_type has mount and HAVE_FSTYPE_GET_SB is false), + AC_MSG_RESULT(no) + ) + AC_MSG_CHECKING(for xattr support in kernel) dnl if this test passes, the kernel has it dnl if this test fails, the kernel does not have it @@ -660,6 +772,12 @@ AC_DEFUN([AX_KERNEL_FEATURES], #include ]) + dnl no bkl, no need for smp_lock.h + AC_CHECK_HEADER([linux/smp_lock.h], [], [], + [#define __KERNEL__ + #include + ]) + AC_MSG_CHECKING(for generic_file_readv api in kernel) dnl if this test passes, the kernel does not have it dnl if this test fails, the kernel has it defined with a different @@ -698,6 +816,24 @@ AC_DEFUN([AX_KERNEL_FEATURES], AC_DEFINE(HAVE_GENERIC_PERMISSION, 1, Define if kernel has generic_permission), ) + dnl generic_permission in 2.6.38 and newer has a four parameter + dnl signature + tmp_cflags=$CFLAGS + CFLAGS="$CFLAGS -Werror" + AC_MSG_CHECKING(for four-param generic_permission) + AC_TRY_COMPILE([ + #define __KERNEL__ + #include + struct inode *f; + ], + [ + generic_permission(f, 0, 0, NULL); + ], + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_FOUR_PARAM_GENERIC_PERMISSION, 1, [Define if generic_permission takes four parameters]), + AC_MSG_RESULT(no) + ) + AC_MSG_CHECKING(for generic_getxattr api in kernel) dnl if this test passes, the kernel does not have it dnl if this test fails, the kernel has it defined @@ -1425,6 +1561,238 @@ AC_DEFUN([AX_KERNEL_FEATURES], ) CFLAGS=$tmp_cflags + dnl file_operations has unlocked_ioctl instead of ioctl as of 2.6.36 + tmp_cflags=$CFLAGS + CFLAGS="$CFLAGS -Werror" + AC_MSG_CHECKING(for unlocked_ioctl in file_operations) + AC_TRY_COMPILE([ + #define __KERNEL__ + #include + static struct file_operations f; + ], + [ + f.unlocked_ioctl = NULL; + ], + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_UNLOCKED_IOCTL_HANDLER, 1, [Define if file_operations struct has unlocked_ioctl member]), + AC_MSG_RESULT(no) + ) + CFLAGS=$tmp_cflags + + dnl 2.6.36 removed inode_setattr with the other BKL removal changes + tmp_cflags=$CFLAGS + CFLAGS="$CFLAGS -Werror" + AC_MSG_CHECKING(for inode_setattr) + AC_TRY_COMPILE([ + #define __KERNEL__ + #include + struct iattr *iattr; + struct inode *inode; + int ret; + ], + [ + ret = inode_setattr(inode, iattr); + ], + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_INODE_SETATTR, 1, [Define if inode_setattr is defined]), + AC_MSG_RESULT(no) + ) + CFLAGS=$tmp_cflags + + dnl dentry operations struct d_hash function has a different signature + dnl in 2.6.38 and newer, second param is an inode + tmp_cflags=$CFLAGS + CFLAGS="$CFLAGS -Werror" + AC_MSG_CHECKING(for three-param dentry_operations.d_hash) + AC_TRY_COMPILE([ + #define __KERNEL__ + #include + #include + static struct dentry_operations d; + static int d_hash_t(const struct dentry *d, + const struct inode *i, + struct qstr * q) + { return 0; } + ], + [ + d.d_hash = d_hash_t; + ], + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_THREE_PARAM_D_HASH, 1, [Define if d_hash member of dentry_operations has three params, the second inode paramsbeing the difference]), + AC_MSG_RESULT(no) + ) + CFLAGS=$tmp_cflags + + + dnl dentry operations struct d_compare function has a different + dnl signature in 2.6.38 and newer, split out dentry/inodes, string and + dnl qstr params + tmp_cflags=$CFLAGS + CFLAGS="$CFLAGS -Werror" + AC_MSG_CHECKING(for seven-param dentry_operations.d_compare) + AC_TRY_COMPILE([ + #define __KERNEL__ + #include + #include + static struct dentry_operations d; + static int d_compare_t(const struct dentry *d1, + const struct inode *i1, + const struct dentry *d2, + const struct inode *i2, + unsigned int len, + const char *str, + const struct qstr *qstr) + { return 0; } + ], + [ + d.d_compare = d_compare_t; + ], + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_SEVEN_PARAM_D_COMPARE, 1, [Define if d_compare member of dentry_operations has seven params]), + AC_MSG_RESULT(no) + ) + CFLAGS=$tmp_cflags + + + dnl dentry operations struct d_delete argumentis constified in + dnl 2.6.38 and newer + tmp_cflags=$CFLAGS + CFLAGS="$CFLAGS -Werror" + AC_MSG_CHECKING(for constified dentry_operations.d_delete) + AC_TRY_COMPILE([ + #define __KERNEL__ + #include + #include + static struct dentry_operations d; + static int d_delete_t(const struct dentry *d) + { return 0; } + ], + [ + d.d_delete = d_delete_t; + ], + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_D_DELETE_CONST, 1, [Define if d_delete member of dentry_operations has a const dentry param]), + AC_MSG_RESULT(no) + ) + CFLAGS=$tmp_cflags + + dnl dentry member d_count is no longer atomic and has it's own spinlock + dnl in 2.6.38 and newer + tmp_cflags=$CFLAGS + CFLAGS="$CFLAGS -Werror" + AC_MSG_CHECKING(for dentry.d_count atomic_t type) + AC_TRY_COMPILE([ + #define __KERNEL__ + #include + #include + struct dentry d; + atomic_t x; + ], + [ + x = d.d_count; + ], + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_DENTRY_D_COUNT_ATOMIC, 1, [Define if d_count member of dentry is of type atomic_t]), + AC_MSG_RESULT(no) + ) + CFLAGS=$tmp_cflags + + dnl permission function pointer in the inode_operations struct now + dnl takes three params with the third being an unsigned int (circa + dnl 2.6.38 + tmp_cflags=$CFLAGS + CFLAGS="$CFLAGS -Werror" + AC_MSG_CHECKING(for three-param inode_operations permission) + AC_TRY_COMPILE([ + #define __KERNEL__ + #include + struct inode_operations i; + int p(struct inode *i, int mode, unsigned int flags) + { return 0; } + ], + [ + i.permission = p; + ], + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_THREE_PARAM_PERMISSION_WITH_FLAG, 1, [Define if permission function pointer of inode_operations struct has three parameters and the third parameter is for flags (unsigned int)]), + AC_MSG_RESULT(no) + ) + CFLAGS=$tmp_cflags + + dnl the acl_check parameter of the generic_permission function has a + dnl third parameter circa 2.6.38 + tmp_cflags=$CFLAGS + CFLAGS="$CFLAGS -Werror" + AC_MSG_CHECKING(for three-param acl_check of generic_permission) + AC_TRY_COMPILE([ + #define __KERNEL__ + #include + struct inode *i; + int p(struct inode *i, int mode, unsigned int flags) + { return 0; } + ], + [ + generic_permission(i, 0, 0, p); + ], + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_THREE_PARAM_ACL_CHECK, 1, [Define if acl_check param of generic_permission function has three parameters]), + AC_MSG_RESULT(no) + ) + CFLAGS=$tmp_cflags + + dnl SPIN_LOCK_UNLOCKED has gone away in 2.6.39 in lieu of + dnl DEFINE_SPINLOCK() + tmp_cflags=$CFLAGS + CFLAGS="$CFLAGS -Werror" + AC_MSG_CHECKING(for SPIN_LOCK_UNLOCKED ) + AC_TRY_COMPILE([ + #define __KERNEL__ + #include + spinlock_t test_lock = SPIN_LOCK_UNLOCKED; + struct inode *i; + ], [ ], + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_SPIN_LOCK_UNLOCKED, 1, [Define if SPIN_LOCK_UNLOCKED defined]), + AC_MSG_RESULT(no) + ) + CFLAGS=$tmp_cflags + + dnl get_sb goes away in 2.6.39 for mount_X + tmp_cflags=$CFLAGS + CFLAGS="$CFLAGS -Werror" + AC_MSG_CHECKING(for get_sb ) + AC_TRY_COMPILE([ + #define __KERNEL__ + #include + struct file_system_type f; + ], + [ + f.get_sb = NULL; + ], + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_GET_SB_MEMBER_FILE_SYSTEM_TYPE, 1, [Define if get_sb is a member of file_system_type struct]), + AC_MSG_RESULT(no) + ) + + AC_MSG_CHECKING(for dirty_inode flag) + AC_TRY_COMPILE([ + #define __KERNEL__ + #include + void di(struct inode *i, int f) + { + return; + } + ], + [ + struct super_operations s; + s.dirty_inode = di; + ], + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_DIRTY_INODE_FLAGS, 1, Define if dirty_inode takes a flag argument ), + AC_MSG_RESULT(no) + ) + CFLAGS=$tmp_cflags + CFLAGS=$oldcflags ]) diff --git a/pvfs2-config.h.in b/pvfs2-config.h.in index 084bfd3..23113e5 100644 --- a/pvfs2-config.h.in +++ b/pvfs2-config.h.in @@ -73,15 +73,24 @@ /* Define if DB has get_pagesize function */ #undef HAVE_DB_GET_PAGESIZE +/* Define if d_count member of dentry is of type atomic_t */ +#undef HAVE_DENTRY_D_COUNT_ATOMIC + /* Define if super_operations statfs has dentry argument */ #undef HAVE_DENTRY_STATFS_SOP +/* Define if dirty_inode takes a flag argument */ +#undef HAVE_DIRTY_INODE_FLAGS + /* Define if kernel super_operations contains drop_inode field */ #undef HAVE_DROP_INODE /* Define if dcache.h contains d_alloc_annon */ #undef HAVE_D_ALLOC_ANON +/* Define if d_delete member of dentry_operations has a const dentry param */ +#undef HAVE_D_DELETE_CONST + /* Define if export_operations has an encode_fh member */ #undef HAVE_ENCODEFH_EXPORT_OPERATIONS @@ -107,6 +116,9 @@ */ #undef HAVE_FIND_INODE_HANDLE_SUPER_OPERATIONS +/* Define if generic_permission takes four parameters */ +#undef HAVE_FOUR_PARAM_GENERIC_PERMISSION + /* Define to 1 if you have the `fsetxattr' function. */ #undef HAVE_FSETXATTR @@ -116,6 +128,12 @@ /* Define to 1 if you have the header file. */ #undef HAVE_FSTAB_H +/* Define if only filesystem_type has get_sb */ +#undef HAVE_FSTYPE_GET_SB + +/* Define if only filesystem_type has mount and HAVE_FSTYPE_GET_SB is false */ +#undef HAVE_FSTYPE_MOUNT_ONLY + /* Define if fsync function in file_operations struct wants a dentry pointer as the second parameter */ #undef HAVE_FSYNC_DENTRY_PARAM @@ -144,9 +162,15 @@ /* Define if pwd.h exists */ #undef HAVE_GETPWUID +/* Define if get_sb_nodev function exists */ +#undef HAVE_GETSB_NODEV + /* Define if struct super_operations in kernel has get_fs_key callback */ #undef HAVE_GET_FS_KEY_SUPER_OPERATIONS +/* Define if get_sb is a member of file_system_type struct */ +#undef HAVE_GET_SB_MEMBER_FILE_SYSTEM_TYPE + /* Define if strerror_r is GNU-specific */ #undef HAVE_GNU_STRERROR_R @@ -168,6 +192,9 @@ /* Define if kernel has iget_locked */ #undef HAVE_IGET_LOCKED +/* Define if inode_setattr is defined */ +#undef HAVE_INODE_SETATTR + /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H @@ -341,6 +368,9 @@ /* Define if kernel setxattr has const void* argument */ #undef HAVE_SETXATTR_CONST_ARG +/* Define if d_compare member of dentry_operations has seven params */ +#undef HAVE_SEVEN_PARAM_D_COMPARE + /* Define if SLAB_KERNEL is defined in kernel */ #undef HAVE_SLAB_KERNEL @@ -352,6 +382,9 @@ tree_lock */ #undef HAVE_SPIN_LOCK_TREE_ADDR_SPACE_STRUCT +/* Define if SPIN_LOCK_UNLOCKED defined */ +#undef HAVE_SPIN_LOCK_UNLOCKED + /* Define if struct super_operations in kernel has statfs_lite callback */ #undef HAVE_STATFS_LITE_SUPER_OPERATIONS @@ -415,6 +448,18 @@ /* Define if TAU library is used */ #undef HAVE_TAU +/* Define if acl_check param of generic_permission function has three + parameters */ +#undef HAVE_THREE_PARAM_ACL_CHECK + +/* Define if d_hash member of dentry_operations has three params, the second + inode paramsbeing the difference */ +#undef HAVE_THREE_PARAM_D_HASH + +/* Define if permission function pointer of inode_operations struct has three + parameters and the third parameter is for flags (unsigned int) */ +#undef HAVE_THREE_PARAM_PERMISSION_WITH_FLAG + /* Define if kernel stddef has true/false enum */ #undef HAVE_TRUE_FALSE_ENUM @@ -437,6 +482,9 @@ /* Define if DB stat function takes malloc function ptr */ #undef HAVE_UNKNOWN_PARAMETER_TO_DB_STAT +/* Define if file_operations struct has unlocked_ioctl member */ +#undef HAVE_UNLOCKED_IOCTL_HANDLER + /* Define if include file valgrind.h exists */ #undef HAVE_VALGRIND_H diff --git a/src/apps/admin/module.mk.in b/src/apps/admin/module.mk.in index 32124c3..5bec602 100644 --- a/src/apps/admin/module.mk.in +++ b/src/apps/admin/module.mk.in @@ -12,6 +12,7 @@ ADMINSRC := \ $(DIR)/pvfs2-stat.c \ $(DIR)/pvfs2-statfs.c \ $(DIR)/pvfs2-perf-mon-example.c \ + $(DIR)/pvfs2-perf-mon-snmp.c \ $(DIR)/pvfs2-mkdir.c \ $(DIR)/pvfs2-chmod.c \ $(DIR)/pvfs2-chown.c \ @@ -26,7 +27,9 @@ ADMINSRC := \ $(DIR)/pvfs2-ln.c \ $(DIR)/pvfs2-perror.c \ $(DIR)/pvfs2-check-server.c \ - $(DIR)/pvfs2-drop-caches.c + $(DIR)/pvfs2-drop-caches.c +#don't build in 2.8.5 release +# $(DIR)/pvfs2-get-uid.c ADMINSRC_SERVER := \ $(DIR)/pvfs2-mkspace.c \ diff --git a/src/apps/admin/pvfs2-config.in b/src/apps/admin/pvfs2-config.in index ed50b04..a77800f 100755 --- a/src/apps/admin/pvfs2-config.in +++ b/src/apps/admin/pvfs2-config.in @@ -65,7 +65,7 @@ while test $# -gt 0; do echo $libflags ;; --serverlibs|--static-serverlibs) - libflags="-L@libdir@ -lpthread -lpvfs2-server @LIBS@ @DB_LIB@" + libflags="-L@libdir@ -lpvfs2-server -lpthread @LIBS@ @DB_LIB@" if [ x"@NEEDS_LIBRT@" = x"1" ]; then libflags="$libflags -lrt" fi diff --git a/src/apps/admin/pvfs2-cp.c b/src/apps/admin/pvfs2-cp.c index 0c9eb56..b274c8c 100644 --- a/src/apps/admin/pvfs2-cp.c +++ b/src/apps/admin/pvfs2-cp.c @@ -51,8 +51,8 @@ enum open_type { typedef struct pvfs2_file_object_s { PVFS_fs_id fs_id; PVFS_object_ref ref; - char pvfs2_path[PVFS_NAME_MAX]; - char user_path[PVFS_NAME_MAX]; + char pvfs2_path[PVFS_NAME_MAX+1]; + char user_path[PVFS_NAME_MAX+1]; PVFS_sys_attr attr; PVFS_permissions perms; } pvfs2_file_object; @@ -60,7 +60,7 @@ typedef struct pvfs2_file_object_s { typedef struct unix_file_object_s { int fd; int mode; - char path[NAME_MAX]; + char path[NAME_MAX+1]; } unix_file_object; typedef struct file_object_s { @@ -149,7 +149,7 @@ int main (int argc, char ** argv) resolve_filename(&dest, user_opts->destfile); PVFS_util_gen_credentials(&credentials); - + ret = generic_open(&src, &credentials, 0, 0, NULL, OPEN_SRC); if (ret < 0) { @@ -183,7 +183,6 @@ int main (int argc, char ** argv) ret = generic_write(&dest, buffer, total_written, buffer_size, &credentials); - if (ret != current_size) { if (ret == -1) { diff --git a/src/apps/admin/pvfs2-event-mon-example.c b/src/apps/admin/pvfs2-event-mon-example.c index a98bac4..ecf257a 100644 --- a/src/apps/admin/pvfs2-event-mon-example.c +++ b/src/apps/admin/pvfs2-event-mon-example.c @@ -48,16 +48,16 @@ int main(int argc, char **argv) user_opts = parse_args(argc, argv); if (!user_opts) { - fprintf(stderr, "Error: failed to parse command line arguments.\n"); - usage(argc, argv); - return -1; + fprintf(stderr, "Error: failed to parse command line arguments.\n"); + usage(argc, argv); + return -1; } ret = PVFS_util_init_defaults(); if(ret < 0) { - PVFS_perror("PVFS_util_init_defaults", ret); - return(-1); + PVFS_perror("PVFS_util_init_defaults", ret); + return(-1); } /* translate local path into pvfs2 relative path */ @@ -65,95 +65,95 @@ int main(int argc, char **argv) &cur_fs, pvfs_path, PVFS_NAME_MAX); if(ret < 0) { - PVFS_perror("PVFS_util_resolve", ret); - return -1; + PVFS_perror("PVFS_util_resolve", ret); + return -1; } PVFS_util_gen_credentials(&creds); /* count how many I/O servers we have */ ret = PVFS_mgmt_count_servers(cur_fs, - &creds, - PVFS_MGMT_IO_SERVER, - &io_server_count); + &creds, + PVFS_MGMT_IO_SERVER, + &io_server_count); if (ret < 0) { - PVFS_perror("PVFS_mgmt_count_servers", ret); - return -1; + PVFS_perror("PVFS_mgmt_count_servers", ret); + return -1; } /* allocate a 2 dimensional array for events */ event_matrix = (struct PVFS_mgmt_event **) - malloc(io_server_count * sizeof(struct PVFS_mgmt_event *)); + malloc(io_server_count * sizeof(struct PVFS_mgmt_event *)); if (event_matrix == NULL) { - perror("malloc"); - return -1; + perror("malloc"); + return -1; } for (i=0; i < io_server_count; i++) { - event_matrix[i] = (struct PVFS_mgmt_event *) - malloc(EVENT_DEPTH * sizeof(struct PVFS_mgmt_event)); - if (event_matrix[i] == NULL) - { - perror("malloc"); - return -1; - } + event_matrix[i] = (struct PVFS_mgmt_event *) + malloc(EVENT_DEPTH * sizeof(struct PVFS_mgmt_event)); + if (event_matrix[i] == NULL) + { + perror("malloc"); + return -1; + } } /* build a list of servers to talk to */ addr_array = (PVFS_BMI_addr_t *) - malloc(io_server_count * sizeof(PVFS_BMI_addr_t)); + malloc(io_server_count * sizeof(PVFS_BMI_addr_t)); if (addr_array == NULL) { - perror("malloc"); - return -1; + perror("malloc"); + return -1; } ret = PVFS_mgmt_get_server_array(cur_fs, - &creds, - PVFS_MGMT_IO_SERVER, - addr_array, - &io_server_count); + &creds, + PVFS_MGMT_IO_SERVER, + addr_array, + &io_server_count); if (ret < 0) { - PVFS_perror("PVFS_mgmt_get_server_array", ret); - return -1; + PVFS_perror("PVFS_mgmt_get_server_array", ret); + return -1; } /* grap current events */ ret = PVFS_mgmt_event_mon_list(cur_fs, - &creds, - event_matrix, - addr_array, - io_server_count, - EVENT_DEPTH, - NULL /* detailed errors */ - , NULL); + &creds, + event_matrix, + addr_array, + io_server_count, + EVENT_DEPTH, + NULL, /* detailed errors */ + NULL); if (ret < 0) { - PVFS_perror("PVFS_mgmt_event_mon_list", EVENT_DEPTH); - return -1; + PVFS_perror("PVFS_mgmt_event_mon_list", EVENT_DEPTH); + return -1; } printf("# (server number) (api) (operation) (value) (id) (flags) (sec) (usec)\n"); for (i=0; i < io_server_count; i++) { - for (j=0; j < EVENT_DEPTH; j++) - { - if ((event_matrix[i][j].flags & PVFS_EVENT_FLAG_INVALID) == 0) - { - printf("%d %d %d %lld %lld %d %d %d\n", - i, - (int)event_matrix[i][j].api, - (int)event_matrix[i][j].operation, - (long long)event_matrix[i][j].value, - (long long)event_matrix[i][j].id, - (int)event_matrix[i][j].flags, - (int)event_matrix[i][j].tv_sec, - (int)event_matrix[i][j].tv_usec); - } - } + for (j=0; j < EVENT_DEPTH; j++) + { + if ((event_matrix[i][j].flags & PVFS_EVENT_FLAG_INVALID) == 0) + { + printf("%d %d %d %lld %lld %d %d %d\n", + i, + (int)event_matrix[i][j].api, + (int)event_matrix[i][j].operation, + (long long)event_matrix[i][j].value, + (long long)event_matrix[i][j].id, + (int)event_matrix[i][j].flags, + (int)event_matrix[i][j].tv_sec, + (int)event_matrix[i][j].tv_usec); + } + } } PVFS_sys_finalize(); @@ -181,48 +181,50 @@ static struct options* parse_args(int argc, char* argv[]) tmp_opts = (struct options *) malloc(sizeof(struct options)); if (tmp_opts == NULL) { - return NULL; + return NULL; } memset(tmp_opts, 0, sizeof(struct options)); /* look at command line arguments */ - while((one_opt = getopt(argc, argv, flags)) != EOF){ - switch(one_opt) + while((one_opt = getopt(argc, argv, flags)) != EOF) + { + switch(one_opt) { case('v'): printf("%s\n", PVFS2_VERSION); exit(0); - case('m'): - len = strlen(optarg)+1; - tmp_opts->mnt_point = (char *) malloc(len + 1); - if (tmp_opts->mnt_point == NULL) - { - free(tmp_opts); - return NULL; - } - memset(tmp_opts->mnt_point, 0, len+1); - ret = sscanf(optarg, "%s", tmp_opts->mnt_point); - if(ret < 1){ - free(tmp_opts); - return NULL; - } - /* TODO: dirty hack... fix later. The remove_dir_prefix() - * function expects some trailing segments or at least - * a slash off of the mount point - */ - strcat(tmp_opts->mnt_point, "/"); - tmp_opts->mnt_point_set = 1; - break; - case('?'): - usage(argc, argv); - exit(EXIT_FAILURE); - } + case('m'): + len = strlen(optarg)+1; + tmp_opts->mnt_point = (char *) malloc(len + 1); + if (tmp_opts->mnt_point == NULL) + { + free(tmp_opts); + return NULL; + } + memset(tmp_opts->mnt_point, 0, len+1); + ret = sscanf(optarg, "%s", tmp_opts->mnt_point); + if(ret < 1) + { + free(tmp_opts); + return NULL; + } + /* TODO: dirty hack... fix later. The remove_dir_prefix() + * function expects some trailing segments or at least + * a slash off of the mount point + */ + strcat(tmp_opts->mnt_point, "/"); + tmp_opts->mnt_point_set = 1; + break; + case('?'): + usage(argc, argv); + exit(EXIT_FAILURE); + } } if (!tmp_opts->mnt_point_set) { - free(tmp_opts); - return NULL; + free(tmp_opts); + return NULL; } return tmp_opts; @@ -232,10 +234,8 @@ static struct options* parse_args(int argc, char* argv[]) static void usage(int argc, char** argv) { fprintf(stderr, "\n"); - fprintf(stderr, "Usage : %s [-m fs_mount_point]\n", - argv[0]); - fprintf(stderr, "Example: %s -m /mnt/pvfs2\n", - argv[0]); + fprintf(stderr, "Usage : %s [-m fs_mount_point]\n", argv[0]); + fprintf(stderr, "Example: %s -m /mnt/pvfs2\n", argv[0]); return; } diff --git a/src/apps/admin/pvfs2-fsck.c b/src/apps/admin/pvfs2-fsck.c index 406aab1..a2ccca4 100644 --- a/src/apps/admin/pvfs2-fsck.c +++ b/src/apps/admin/pvfs2-fsck.c @@ -35,14 +35,18 @@ struct options int mnt_point_set; int verbose; int destructive; + int safety_check; + unsigned int safety_count; }; struct options *fsck_opts = NULL; /* lost+found reference */ PVFS_object_ref laf_ref; +unsigned long int global_removals = 0; static void handlelist_remove_handle_no_idx(struct handlelist *hl, PVFS_handle handle); +static void get_user_action_to_continue( void ); int main(int argc, char **argv) { @@ -1199,6 +1203,11 @@ int remove_directory_entry(PVFS_object_ref dir_ref, name, llu(entry_ref.handle), llu(dir_ref.handle)); + if( (fsck_opts->safety_check) && + (++global_removals >= fsck_opts->safety_count) ) + { + get_user_action_to_continue( ); + } if (fsck_opts->destructive) { ret = PVFS_mgmt_remove_dirent(dir_ref, @@ -1226,6 +1235,12 @@ int remove_object(PVFS_object_ref obj_ref, get_type_str(obj_type), llu(obj_ref.handle)); + if( (fsck_opts->safety_check) && + (++global_removals >= fsck_opts->safety_count) ) + { + get_user_action_to_continue( ); + } + if (fsck_opts->destructive) { ret = PVFS_mgmt_remove_object(obj_ref, creds, NULL); @@ -1543,7 +1558,7 @@ static struct options *parse_args(int argc, char *argv[]) memset(opts, 0, sizeof(struct options)); /* look at command line arguments */ - while((one_opt = getopt(argc, argv, "apynvVm:")) != EOF){ + while((one_opt = getopt(argc, argv, "apyns:vVm:")) != EOF){ switch(one_opt) { case 'a': @@ -1554,6 +1569,10 @@ static struct options *parse_args(int argc, char *argv[]) case 'n': opts->destructive = 0; break; + case 's': + opts->safety_count = atoi(optarg); + opts->safety_check = 1; + break; case 'V': printf("%s\n", PVFS2_VERSION); exit(0); @@ -1601,12 +1620,14 @@ static struct options *parse_args(int argc, char *argv[]) static void usage(int argc, char** argv) { fprintf(stderr, "\n"); - fprintf(stderr, "Usage : %s [-vV] [-m fs_mount_point]\n", + fprintf(stderr, "Usage : %s [-vV] <-ayp -s N> [-m fs_mount_point]\n", argv[0]); fprintf(stderr, "Display information about contents of file system.\n"); fprintf(stderr, " -V print version and exit\n"); fprintf(stderr, " -v verbose operation\n"); fprintf(stderr, " -n answer \"no\" to all questions\n"); + fprintf(stderr, " -s N safety check, prompt after N removals, " + "use with a, p, or y\n"); fprintf(stderr, " -y answer \"yes\" to all questions\n"); fprintf(stderr, " -p automatically repair with no questions\n"); fprintf(stderr, " -a equivalent to \"-p\"\n"); @@ -1649,6 +1670,52 @@ static char *get_type_str(int type) return ret; } +void get_user_action_to_continue( ) +{ + int count = 0; + int reply_idx = 0; + int read_c = 0; + char reply[3] = { 0 }; + + /* only cause the prompt if destructive actions are being taken */ + if( fsck_opts->destructive ) + { + fprintf(stdout, "%lu objects have been removed, ", global_removals); + do + { + memset(reply, 0, 3); + count = 0, reply_idx = 0; + fprintf(stdout, "continue removal [Y|N]: "); + do + { + read_c = getchar(); + count++; + /* discard anything beyond the two chars we want */ + if( (read_c != EOF) && (reply_idx < 2 ) ) + { + reply[reply_idx++] = (char)read_c; + } + } + while((read_c != EOF) && (read_c != '\n')); + + if( (count == 2) && (strncasecmp("Y\n", reply, 2) == 0) ) + { + fprintf(stdout, "resetting removal count, continuing\n"); + global_removals = 0; + return; + } + else if( (count == 2) && (strncasecmp("N\n", reply, 2) == 0) ) + { + fprintf(stdout, "aborting\n"); + exit(1); + } + } + while( 1 ) ; + } + + return; +} + /* * Local variables: * c-indent-level: 4 diff --git a/src/apps/admin/pvfs2-ls.c b/src/apps/admin/pvfs2-ls.c index 255d114..d80ce81 100644 --- a/src/apps/admin/pvfs2-ls.c +++ b/src/apps/admin/pvfs2-ls.c @@ -10,12 +10,18 @@ #include #include #include +#ifndef WIN32 #include +#endif #include +#ifndef WIN32 #include #include +#endif #include +#ifndef WIN32 #include +#endif #include "pvfs2.h" #include "str-utils.h" @@ -25,6 +31,9 @@ #define PVFS2_VERSION "Unknown" #endif +#ifdef WIN32 +#define snprintf _snprintf +#endif /* TODO: this can be larger after system interface readdir logic * is in place to break up large readdirs into multiple operations @@ -216,8 +225,12 @@ void print_entry_attr( { char *formatted_size = NULL; char *formatted_owner = NULL, *formatted_group = NULL, *formatted_time = NULL; +#ifdef WIN32 + +#else struct group *grp = NULL; struct passwd *pwd = NULL; +#endif char *empty_str = ""; char *owner = empty_str, *group = empty_str; char *inode = empty_str; @@ -246,22 +259,38 @@ void print_entry_attr( atime = (time_t)attr->atime; ctime = (time_t)attr->ctime; +#ifdef WIN32 + num_bytes = strftime( scratch_time,ALL_TIMES_LENGTH+1,"%Y-%m-%d %H:%M:%S %z",time ); +#else num_bytes = strftime( scratch_time,ALL_TIMES_LENGTH+1,"%F %H:%M:%S %z",time ); +#endif strncpy(scratch_big_time,scratch_time,num_bytes); time = localtime(&atime); +#ifdef WIN32 + num_bytes = strftime( scratch_time,ALL_TIMES_LENGTH+3," %Y-%m-%d %H:%M:%S %z",time ); +#else num_bytes = strftime( scratch_time,ALL_TIMES_LENGTH+3," %F %H:%M:%S %z",time ); +#endif strncat(scratch_big_time,scratch_time,num_bytes); time = localtime(&ctime); +#ifdef WIN32 + num_bytes = strftime( scratch_time,ALL_TIMES_LENGTH+3," %Y-%m-%d %H:%M:%S %z",time ); +#else num_bytes = strftime( scratch_time,ALL_TIMES_LENGTH+3," %F %H:%M:%S %z",time ); +#endif strncat(scratch_big_time,scratch_time,num_bytes); format_size_string(scratch_big_time,strlen(scratch_big_time),&formatted_time,0,1); } else { +#ifdef WIN32 + strftime( scratch_time,17,"%Y-%m-%d %H:%M",time ); +#else strftime( scratch_time,17,"%F %H:%M",time ); +#endif format_size_string(scratch_time,16,&formatted_time,0,1); } @@ -313,14 +342,23 @@ void print_entry_attr( { if (!opts->list_no_owner) { +#ifdef WIN32 + owner = scratch_owner; +#else pwd = getpwuid((uid_t)attr->owner); owner = (pwd ? pwd->pw_name : scratch_owner); +#endif } if (!opts->list_no_group) { +#ifdef WIN32 + group = scratch_group; +#else grp = getgrgid((gid_t)attr->group); group = (grp ? grp->gr_name : scratch_group); +#endif + } } @@ -602,6 +640,8 @@ int do_list( for(i = 0; i < rdplus_response.pvfs_dirent_outcount; i++) { + PVFS_sys_attr *attr; + cur_file = rdplus_response.dirent_array[i].d_name; cur_handle = rdplus_response.dirent_array[i].handle; @@ -610,7 +650,7 @@ int do_list( rdplus_response.stat_err_array[i], opts, entry_buffer); - PVFS_sys_attr *attr = &rdplus_response.attr_array[i]; + attr = &rdplus_response.attr_array[i]; if(attr->objtype == PVFS_TYPE_DIRECTORY && opts->list_recursive) { int path_len = strlen(start) + strlen(cur_file) + 1; @@ -705,11 +745,144 @@ int do_list( * * returns pointer to options structure on success, NULL on failure */ +#ifdef WIN32 static struct options* parse_args(int argc, char* argv[]) { int i = 0, ret = 0, option_index = 0; const char *cur_option = NULL; struct options* tmp_opts = NULL; + + static char str_opts[14][16] = { + "help", + "human-readable", + "si", + "version", + "recursive", + "verbose", + "numeric-uid-gid", + "directory", + "no-group", + "almost-all", + "all", + "inode", + "size", + "all-times" + }; + + tmp_opts = (struct options*)malloc(sizeof(struct options)); + if (!tmp_opts) + { + return(NULL); + } + memset(tmp_opts, 0, sizeof(struct options)); + /* RVndGoAaiglt */ + option_index = 1; + while ((option_index < argc) && (argv[option_index][0] == '-')) + { + cur_option = argv[option_index]; + + if ((strcmp(cur_option, "-?") == 0) || + (strcmp(cur_option, "--help") == 0)) + { + usage(argc, argv); + exit(0); + } + else if ((strcmp(cur_option, "--human-readable") == 0) || + (strcmp(cur_option, "-h") == 0)) + { + tmp_opts->list_human_readable = 1; + } + else if (strcmp(cur_option, "--si") == 0) + { + tmp_opts->list_use_si_units = 1; + } + else if (strcmp(cur_option, "--version") == 0) + { + printf("%s\n", PVFS2_VERSION); + exit(0); + } + else if ((strcmp(cur_option, "--recursive") == 0) || + (strcmp(cur_option, "-R") == 0)) + { + tmp_opts->list_recursive = 1; + } + else if ((strcmp(cur_option, "--verbose") == 0) || + (strcmp(cur_option, "-V") == 0)) + { + tmp_opts->list_verbose = 1; + } + else if ((strcmp(cur_option, "--numeric-uid-gid") == 0) || + (strcmp(cur_option, "-n") == 0)) + { + tmp_opts->list_long = 1; + tmp_opts->list_numeric_uid_gid = 1; + } + else if ((strcmp(cur_option, "--directory") == 0) || + (strcmp(cur_option, "-d") == 0)) + { + tmp_opts->list_directory = 1; + } + else if ((strcmp(cur_option, "--no-group") == 0) || + (strcmp(cur_option, "-G") == 0)) + { + tmp_opts->list_long = 1; + tmp_opts->list_no_group = 1; + } + else if ((strcmp(cur_option, "--almost-all") == 0) || + (strcmp(cur_option, "-A") == 0)) + { + tmp_opts->list_almost_all = 1; + } + else if ((strcmp(cur_option, "--all") == 0) || + (strcmp(cur_option, "-a") == 0)) + { + tmp_opts->list_all = 1; + } + else if ((strcmp(cur_option, "--inode") == 0) || + (strcmp(cur_option, "-i") == 0)) + { + tmp_opts->list_inode = 1; + } + else if ((strcmp(cur_option, "--all-times") == 0)) + { + tmp_opts->list_all_times = 1; + } + else if (strcmp(cur_option, "-l") == 0) + { + tmp_opts->list_long = 1; + } + else + { + usage(argc, argv); + exit(EXIT_FAILURE); + } + + option_index++; + } + + for(i = option_index; i < argc; i++) + { + if (tmp_opts->num_starts < MAX_NUM_PATHS) + { + tmp_opts->start[i-option_index] = argv[i]; + tmp_opts->num_starts++; + } + else + { + fprintf(stderr,"Ignoring path %s\n",argv[i]); + } + } + + return tmp_opts; + +} +#else +static struct options* parse_args(int argc, char* argv[]) +{ + int i = 0, ret = 0, option_index = 0; + const char *cur_option = NULL; + struct options* tmp_opts = NULL; + static struct option long_opts[] = { {"help",0,0,0}, @@ -876,6 +1049,7 @@ static struct options* parse_args(int argc, char* argv[]) } return tmp_opts; } +#endif static void usage(int argc, char** argv) { diff --git a/src/apps/admin/pvfs2-perf-mon-example.c b/src/apps/admin/pvfs2-perf-mon-example.c index 3a59e78..116fd40 100644 --- a/src/apps/admin/pvfs2-perf-mon-example.c +++ b/src/apps/admin/pvfs2-perf-mon-example.c @@ -27,6 +27,19 @@ #define PVFS2_VERSION "Unknown" #endif +#define MAX_KEY_CNT 4; +/* macros for accessing data returned from server */ +#define VALID_FLAG(s,h) (perf_matrix[(s)][((h) * (key_cnt + 2)) + key_cnt] != 0.0) +#define ID(s,h) (perf_matrix[(s)][((h) * (key_cnt + 2)) + key_cnt]) +#define START_TIME(s,h) (perf_matrix[(s)][((h) * (key_cnt + 2)) + key_cnt]) +#define READ(s,h) (perf_matrix[(s)][((h) * (key_cnt + 2)) + 0]) +#define WRITE(s,h) (perf_matrix[(s)][((h) * (key_cnt + 2)) + 1]) +#define METADATA_READ(s,h) (perf_matrix[(s)][((h) * (key_cnt + 2)) + 2]) +#define METADATA_WRITE(s,h) (perf_matrix[(s)][((h) * (key_cnt + 2)) + 3]) + +int key_cnt; /* holds the Number of keys */ + + struct options { char* mnt_point; @@ -45,7 +58,7 @@ int main(int argc, char **argv) int i,j; PVFS_credentials creds; int io_server_count; - struct PVFS_mgmt_perf_stat** perf_matrix; + int64_t** perf_matrix; uint64_t* end_time_ms_array; uint32_t* next_id_array; PVFS_BMI_addr_t *addr_array; @@ -90,8 +103,7 @@ int main(int argc, char **argv) } /* allocate a 2 dimensional array for statistics */ - perf_matrix = (struct PVFS_mgmt_perf_stat**)malloc( - io_server_count*sizeof(struct PVFS_mgmt_perf_stat*)); + perf_matrix = (int64_t **)malloc(io_server_count*sizeof(int64_t *)); if(!perf_matrix) { perror("malloc"); @@ -99,8 +111,7 @@ int main(int argc, char **argv) } for(i=0; ikey[0].buffer); return -1; } - if (strncmp(user_opts->key[0].buffer,"user.pvfs2.meta_hint",20) == 0) + if (strncmp(user_opts->key[0].buffer + ,"user.pvfs2.meta_hint" + ,user_opts->key[0].buffer_sz) == 0) { tmp_val.buffer=¤t_meta_hint.flags; tmp_val.buffer_sz=sizeof(current_meta_hint.flags); @@ -173,9 +175,8 @@ int main(int argc, char **argv) } if (modify_val(&user_opts->key[0], &user_opts->val[0]) < 0) { - fprintf(stderr, "Invalid value for user-settable attribute %s, %s\n" - , (char *) user_opts->key[0].buffer - , (char *) user_opts->val[0].buffer); + fprintf(stderr, "Invalid value for user-settable attribute %s\n" + , (char *) user_opts->key[0].buffer); return -1; } } @@ -200,7 +201,7 @@ int main(int argc, char **argv) { if (strncmp(user_opts->key[0].buffer ,"user.pvfs2.meta_hint" - ,SPECIAL_METAFILE_HINT_KEYLEN) == 0) { + ,user_opts->key[0].buffer_sz) == 0) { PVFS_metafile_hint *hint = (PVFS_metafile_hint *) user_opts->val[0].buffer; printf("Metafile Hints (0X%08X)",(unsigned int)hint->flags); @@ -219,7 +220,7 @@ int main(int argc, char **argv) printf("\n"); } else if ( strncmp(user_opts->key[0].buffer ,"user.pvfs2.mirror.handles" - ,sizeof("user.pvfs2.mirror.handles")) == 0) + ,user_opts->key[0].buffer_sz) == 0) { PVFS_handle *myHandles = (PVFS_handle *)user_opts->val[0].buffer; int copies = *(int *)user_opts->val[1].buffer; @@ -230,13 +231,13 @@ int main(int argc, char **argv) } } else if ( strncmp(user_opts->key[0].buffer ,"user.pvfs2.mirror.copies" - ,sizeof("user.pvfs2.mirror.copies")) == 0) + ,user_opts->key[0].buffer_sz) == 0) { int *myCopies = (int *)user_opts->val[0].buffer; printf("Number of Mirrored Copies : %d\n",*myCopies); } else if ( strncmp(user_opts->key[0].buffer ,"user.pvfs2.mirror.status" - ,sizeof("user.pvfs2.mirror.status")) == 0) + ,user_opts->key[0].buffer_sz) == 0) { int copies = *(int *)user_opts->val[1].buffer; int dfile_count = src.u.pvfs2.attr.dfile_count; @@ -248,7 +249,7 @@ int main(int argc, char **argv) ,llu(status[i])); } else if ( strncmp(user_opts->key[0].buffer ,"user.pvfs2.mirror.mode" - , sizeof("user.pvfs2.mirror.mode")) == 0) + ,user_opts->key[0].buffer_sz) == 0) { printf("Mirroring Mode : "); switch(*(MIRROR_MODE *)user_opts->val[0].buffer) @@ -286,59 +287,59 @@ static int modify_val(PVFS_ds_keyval *key_p, PVFS_ds_keyval *val_p) *turned on and off with the pvfs2-setmattr and setmattr commands. */ if (strncmp(key_p->buffer,"user.pvfs2.meta_hint" - , SPECIAL_METAFILE_HINT_KEYLEN) == 0) + ,key_p->buffer_sz) == 0) { - if (strncmp(val_p->buffer, "+immutable", 10) == 0) + if (strncmp(val_p->buffer, "+immutable", val_p->buffer_sz) == 0) { current_meta_hint.flags |= PVFS_IMMUTABLE_FL; printf("Adding immutable to meta_hint...(0X%08X)\n" ,(unsigned int)current_meta_hint.flags); } - else if (strncmp(val_p->buffer, "-immutable", 10) == 0) + else if (strncmp(val_p->buffer, "-immutable", val_p->buffer_sz) == 0) { current_meta_hint.flags &= ~PVFS_IMMUTABLE_FL; printf("Removing immutable from meta_hint...(0X%08X)\n" ,(unsigned int)current_meta_hint.flags); } - else if (strncmp(val_p->buffer,"=immutable",10) == 0) + else if (strncmp(val_p->buffer,"=immutable", val_p->buffer_sz) == 0) { current_meta_hint.flags = (current_meta_hint.flags & ~ALL_FS_META_HINT_FLAGS) | PVFS_IMMUTABLE_FL; printf("Setting meta_hint to immutable only (0X%08X)\n" ,(unsigned int)current_meta_hint.flags); } - else if (strncmp(val_p->buffer, "+append", 7) == 0) + else if (strncmp(val_p->buffer, "+append", val_p->buffer_sz) == 0) { current_meta_hint.flags |= PVFS_APPEND_FL; printf("Adding append to meta_hint...(0X%08X)\n" ,(unsigned int)current_meta_hint.flags); } - else if (strncmp(val_p->buffer, "-append", 7) == 0) + else if (strncmp(val_p->buffer, "-append", val_p->buffer_sz) == 0) { current_meta_hint.flags &= ~PVFS_APPEND_FL; printf("Removing append from meta_hint...(0X%08X)\n" ,(unsigned int)current_meta_hint.flags); } - else if (strncmp(val_p->buffer,"=append",7) == 0) + else if (strncmp(val_p->buffer,"=append", val_p->buffer_sz) == 0) { current_meta_hint.flags = (current_meta_hint.flags & ~ALL_FS_META_HINT_FLAGS) | PVFS_APPEND_FL; printf("Setting meta_hint to append only (0X%08X)\n" ,(unsigned int)current_meta_hint.flags); } - else if (strncmp(val_p->buffer, "+noatime", 8) == 0) + else if (strncmp(val_p->buffer, "+noatime", val_p->buffer_sz) == 0) { current_meta_hint.flags |= PVFS_NOATIME_FL; printf("Adding noatime to meta_hint...(0X%08X)\n" ,(unsigned int)current_meta_hint.flags); } - else if (strncmp(val_p->buffer, "-noatime", 8) == 0) + else if (strncmp(val_p->buffer, "-noatime", val_p->buffer_sz) == 0) { current_meta_hint.flags &= ~PVFS_NOATIME_FL; printf("Removing atime from meta_hint...(0X%08X)\n" ,(unsigned int)current_meta_hint.flags); } - else if (strncmp(val_p->buffer,"=noatime",8) == 0) + else if (strncmp(val_p->buffer,"=noatime", val_p->buffer_sz) == 0) { current_meta_hint.flags = (current_meta_hint.flags & ~ALL_FS_META_HINT_FLAGS) | PVFS_NOATIME_FL; @@ -352,11 +353,11 @@ static int modify_val(PVFS_ds_keyval *key_p, PVFS_ds_keyval *val_p) memcpy(val_p->buffer, ¤t_meta_hint.flags, sizeof(current_meta_hint.flags)); val_p->buffer_sz = sizeof(current_meta_hint.flags); } else if (strncmp(key_p->buffer,"user.pvfs2.mirror.mode" - ,sizeof("user.pvfs2.mirror.mode")) == 0) + ,key_p->buffer_sz) == 0) { printf("Setting mirror mode to %d\n",*(int *)val_p->buffer); } else if (strncmp(key_p->buffer,"user.pvfs2.mirror.copies" - ,sizeof("user.pvfs2.mirror.mode")) == 0) + ,key_p->buffer_sz) == 0) { printf("Setting number of mirrored copies to %d\n" ,*(int *)val_p->buffer); @@ -514,7 +515,7 @@ static struct options* parse_args(int argc, char* argv[]) tmp_opts->get = 1; /* look at command line arguments */ - while((one_opt = getopt(argc, argv, flags)) != EOF) + while((one_opt = getopt(argc, argv, flags)) != -1) { switch(one_opt){ case 't': @@ -530,10 +531,10 @@ static struct options* parse_args(int argc, char* argv[]) case 'v': if (strncmp(tmp_opts->key[0].buffer ,"user.pvfs2.mirror.mode" - ,sizeof("user.pvfs2.mirror.mode")) == 0 || + ,tmp_opts->key[0].buffer_sz) == 0 || strncmp(tmp_opts->key[0].buffer ,"user.pvfs2.mirror.copies" - ,sizeof("user.pvfs2.mirror.copies")) == 0) + ,tmp_opts->key[0].buffer_sz) == 0) { /*convert string argument into numeric argument*/ tmp_opts->val[0].buffer = malloc(sizeof(int)); if (!tmp_opts->val[0].buffer) @@ -559,10 +560,13 @@ static struct options* parse_args(int argc, char* argv[]) /*ensure that the given mode is supported by PVFS*/ if (!tmp_opts->get && - strcmp(tmp_opts->key[0].buffer,"user.pvfs2.mirror.mode") == 0) + strncmp(tmp_opts->key[0].buffer + ,"user.pvfs2.mirror.mode" + ,tmp_opts->key[0].buffer_sz) == 0) { - if (*(int *)tmp_opts->val[0].buffer < BEGIN_MIRROR_MODE || - *(int *)tmp_opts->val[0].buffer > END_MIRROR_MODE ) + if (tmp_opts->val[0].buffer && + (*(int *)tmp_opts->val[0].buffer < BEGIN_MIRROR_MODE || + *(int *)tmp_opts->val[0].buffer > END_MIRROR_MODE) ) { fprintf(stderr,"Invalid Mirror Mode ==> %d\n" "\tValid Modes\n" @@ -580,8 +584,12 @@ static struct options* parse_args(int argc, char* argv[]) /*if user wants mirror.handles or mirror.status, then we must also */ /*retrieve the number of copies, so we know how to display the */ /*information properly. */ - if (strcmp(tmp_opts->key[0].buffer,"user.pvfs2.mirror.handles") == 0 || - strcmp(tmp_opts->key[0].buffer,"user.pvfs2.mirror.status") == 0 ) + if (strncmp(tmp_opts->key[0].buffer + ,"user.pvfs2.mirror.handles" + ,tmp_opts->key[0].buffer_sz) == 0 || + strncmp(tmp_opts->key[0].buffer + ,"user.pvfs2.mirror.status" + ,tmp_opts->key[0].buffer_sz) == 0 ) { tmp_opts->key_count = 2; PVFS_ds_keyval *myKeys = malloc(tmp_opts->key_count * @@ -591,8 +599,7 @@ static struct options* parse_args(int argc, char* argv[]) fprintf(stderr,"Unable to allocate myKeys.\n"); exit(EXIT_FAILURE); } - memset(myKeys,0,sizeof(tmp_opts->key_count * - sizeof(PVFS_ds_keyval))); + memset(myKeys,0,tmp_opts->key_count*sizeof(PVFS_ds_keyval)); myKeys[0] = *tmp_opts->key; myKeys[1].buffer = strdup("user.pvfs2.mirror.copies"); myKeys[1].buffer_sz = sizeof("user.pvfs2.mirror.copies"); @@ -619,8 +626,7 @@ static struct options* parse_args(int argc, char* argv[]) fprintf(stderr,"Unable to allocate myVals.\n"); exit(EXIT_FAILURE); } - memset(myVals,0,sizeof(tmp_opts->key_count * - sizeof(PVFS_ds_keyval))); + memset(myVals,0,tmp_opts->key_count*sizeof(PVFS_ds_keyval)); myVals[0] = *tmp_opts->val; free(tmp_opts->val); diff --git a/src/apps/devel/pvfs2-db-display.c b/src/apps/devel/pvfs2-db-display.c index 4bf22f2..38b5c8b 100644 --- a/src/apps/devel/pvfs2-db-display.c +++ b/src/apps/devel/pvfs2-db-display.c @@ -300,8 +300,15 @@ void print_keyval( DBT key, DBT val ) if( strncmp(k->key, "dh", 3) == 0 || strncmp(k->key, "de", 3) == 0 ) { - vh = *(uint64_t *)val.data; - printf("(%llu)(%d)\n", llu(vh), val.size); + int s = 0; + while(s < val.size ) + { + vh = *(uint64_t *)(val.data + s); + printf("(%llu)", llu(vh)); + s += sizeof(TROVE_handle); + } + printf("(%d)\n", val.size); + } else if( strncmp(k->key, "md", 3) == 0 ) diff --git a/src/apps/fuse/pvfs2fuse.c b/src/apps/fuse/pvfs2fuse.c index f86dde3..17b6063 100644 --- a/src/apps/fuse/pvfs2fuse.c +++ b/src/apps/fuse/pvfs2fuse.c @@ -9,13 +9,13 @@ * Author: John A. Chandy * Sumit Narayan * - * $Date: 2010/12/21 15:34:13 $ + * $Date: 2010-12-21 15:34:13 $ * $Revision: 1.3.8.2 $ * * Documentation: http://www.engr.uconn.edu/~sun03001/docs/pvfs2fuse-rpt.pdf */ -/* char *pvfs2fuse_version = "$Id: pvfs2fuse.c,v 1.3.8.2 2010/12/21 15:34:13 mtmoore Exp $"; */ +/* char *pvfs2fuse_version = "$Id: pvfs2fuse.c,v 1.3.8.2 2010-12-21 15:34:13 mtmoore Exp $"; */ char *pvfs2fuse_version = "0.01"; #define FUSE_USE_VERSION 27 diff --git a/src/apps/karma/comm.c b/src/apps/karma/comm.c index d8e2649..5242974 100644 --- a/src/apps/karma/comm.c +++ b/src/apps/karma/comm.c @@ -16,6 +16,7 @@ #include "karma.h" #define GUI_COMM_PERF_HISTORY 5 +#define GUI_COMM_PERF_KEYCOUNT 4 #undef FAKE_STATS #undef FAKE_PERF @@ -33,6 +34,19 @@ static int internal_addr_ct; static int64_t meta_read_prev = 0; static int64_t meta_write_prev = 0; +/* this struct is now only used by karma */ +/* perf numbers are returned as an array of int64_t */ + +struct PVFS_mgmt_perf_stat +{ + int32_t valid_flag; + int64_t start_time_ms; + int64_t read; + int64_t write; + int64_t metadata_read; + int64_t metadata_write; +}; + /* performance data structures */ static struct PVFS_mgmt_perf_stat **internal_perf; static uint32_t *internal_perf_ids; @@ -396,22 +410,57 @@ static int gui_comm_stats_collect( static int gui_comm_perf_collect( void) { - int ret; + int ret = 0; char err_msg[64]; char msgbuf[64]; + int key_count; + int64_t **perf_data; + int srv; #ifndef FAKE_PERF + key_count = GUI_COMM_PERF_KEYCOUNT; + + perf_data = (int64_t **)malloc(internal_addr_ct * sizeof(int64_t *)); + for (srv = 0; srv < internal_addr_ct; srv++) + perf_data[srv] = (int64_t *)malloc(sizeof(int64_t) * + (GUI_COMM_PERF_KEYCOUNT + 2) * + GUI_COMM_PERF_HISTORY); + ret = PVFS_mgmt_perf_mon_list(cur_fsid, &creds, - internal_perf, + perf_data, internal_end_time_ms, internal_addrs, internal_perf_ids, internal_addr_ct, + &key_count, GUI_COMM_PERF_HISTORY, internal_details, NULL); if (ret == 0) - return 0; + { + /* Note: Karma could be rewritten to deal with the */ + /* new format from the perf subsystem, but might */ + /* not be any great need to ... WBL */ + for (srv = 0; srv < internal_addr_ct; srv++) + { + int i; + for (i = 0; i < GUI_COMM_PERF_HISTORY; i++) + { + internal_perf[srv][i].valid_flag = + (perf_data[srv][(i * (key_count + 2)) + key_count] != 0.0); + internal_perf[srv][i].start_time_ms = + perf_data[srv][(i * (key_count + 2)) + key_count]; + internal_perf[srv][i].read = + perf_data[srv][(i * (key_count + 2)) + 0]; + internal_perf[srv][i].write = + perf_data[srv][(i * (key_count + 2)) + 1]; + internal_perf[srv][i].metadata_read = + perf_data[srv][(i * (key_count + 2)) + 2]; + internal_perf[srv][i].metadata_write = + perf_data[srv][(i * (key_count + 2)) + 3]; + } + } + } else if (ret == -PVFS_EDETAIL) { int i; @@ -432,7 +481,7 @@ static int gui_comm_perf_collect( gui_message_new(msgbuf); } - return 0; + ret = 0; } else { @@ -443,11 +492,15 @@ static int gui_comm_perf_collect( err_msg); gui_message_new(msgbuf); - return -1; + ret = -1; } + + for (srv = 0; srv < internal_addr_ct; srv++) + free(perf_data[srv]); + free(perf_data); #endif - return 0; + return ret; } /* gui_comm_traffic_retrieve() diff --git a/src/apps/kernel/linux/pvfs2-client-core.c b/src/apps/kernel/linux/pvfs2-client-core.c index 907164f..7a7b531 100644 --- a/src/apps/kernel/linux/pvfs2-client-core.c +++ b/src/apps/kernel/linux/pvfs2-client-core.c @@ -19,19 +19,6 @@ #ifdef __PVFS2_SEGV_BACKTRACE__ #include -#define __USE_GNU -#include -#endif - -#ifdef __PVFS2_SEGV_BACKTRACE__ -#include -#define __USE_GNU -#include -#endif - -#ifdef __PVFS2_SEGV_BACKTRACE__ -#include -#define __USE_GNU #include #endif @@ -297,7 +284,7 @@ do { \ #elif defined(REG_RIP) # define REG_INSTRUCTION_POINTER REG_RIP #else -# error Unknown instruction pointer location for your architecture, configure without --enable-segv-backtrace. +# error Unknown instruction pointer location for your architecture, configure with --disable-segv-backtrace. #endif static void client_segfault_handler(int signum, siginfo_t *info, void *secret) @@ -395,12 +382,10 @@ static PVFS_error cancel_op_in_progress(PVFS_id_gen_t tag) gossip_debug(GOSSIP_CLIENTCORE_DEBUG, "cancel_op_in_progress called\n"); - hash_link = qhash_search( - s_ops_in_progress_table, (void *)(&tag)); + hash_link = qhash_search( s_ops_in_progress_table, (void *)(&tag)); if (hash_link) { - vfs_request = qhash_entry( - hash_link, vfs_request_t, hash_link); + vfs_request = qhash_entry( hash_link, vfs_request_t, hash_link); assert(vfs_request); assert(vfs_request->info.tag == tag); @@ -440,12 +425,11 @@ static int is_op_in_progress(vfs_request_t *vfs_request) gossip_debug(GOSSIP_CLIENTCORE_DEBUG, "is_op_in_progress called on " "tag %lld\n", lld(vfs_request->info.tag)); - hash_link = qhash_search( - s_ops_in_progress_table, (void *)(&vfs_request->info.tag)); + hash_link = qhash_search( s_ops_in_progress_table, + (void *)(&vfs_request->info.tag)); if (hash_link) { - tmp_request = qhash_entry( - hash_link, vfs_request_t, hash_link); + tmp_request = qhash_entry( hash_link, vfs_request_t, hash_link); assert(tmp_request); op_found = ((tmp_request->info.tag == vfs_request->info.tag) && @@ -3770,7 +3754,7 @@ static void parse_args(int argc, char **argv, options_t *opts) }; assert(opts); - opts->perf_time_interval_secs = PERF_DEFAULT_TIME_INTERVAL_SECS; + opts->perf_time_interval_secs = PERF_DEFAULT_UPDATE_INTERVAL / 1000; opts->perf_history_size = PERF_DEFAULT_HISTORY_SIZE; while((ret = getopt_long(argc, argv, "ha:n:L:", diff --git a/src/client/sysint/acache.c b/src/client/sysint/acache.c index 50b819b..b6963d7 100644 --- a/src/client/sysint/acache.c +++ b/src/client/sysint/acache.c @@ -366,8 +366,8 @@ int PINT_acache_get_cached_entry( } #if 0 - gossip_debug(GOSSIP_ACACHE_DEBUG, "acache: -status=%d, attr_status=%d, size_status=%d\n", + gossip_debug(GOSSIP_ACACHE_DEBUG, "acache: " + "status=%d, attr_status=%d, size_status=%d\n", status, tmp_payload->attr_status, tmp_payload->size_status); #endif diff --git a/src/client/sysint/client-job-timer.sm b/src/client/sysint/client-job-timer.sm index 96eaadf..c567754 100644 --- a/src/client/sysint/client-job-timer.sm +++ b/src/client/sysint/client-job-timer.sm @@ -7,9 +7,13 @@ #include #include #include +#ifdef WIN32 +#include "wincommon.h" +#else #include -#include #include +#endif +#include #include "state-machine.h" #include "client-state-machine.h" diff --git a/src/client/sysint/client-state-machine.c b/src/client/sysint/client-state-machine.c index bc07b7b..163c0dd 100644 --- a/src/client/sysint/client-state-machine.c +++ b/src/client/sysint/client-state-machine.c @@ -206,12 +206,11 @@ static inline int cancelled_io_jobs_are_pending(PINT_smcb *smcb) test()). to avoid passing out the same completed op mutliple times, do not add the operation to the completion list until all cancellations on the I/O operation are accounted for - */ - assert(sm_p); - + */ PINT_client_sm *sm_base_p = PINT_sm_frame(smcb, (-(smcb->frame_count -1))); + assert(sm_p); assert(sm_base_p); /* @@ -269,7 +268,8 @@ struct PINT_client_op_entry_s PINT_client_sm_mgmt_table[] = {&pvfs2_client_mgmt_remove_object_sm}, {&pvfs2_client_mgmt_remove_dirent_sm}, {&pvfs2_client_mgmt_create_dirent_sm}, - {&pvfs2_client_mgmt_get_dirdata_handle_sm} + {&pvfs2_client_mgmt_get_dirdata_handle_sm}, + {&pvfs2_client_mgmt_get_uid_list_sm} }; @@ -992,6 +992,7 @@ const char *PINT_client_get_name_str(int op_type) { PVFS_MGMT_CREATE_DIRENT, "PVFS_MGMT_CREATE_DIRENT" }, { PVFS_MGMT_GET_DIRDATA_HANDLE, "PVFS_MGMT_GET_DIRDATA_HANDLE" }, + { PVFS_MGMT_GET_UID_LIST, "PVFS_MGMT_GET_UID_LIST" }, { PVFS_SYS_GETEATTR, "PVFS_SYS_GETEATTR" }, { PVFS_SYS_SETEATTR, "PVFS_SYS_SETEATTR" }, { PVFS_SYS_DELEATTR, "PVFS_SYS_DELEATTR" }, diff --git a/src/client/sysint/client-state-machine.h b/src/client/sysint/client-state-machine.h index ca85297..d96812f 100644 --- a/src/client/sysint/client-state-machine.h +++ b/src/client/sysint/client-state-machine.h @@ -274,6 +274,9 @@ struct PINT_client_io_sm struct PINT_client_flush_sm { +#ifdef WIN32 + int field; +#endif }; struct PINT_client_readdir_sm @@ -306,6 +309,13 @@ struct PINT_client_readdirplus_sm PVFS_handle **handles; }; +/* + * A segment is part of a path - namely each part of the + * path delimited by / characters. as each segment is + * looked up we record the PVFS_object_ref for the + * object in the FS, and its attributes. Other fields + * keep up with the segment in contect of the whole path + */ typedef struct { char *seg_name; @@ -315,6 +325,14 @@ typedef struct PVFS_object_ref seg_resolved_refn; } PINT_client_lookup_sm_segment; +/* + * A context is a group of segments that have been looked up + * on a server. A server can resolve more than one segment + * in a single request, and these groupings are maintained + * in a context. Again fields manage the progress as these + * lookups happen. + */ + typedef struct { int total_segments; @@ -374,9 +392,10 @@ struct PINT_client_mgmt_statfs_list_sm struct PINT_client_mgmt_perf_mon_list_sm { PVFS_fs_id fs_id; - struct PVFS_mgmt_perf_stat **perf_matrix; + int64_t **perf_matrix; uint64_t *end_time_ms_array; int server_count; + int *key_count; int history_count; PVFS_id_gen_t *addr_array; uint32_t *next_id_array; @@ -546,6 +565,17 @@ struct PINT_sysdev_unexp_sm struct PINT_dev_unexp_info *info; }; +/* scratch area used for the UID management state machine */ +struct PINT_client_mgmt_get_uid_list_sm +{ + PVFS_fs_id fs_id; + uint32_t history; + int server_count; + PVFS_id_gen_t *addr_array; /* in */ + PVFS_uid_info_s **uid_statistics; /* out */ + uint32_t *uid_count; /* out */ +}; + typedef struct { PVFS_dirent **dirent_array; @@ -623,6 +653,7 @@ typedef struct PINT_client_sm struct PINT_client_perf_count_timer_sm perf_count_timer; struct PINT_sysdev_unexp_sm sysdev_unexp; struct PINT_client_job_timer_sm job_timer; + struct PINT_client_mgmt_get_uid_list_sm get_uid_list; } u; } PINT_client_sm; @@ -711,6 +742,7 @@ enum PVFS_MGMT_REMOVE_DIRENT = 78, PVFS_MGMT_CREATE_DIRENT = 79, PVFS_MGMT_GET_DIRDATA_HANDLE = 80, + PVFS_MGMT_GET_UID_LIST = 81, PVFS_SERVER_GET_CONFIG = 200, PVFS_CLIENT_JOB_TIMER = 300, PVFS_CLIENT_PERF_COUNT_TIMER = 301, @@ -719,7 +751,7 @@ enum #define PVFS_OP_SYS_MAXVALID 21 #define PVFS_OP_SYS_MAXVAL 69 -#define PVFS_OP_MGMT_MAXVALID 81 +#define PVFS_OP_MGMT_MAXVALID 82 #define PVFS_OP_MGMT_MAXVAL 199 int PINT_client_io_cancel(job_id_t id); @@ -823,6 +855,7 @@ extern struct PINT_state_machine_s pvfs2_client_del_eattr_sm; extern struct PINT_state_machine_s pvfs2_client_list_eattr_sm; extern struct PINT_state_machine_s pvfs2_client_statfs_sm; extern struct PINT_state_machine_s pvfs2_fs_add_sm; +extern struct PINT_state_machine_s pvfs2_client_mgmt_get_uid_list_sm; /* nested state machines (helpers) */ extern struct PINT_state_machine_s pvfs2_client_lookup_ncache_sm; diff --git a/src/client/sysint/finalize.c b/src/client/sysint/finalize.c index 9f4c48f..1fccbc0 100644 --- a/src/client/sysint/finalize.c +++ b/src/client/sysint/finalize.c @@ -42,7 +42,7 @@ int PVFS_sys_finalize() PINT_ncache_finalize(); PINT_acache_finalize(); PINT_cached_config_finalize(); - + /* flush all known server configurations */ PINT_server_config_mgr_finalize(); diff --git a/src/client/sysint/fs-add.sm b/src/client/sysint/fs-add.sm index 90dfa2c..33f7ce1 100644 --- a/src/client/sysint/fs-add.sm +++ b/src/client/sysint/fs-add.sm @@ -22,7 +22,9 @@ #include #include #include +#ifndef WIN32 #include +#endif #include "acache.h" #include "ncache.h" diff --git a/src/client/sysint/initialize.c b/src/client/sysint/initialize.c index bb3ac54..a1faac0 100644 --- a/src/client/sysint/initialize.c +++ b/src/client/sysint/initialize.c @@ -11,7 +11,9 @@ #include #include #include +#ifndef WIN32 #include +#endif #include "acache.h" #include "ncache.h" @@ -76,7 +78,11 @@ int PVFS_sys_initialize(uint64_t default_debug_mask) uint64_t debug_mask = 0; char *event_mask = NULL; +#ifdef WIN32 + pint_client_pid = (int) GetCurrentProcessId(); +#else pint_client_pid = getpid(); +#endif gossip_enable_stderr(); diff --git a/src/client/sysint/mgmt-create-dirent.sm b/src/client/sysint/mgmt-create-dirent.sm index 7043bf7..d136f1c 100644 --- a/src/client/sysint/mgmt-create-dirent.sm +++ b/src/client/sysint/mgmt-create-dirent.sm @@ -211,9 +211,13 @@ static int mgmt_create_dirent_comp_fn( void *v_p, struct PVFS_server_resp *resp_p, int index) { PINT_smcb *smcb = v_p; +#ifdef WIN32 + PINT_client_sm *sm_p = + PINT_sm_frame(smcb, PINT_MSGPAIR_PARENT_SM); +#else PINT_client_sm *sm_p __attribute__((unused)) = PINT_sm_frame(smcb, PINT_MSGPAIR_PARENT_SM); - +#endif assert(resp_p->op == PVFS_SERV_CRDIRENT); if (resp_p->status == 0) diff --git a/src/client/sysint/mgmt-get-config.c b/src/client/sysint/mgmt-get-config.c index 131cd63..927d669 100755 --- a/src/client/sysint/mgmt-get-config.c +++ b/src/client/sysint/mgmt-get-config.c @@ -6,7 +6,9 @@ #include #include +#ifndef WIN32 #include +#endif #include "client-state-machine.h" #include "pvfs2-debug.h" diff --git a/src/client/sysint/mgmt-perf-mon-list.sm b/src/client/sysint/mgmt-perf-mon-list.sm index 0af544c..a2149ae 100644 --- a/src/client/sysint/mgmt-perf-mon-list.sm +++ b/src/client/sysint/mgmt-perf-mon-list.sm @@ -59,11 +59,12 @@ machine pvfs2_client_mgmt_perf_mon_list_sm PVFS_error PVFS_imgmt_perf_mon_list( PVFS_fs_id fs_id, PVFS_credentials *credentials, - struct PVFS_mgmt_perf_stat **perf_matrix, + int64_t **perf_matrix, uint64_t *end_time_ms_array, PVFS_BMI_addr_t *addr_array, uint32_t* next_id_array, int server_count, + int *key_count, int history_count, PVFS_error_details *details, PVFS_mgmt_op_id *op_id, @@ -77,8 +78,9 @@ PVFS_error PVFS_imgmt_perf_mon_list( gossip_debug(GOSSIP_CLIENT_DEBUG, "PVFS_imgmt_perf_mon_list entered\n"); - if ((server_count < 1) || (history_count < 1) || !perf_matrix || - !addr_array || !end_time_ms_array) + if ((server_count < 1) || (history_count < 1) || !key_count + || (*key_count < 1) || !perf_matrix || !addr_array + || !end_time_ms_array) { return -PVFS_EINVAL; } @@ -100,6 +102,7 @@ PVFS_error PVFS_imgmt_perf_mon_list( sm_p->u.perf_mon_list.fs_id = fs_id; sm_p->u.perf_mon_list.perf_matrix = perf_matrix; sm_p->u.perf_mon_list.server_count = server_count; + sm_p->u.perf_mon_list.key_count = key_count; sm_p->u.perf_mon_list.history_count = history_count; sm_p->u.perf_mon_list.addr_array = addr_array; sm_p->u.perf_mon_list.next_id_array = next_id_array; @@ -123,11 +126,12 @@ PVFS_error PVFS_imgmt_perf_mon_list( PVFS_error PVFS_mgmt_perf_mon_list( PVFS_fs_id fs_id, PVFS_credentials *credentials, - struct PVFS_mgmt_perf_stat **perf_matrix, + int64_t **perf_matrix, uint64_t *end_time_ms_array, PVFS_BMI_addr_t *addr_array, uint32_t* next_id_array, int server_count, + int *key_count, int history_count, PVFS_error_details *details, PVFS_hint hints) @@ -140,8 +144,8 @@ PVFS_error PVFS_mgmt_perf_mon_list( ret = PVFS_imgmt_perf_mon_list( fs_id, credentials, perf_matrix, end_time_ms_array, - addr_array, next_id_array, server_count, history_count, - details, &op_id, hints, NULL); + addr_array, next_id_array, server_count, key_count, + history_count, details, &op_id, hints, NULL); if (ret) { @@ -182,6 +186,7 @@ static PINT_sm_action mgmt_perf_mon_list_setup_msgpair( msg_p->req, *sm_p->cred_p, sm_p->u.perf_mon_list.next_id_array[i], + *sm_p->u.perf_mon_list.key_count, sm_p->u.perf_mon_list.history_count, sm_p->hints); @@ -259,10 +264,12 @@ static int perf_mon_list_comp_fn(void* v_p, resp_p->u.mgmt_perf_mon.suggested_next_id; sm_p->u.perf_mon_list.end_time_ms_array[i] = resp_p->u.mgmt_perf_mon.end_time_ms; + *sm_p->u.perf_mon_list.key_count = + resp_p->u.mgmt_perf_mon.key_count; memcpy(sm_p->u.perf_mon_list.perf_matrix[i], resp_p->u.mgmt_perf_mon.perf_array, resp_p->u.mgmt_perf_mon.perf_array_count - * sizeof(struct PVFS_mgmt_perf_stat)); + * sizeof(int64_t)); } /* if this is the last response, check all of the status values and diff --git a/src/client/sysint/mgmt-remove-dirent.sm b/src/client/sysint/mgmt-remove-dirent.sm index fcfcb02..b67f9a0 100644 --- a/src/client/sysint/mgmt-remove-dirent.sm +++ b/src/client/sysint/mgmt-remove-dirent.sm @@ -204,9 +204,13 @@ static int mgmt_remove_dirent_comp_fn( void *v_p, struct PVFS_server_resp *resp_p, int index) { PINT_smcb *smcb = v_p; +#ifdef WIN32 + PINT_client_sm *sm_p = + PINT_sm_frame(smcb, PINT_MSGPAIR_PARENT_SM); +#else PINT_client_sm *sm_p __attribute__((unused)) = PINT_sm_frame(smcb, PINT_MSGPAIR_PARENT_SM); - +#endif assert(resp_p->op == PVFS_SERV_MGMT_REMOVE_DIRENT); if (resp_p->status == 0) diff --git a/src/client/sysint/mgmt-remove-object.sm b/src/client/sysint/mgmt-remove-object.sm index af28341..f240378 100644 --- a/src/client/sysint/mgmt-remove-object.sm +++ b/src/client/sysint/mgmt-remove-object.sm @@ -200,9 +200,13 @@ static int mgmt_remove_object_comp_fn( void *v_p, struct PVFS_server_resp *resp_p, int index) { PINT_smcb *smcb = v_p; +#ifdef WIN32 + PINT_client_sm *sm_p = + PINT_sm_frame(smcb, PINT_MSGPAIR_PARENT_SM); +#else PINT_client_sm *sm_p __attribute__((unused)) = PINT_sm_frame(smcb, PINT_MSGPAIR_PARENT_SM); - +#endif assert(resp_p->op == PVFS_SERV_MGMT_REMOVE_OBJECT); if (resp_p->status == 0) diff --git a/src/client/sysint/module.mk.in b/src/client/sysint/module.mk.in index 4f606c9..fa8ee23 100644 --- a/src/client/sysint/module.mk.in +++ b/src/client/sysint/module.mk.in @@ -51,6 +51,7 @@ CLIENT_SMCGEN := \ $(DIR)/mgmt-remove-dirent.c \ $(DIR)/mgmt-create-dirent.c \ $(DIR)/mgmt-get-dirdata-handle.c \ + $(DIR)/mgmt-get-uid-list.c \ $(DIR)/osdsm.c \ $(DIR)/sys-osd-io.c diff --git a/src/client/sysint/perf-count-timer.sm b/src/client/sysint/perf-count-timer.sm index 5991d23..8ff7fdb 100644 --- a/src/client/sysint/perf-count-timer.sm +++ b/src/client/sysint/perf-count-timer.sm @@ -7,9 +7,11 @@ #include #include #include +#ifndef WIN32 #include -#include #include +#endif +#include #include "client-state-machine.h" #include "pint-perf-counter.h" @@ -80,11 +82,19 @@ static PINT_sm_action perf_count_timer_do_work( tmp_text = PINT_perf_generate_text(sm_p->u.perf_count_timer.pc, 4096); if(tmp_text) { +#ifdef WIN32 + token = strtok(tmp_text, delim); /* thread-safe */ +#else token = strtok_r(tmp_text, delim, &ptr); +#endif while(token) { gossip_perf_log("%s\n", token); +#ifdef WIN32 + token = strtok(NULL, delim); +#else token = strtok_r(NULL, delim, &ptr); +#endif } free(tmp_text); } diff --git a/src/client/sysint/pint-sysdev-unexp.sm b/src/client/sysint/pint-sysdev-unexp.sm index 3a075e3..8dc3a5c 100644 --- a/src/client/sysint/pint-sysdev-unexp.sm +++ b/src/client/sysint/pint-sysdev-unexp.sm @@ -7,9 +7,11 @@ #include #include #include +#ifndef WIN32 #include -#include #include +#endif +#include #include "state-machine.h" #include "client-state-machine.h" diff --git a/src/client/sysint/pint-sysint-utils.c b/src/client/sysint/pint-sysint-utils.c index 5e99f91..4e2f67b 100644 --- a/src/client/sysint/pint-sysint-utils.c +++ b/src/client/sysint/pint-sysint-utils.c @@ -4,7 +4,9 @@ * See COPYING in top-level directory. */ +#ifndef WIN32 #include +#endif #include #include "pvfs2-sysint.h" diff --git a/src/client/sysint/pint-sysint-utils.h b/src/client/sysint/pint-sysint-utils.h index a0590ef..808228b 100644 --- a/src/client/sysint/pint-sysint-utils.h +++ b/src/client/sysint/pint-sysint-utils.h @@ -11,7 +11,11 @@ #include #include +#ifdef WIN32 +#include "wincommon.h" +#else #include +#endif #include #include diff --git a/src/client/sysint/remove.sm b/src/client/sysint/remove.sm index 37fb6ac..3de652a 100644 --- a/src/client/sysint/remove.sm +++ b/src/client/sysint/remove.sm @@ -24,7 +24,8 @@ enum { REMOVE_MUST_REMOVE_DATAFILES = 1, OSD_MSGPAIR = 2001, - OSD_MDFILE_MSGPAIR = 2002 + OSD_MDFILE_MSGPAIR = 2002, + SKIP_COLLECTION_REMOVAL = 2003 }; #define HANDLE_REMOVE_ERROR(state) \ @@ -111,6 +112,21 @@ nested machine pvfs2_client_remove_helper_sm state object_remove_xfer_msgpair { jump pvfs2_msgpairarray_sm; + success => remove_collection; + default => object_remove_failure; + } + + state remove_collection + { + run remove_collection; + success => remove_collection_xfer; + SKIP_COLLECTION_REMOVAL => remove_helper_cleanup; + default => object_remove_failure; + } + + state remove_collection_xfer + { + jump pvfs2_osd_msgpairarray_sm; success => remove_helper_cleanup; default => object_remove_failure; } @@ -320,6 +336,66 @@ static PINT_sm_action remove_object_remove_setup_msgpair( return SM_ACTION_COMPLETE; } +static PINT_sm_action remove_collection( + struct PINT_smcb *smcb, job_status_s *js_p) +{ + struct PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); + int ret = -PVFS_EINVAL; + PINT_sm_msgpair_state *msg_p = NULL; + struct server_configuration_s *server_config; + PINT_llist *cur = NULL; + struct host_alias_s *cur_alias; + PVFS_BMI_addr_t addr; + + js_p->error_code = 0; + + server_config = PINT_get_server_config_struct( + sm_p->object_ref.fs_id); + PINT_put_server_config_struct(server_config); + + if (!(server_config->member_attr) || sm_p->getattr.attr.objtype != PVFS_TYPE_DIRECTORY) { + js_p->error_code = SKIP_COLLECTION_REMOVAL; + return SM_ACTION_COMPLETE; + } + + cur = server_config->host_aliases; + while(cur) + { + cur_alias = PINT_llist_head(cur); + if (!cur_alias) + { + break; + } + if(!strncmp(cur_alias->bmi_address, "osd", 3)) { + BMI_addr_lookup(&addr,cur_alias->bmi_address); + } + + cur = PINT_llist_next(cur); + } + + PINT_msgpair_init(&sm_p->msgarray_op); + msg_p = &sm_p->msgarray_op.msgpair; + + msg_p->fs_id = sm_p->object_ref.fs_id; + msg_p->retry_flag = PVFS_MSGPAIR_RETRY; + msg_p->svr_addr = addr; + msg_p->comp_fn = NULL; + + struct osd_command *command = &sm_p->msgarray_op.msgpair.osd_command; + + ret = osd_command_set_remove_collection(command, PVFS_OSD_DATA_PID, sm_p->getattr.attr.cid, 0); + + if (ret) { + osd_error_xerrno(ret, "%s: osd_command_set_remove_collection failed", + __func__); + js_p->error_code = ret; + return 1; + } + + PINT_sm_push_frame(smcb, 0, &sm_p->msgarray_op); + return SM_ACTION_COMPLETE; +} + static PINT_sm_action remove_datafile_remove_failure( struct PINT_smcb *smcb, job_status_s *js_p) { @@ -365,7 +441,7 @@ static PINT_sm_action remove_helper_cleanup( PINT_msgpairarray_destroy(&sm_p->msgarray_op); /* came directly from object_remove_setup_msgpair, no error to check */ - if (js_p->error_code == OSD_MDFILE_MSGPAIR) + if (js_p->error_code == OSD_MDFILE_MSGPAIR || js_p->error_code == SKIP_COLLECTION_REMOVAL) js_p->error_code = 0; if (js_p->error_code) diff --git a/src/client/sysint/server-get-config.sm b/src/client/sysint/server-get-config.sm index b43d921..fadb81e 100644 --- a/src/client/sysint/server-get-config.sm +++ b/src/client/sysint/server-get-config.sm @@ -6,7 +6,9 @@ #include #include +#ifndef WIN32 #include +#endif #include "client-state-machine.h" #include "pvfs2-debug.h" @@ -154,6 +156,77 @@ int PINT_server_get_config( return(error); } +#ifdef WIN32 +static int server_parse_config( + struct server_configuration_s *config, + char *fs_config_buf, + uint32_t fs_config_buf_size) +{ + int ret = 1, template_index = 1; + char temp_path[MAX_PATH], temp_file[MAX_PATH]; + DWORD rc = 1, use_temp_path, bytes; + HANDLE hFile; + + if (config == NULL) + { + return ret; + } + + assert(fs_config_buf); + + /* get the path to the TEMP directory */ + use_temp_path = GetTempPath(MAX_PATH, temp_path); + if (use_temp_path) + { + /* get temporary file name in TEMP directory */ + use_temp_path = GetTempFileName(temp_path, + "__pvfs_fs_config", 0, temp_file); + } + + if (!use_temp_path) + { + /* get temporary file name in current directory */ + rc = GetTempFileName(".", "__pvfs_fs_config", 0, temp_file); + } + + if (!rc) + { + gossip_err("Error: Cannot create temporary " + "configuration files!\n"); + return ret; + } + + hFile = CreateFile(temp_file, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, + FILE_ATTRIBUTE_NORMAL, NULL); + + if (hFile == INVALID_HANDLE_VALUE) + { + gossip_err("Error: Cannot create temporary " + "configuration files!\n"); + return ret; + } + + assert(!fs_config_buf[fs_config_buf_size - 1]); + + rc = WriteFile(hFile, fs_config_buf, fs_config_buf_size - 1, &bytes, NULL); + + CloseHandle(hFile); + + if (rc && (bytes == fs_config_buf_size - 1)) + { + ret = PINT_parse_config(config, temp_file, NULL); + } + else + { + gossip_err("Failed to write fs.conf buffer to temp file: %s: %d\n", + temp_file, GetLastError()); + } + + DeleteFile(temp_file); + + return ret; +} +#else static int server_parse_config( struct server_configuration_s *config, char *fs_config_buf, @@ -209,6 +282,7 @@ static int server_parse_config( } return ret; } +#endif static PINT_sm_action server_get_config_setup_msgpair( struct PINT_smcb *smcb, job_status_s *js_p) diff --git a/src/client/sysint/sys-create.sm b/src/client/sysint/sys-create.sm index e3f600b..94a24a3 100644 --- a/src/client/sysint/sys-create.sm +++ b/src/client/sysint/sys-create.sm @@ -82,7 +82,7 @@ machine pvfs2_client_create_sm success => create_setup_msgpair; default => cleanup; } - + state create_setup_msgpair { run create_create_setup_msgpair; @@ -356,14 +356,14 @@ PVFS_error PVFS_isys_create( /** Create a file with a specified distribution. */ PVFS_error PVFS_sys_create( - char *object_name, - PVFS_object_ref parent_ref, - PVFS_sys_attr attr, - const PVFS_credentials *credentials, - PVFS_sys_dist *dist, - PVFS_sysresp_create *resp, - PVFS_sys_layout *layout, - PVFS_hint hints) + char *object_name, /**< name of the file to create */ + PVFS_object_ref parent_ref, /**< handle of the parent dir */ + PVFS_sys_attr attr, /**< attributes of new file */ + const PVFS_credentials *credentials,/**< identity of the caller */ + PVFS_sys_dist *dist, /**< distribution of new file */ + PVFS_sysresp_create *resp, /**< response from the request */ + PVFS_sys_layout *layout, /**< selection of servers to hold file */ + PVFS_hint hints) /**< user supplied PVFS hints */ { PVFS_error ret = -PVFS_EINVAL, error = 0; PVFS_sys_op_id op_id; @@ -399,7 +399,6 @@ static PINT_sm_action create_init( struct PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); job_id_t tmp_id; - assert((js_p->error_code == 0) || (js_p->error_code == CREATE_RETRY)); @@ -414,6 +413,14 @@ static PINT_sm_action create_init( { js_p->error_code = 0; + /* call for getattr_acache_lookup (next state) */ + PINT_SM_GETATTR_STATE_FILL( + sm_p->getattr, + sm_p->object_ref, + PVFS_ATTR_COMMON_ALL|PVFS_ATTR_DIR_HINT, + PVFS_TYPE_DIRECTORY, + 0); + return job_req_sched_post_timer( sm_p->msgarray_op.params.retry_delay, smcb, 0, js_p, &tmp_id, pint_client_sm_context); @@ -557,7 +564,7 @@ static int create_datafiles_comp_fn(void *v_p, gossip_err("%s: OSD-assigned oid %llu out of range %llu-%llu\n", __func__, llu(oid), llu(first), llu(last)); sm_p->u.create.datafile_handles[index] = oid; - + /* The first datafile also happens to be the metafile */ if (is_osd_md && index == 0) { sm_p->u.create.metafile_handle = oid; @@ -569,6 +576,7 @@ static int create_datafiles_comp_fn(void *v_p, gossip_debug(GOSSIP_CLIENT_DEBUG, "Datafile handle %d is %llu\n", index, llu(sm_p->u.create.datafile_handles[index])); + return 0; } @@ -636,7 +644,7 @@ static PINT_sm_action create_create_setup_msgpair( * OK, so osd_type == OSD_MDFILE which means that we're storing the * file metadata as attributes of the first datafile. There is nothing * else to be done here so we'll go ahead and skip the - * dspace_create_xfer state and jump directly to the + * create_xfer state and jump directly to the * datafiles_setup_msgpair_array state. */ js_p->error_code = OSD_MDFILE_MSGPAIR; @@ -704,7 +712,6 @@ static PINT_sm_action create_create_setup_msgpair( js_p->error_code = OSD_MSGPAIR; } else { - /* vanilla PVFS */ PINT_SERVREQ_CREATE_FILL( msg_p->req, *sm_p->cred_p, @@ -748,7 +755,7 @@ static PINT_sm_action create_datafiles_setup_msgpair_array( sm_p->object_ref.fs_id); PINT_put_server_config_struct(server_config); is_osd = (server_config->osd_type != OSD_NONE); - + js_p->error_code = is_osd ? OSD_MSGPAIR : 0; /* allocate handle extent array objects */ @@ -777,14 +784,14 @@ static PINT_sm_action create_datafiles_setup_msgpair_array( js_p->error_code = -PVFS_ENOMEM; return SM_ACTION_COMPLETE; } - + ret = PINT_cached_config_map_servers( sm_p->object_ref.fs_id, &sm_p->u.create.num_data_files, &sm_p->u.create.layout, sm_p->u.create.data_server_addrs, sm_p->u.create.io_handle_extent_array); - + if(ret < 0) { gossip_err("create: failed to map the layout to a set of IO servers\n"); @@ -798,8 +805,8 @@ static PINT_sm_action create_datafiles_setup_msgpair_array( js_p->error_code = ret; return SM_ACTION_COMPLETE; } - - if(server_config->post_create) { + + if(!server_config->post_create) { PINT_msgpair_init(&sm_p->msgarray_op); msg_p = &sm_p->msgarray_op.msgpair; @@ -813,14 +820,18 @@ static PINT_sm_action create_datafiles_setup_msgpair_array( CCAP_OID, NULL, CCAP_OID_LEN }, { ATTR_SET, USER_COLL_PG, 1, &attrval, 8}}; - set_htonll(&attrval, COLLECTION_OID_LB); + if(!sm_p->getattr.attr.cid) { + sm_p->getattr.attr.cid = COLLECTION_OID_LB; /* root directory */ + } + set_htonll(&attrval, sm_p->getattr.attr.cid); /* * A hack in PVFS_util_init_defaults has set up an object an the * low bound of the extent array. So as we create handles, we get * them in increasing order that satisfies our extent bounds. */ - ret = osd_command_set_create(command, PVFS_OSD_DATA_PID, 0, 1); + gossip_err("%d\n", sm_p->u.create.datafile_handles[0]); + ret = osd_command_set_create(command, PVFS_OSD_DATA_PID, sm_p->u.create.datafile_handles[0], 1); if (ret) { osd_error_xerrno(ret, "%s: osd_command_set_create failed", __func__); @@ -982,7 +993,7 @@ static PINT_sm_action create_setattr_setup_msgpair( PINT_DIST_PACK_SIZE(sm_p->u.create.dist); } - if(server_config->post_create) { + if(!server_config->post_create) { msg_p->fs_id = sm_p->object_ref.fs_id; msg_p->handle = sm_p->u.create.metafile_handle; msg_p->retry_flag = PVFS_MSGPAIR_NO_RETRY; @@ -1002,6 +1013,7 @@ static PINT_sm_action create_setattr_setup_msgpair( js_p->error_code = OSD_NOT_EXIST; ret = PINT_copy_object_attr(&sm_p->u.create.cache_attr, &sm_p->msgarray_op.msgpair.req.u.setattr.attr); + if(ret != 0) { js_p->error_code = ret; @@ -1138,6 +1150,7 @@ static PINT_sm_action create_cleanup( /* Also, make sure to clear time masks. The server is responsible * for setting that. */ + sm_p->u.create.attr.mask &= (~(PVFS_ATTR_COMMON_MTIME)); sm_p->u.create.attr.mask &= (~(PVFS_ATTR_COMMON_CTIME)); sm_p->u.create.attr.mask &= (~(PVFS_ATTR_COMMON_ATIME)); @@ -1393,7 +1406,7 @@ static PINT_sm_action create_parent_getattr_inspect( gossip_debug(GOSSIP_CLIENT_DEBUG, "Setting number of datafiles to %d [requested %d]\n", sm_p->u.create.num_data_files, num_dfiles_requested); - + return SM_ACTION_COMPLETE; } diff --git a/src/client/sysint/sys-del-eattr.sm b/src/client/sysint/sys-del-eattr.sm index cb0f7b6..51ba83c 100644 --- a/src/client/sysint/sys-del-eattr.sm +++ b/src/client/sysint/sys-del-eattr.sm @@ -6,7 +6,9 @@ #include #include +#ifndef WIN32 #include +#endif #include "client-state-machine.h" #include "pvfs2-debug.h" diff --git a/src/client/sysint/sys-flush.sm b/src/client/sysint/sys-flush.sm index 148f6a1..9a25c7c 100644 --- a/src/client/sysint/sys-flush.sm +++ b/src/client/sysint/sys-flush.sm @@ -168,8 +168,13 @@ static int flush_datafile_setup_msgpairarray( attr = &sm_p->getattr.attr; assert(attr); - assert(attr->mask & PVFS_ATTR_META_DFILES); - assert(attr->u.meta.dfile_count > 0); + if(!(attr->mask & PVFS_ATTR_META_DFILES) || + !(attr->u.meta.dfile_count > 0)) + { + /* this object does not have defiles - sync not supported */ + js_p->error_code = -PVFS_EINVAL; + return SM_ACTION_COMPLETE; + } ret = PINT_msgpairarray_init(&sm_p->msgarray_op, (attr->u.meta.dfile_count + 1)); if(ret != 0) diff --git a/src/client/sysint/sys-get-eattr.sm b/src/client/sysint/sys-get-eattr.sm index fb41a8d..ac972f6 100644 --- a/src/client/sysint/sys-get-eattr.sm +++ b/src/client/sysint/sys-get-eattr.sm @@ -4,9 +4,15 @@ * See COPYING in top-level directory. */ +/** \file PVFS system calls for reading extended attributes + * \ingroup sysint + */ + #include #include +#ifndef WIN32 #include +#endif #include "client-state-machine.h" #include "pvfs2-debug.h" diff --git a/src/client/sysint/sys-getattr.sm b/src/client/sysint/sys-getattr.sm index 1c8a1c2..b2049df 100644 --- a/src/client/sysint/sys-getattr.sm +++ b/src/client/sysint/sys-getattr.sm @@ -42,7 +42,11 @@ * we grab these sizes. */ +#ifdef WIN32 +static struct profiler getattr_prof; +#else static struct profiler getattr_prof __attribute__((unused)); +#endif extern job_context_id pint_client_sm_context; @@ -366,7 +370,7 @@ static PINT_sm_action getattr_acache_lookup( &sm_p->getattr.size, &size_status); - if(sm_p->u.io.io_type == PVFS_IO_WRITE && !server_config->post_create) { + if(sm_p->u.io.io_type == PVFS_IO_WRITE && server_config->post_create) { /* the object that we are trying to write to has not been created */ js_p->error_code = IO_DO_OSD; return SM_ACTION_COMPLETE; @@ -657,8 +661,8 @@ out: sm_p->getattr.req_attrmask, sm_p->hints); js_p->error_code = 0; - } - + } + PINT_sm_push_frame(smcb, 0, &sm_p->msgarray_op); return SM_ACTION_COMPLETE; } @@ -864,7 +868,11 @@ static int getattr_object_getattr_comp_fn( static PINT_sm_action getattr_object_getattr_failure( struct PINT_smcb *smcb, job_status_s *js_p) { +#ifdef WIN32 + struct PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); +#else struct PINT_client_sm *sm_p __attribute__((unused)) = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); +#endif gossip_debug(GOSSIP_CLIENT_DEBUG ,"(%p) getattr state: getattr_object_getattr_failure\n" @@ -894,6 +902,7 @@ static PINT_sm_action getattr_datafile_getattr_setup_msgpairarray( PVFS_object_attr *attr = NULL; PINT_sm_msgpair_state *msg_p = NULL; uint64_t mirror_retry = (sm_p->getattr.attr.mask & PVFS_ATTR_META_MIRROR_DFILES); + PVFS_handle *handles; int is_osd = fsid_is_osd(sm_p->object_ref.fs_id); gossip_debug(GOSSIP_MIRROR_DEBUG,"Executing getattr_datafile_getattr_setup_msgpairarray...\n"); @@ -935,7 +944,7 @@ static PINT_sm_action getattr_datafile_getattr_setup_msgpairarray( } /* allocate handle array and populate */ - PVFS_handle *handles = malloc(sizeof(PVFS_handle) * attr->u.meta.dfile_count); + handles = malloc(sizeof(PVFS_handle) * attr->u.meta.dfile_count); if (!handles) { gossip_lerr("Unable to allocation local handles array.\n"); @@ -1056,8 +1065,12 @@ static int getattr_datafile_getattr_comp_fn( status = osd_errno_from_status( sm_p->msgarray_op.msgarray[index].osd_command.status); } else { + if (resp_p->status) + { /* tree request had a problem */ + return resp_p->status; + } + assert(resp_p->op == PVFS_SERV_TREE_GET_FILE_SIZE); - status = resp_p->status; } if (status != 0) @@ -1164,6 +1177,8 @@ static PINT_sm_action getattr_datafile_getattr_retry( int j = 0; int k = 0; int ret = 0; + uint32_t *tmp_server_nr; + PVFS_handle *tmp_handles; gossip_debug(GOSSIP_CLIENT_DEBUG, "(%p) getattr state: " @@ -1208,7 +1223,7 @@ static PINT_sm_action getattr_datafile_getattr_retry( } /*allocate temporary index-to-server array*/ - uint32_t *tmp_server_nr = malloc(sizeof(uint32_t) * retry_msg_count); + tmp_server_nr = malloc(sizeof(uint32_t) * retry_msg_count); if (!tmp_server_nr) { gossip_lerr("Unable to allocate temporary index-to-server array.\n"); @@ -1218,7 +1233,7 @@ static PINT_sm_action getattr_datafile_getattr_retry( memset(tmp_server_nr,0,sizeof(uint32_t) * retry_msg_count); /*allocate temporary handle array*/ - PVFS_handle *tmp_handles = malloc(sizeof(PVFS_handle) * retry_msg_count); + tmp_handles = malloc(sizeof(PVFS_handle) * retry_msg_count); if (!tmp_handles) { gossip_lerr("Unable to allocate temporary handle array.\n"); @@ -1368,7 +1383,7 @@ static PINT_sm_action getattr_datafile_getattr_cleanup( static PINT_sm_action getattr_acache_insert( struct PINT_smcb *smcb, job_status_s *js_p) -{ +{ struct PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); PVFS_size* tmp_size = NULL; diff --git a/src/client/sysint/sys-io.sm b/src/client/sysint/sys-io.sm index 78a435e..a8891c5 100644 --- a/src/client/sysint/sys-io.sm +++ b/src/client/sysint/sys-io.sm @@ -13,7 +13,9 @@ #include #include +#ifndef WIN32 #include +#endif #include "client-state-machine.h" #include "pvfs2-debug.h" @@ -262,7 +264,7 @@ machine pvfs2_client_io_sm { run io_analyze_results; IO_RETRY => init; - IO_ANALYZE_SIZE_RESULTS => io_analyze_size_results; + /*IO_ANALYZE_SIZE_RESULTS => io_analyze_size_results;*/ IO_GET_DATAFILE_SIZE => io_datafile_size; default => io_cleanup; } @@ -452,7 +454,6 @@ static PINT_sm_action io_init( (js_p->error_code == IO_RETRY_NODELAY)) { js_p->error_code = 0; - io_datafile_index_array_destroy(sm_p); io_contexts_destroy(sm_p); @@ -1046,8 +1047,6 @@ static int io_datafile_post_msgpairs_retry (struct PINT_smcb *smcb static int io_datafile_mirror_retry(struct PINT_smcb *smcb ,job_status_s *js_p ) { - gossip_debug(GOSSIP_MIRROR_DEBUG,"Executing %s...\n",__func__); - gossip_debug(GOSSIP_IO_DEBUG,"Executing io_datafile_mirror_retry...\n"); struct PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); PVFS_object_attr *attr = &(sm_p->getattr.attr); PVFS_metafile_attr *meta = &(attr->u.meta); @@ -1059,6 +1058,9 @@ static int io_datafile_mirror_retry(struct PINT_smcb *smcb int i,j,ret; char *enc_req_bytes = NULL; + gossip_debug(GOSSIP_MIRROR_DEBUG,"Executing %s...\n",__func__); + gossip_debug(GOSSIP_IO_DEBUG,"Executing io_datafile_mirror_retry...\n"); + /* Have we exhausted the number of retries */ if (io->retry_count >= sm_p->msgarray_op.params.retry_limit) { @@ -1498,16 +1500,20 @@ static PINT_sm_action io_datafile_complete_operations( || sm_p->u.io.flow_completion_count || sm_p->u.io.write_ack_completion_count) { if (PINT_smcb_cancelled(smcb)) + { gossip_debug(GOSSIP_IO_DEBUG, "detected I/O cancellation with " "%d flows and %d write acks pending\n", sm_p->u.io.flow_completion_count, sm_p->u.io.write_ack_completion_count); + } else + { gossip_debug(GOSSIP_IO_DEBUG, " %d flows pending, %d write acks " "pending, %d msgpair\n", sm_p->u.io.flow_completion_count, sm_p->u.io.write_ack_completion_count, sm_p->u.io.msgpair_completion_count); + } return SM_ACTION_DEFERRED; } diff --git a/src/client/sysint/sys-list-eattr.sm b/src/client/sysint/sys-list-eattr.sm index 7fb794f..1510e9d 100644 --- a/src/client/sysint/sys-list-eattr.sm +++ b/src/client/sysint/sys-list-eattr.sm @@ -6,7 +6,9 @@ #include #include +#ifndef WIN32 #include +#endif #include "client-state-machine.h" #include "pvfs2-debug.h" @@ -78,7 +80,8 @@ PVFS_error PVFS_isys_listeattr( /* the resp key array is used to determine how much we allocate, * let's enfore the max key buffer of PVFS_MAX_XATTR_NAMELEN */ - if( resp_p->nkey > PVFS_REQ_LIMIT_EATTR_LIST ) + + if( nkey > PVFS_REQ_LIMIT_EATTR_LIST ) { gossip_debug(GOSSIP_CLIENT_DEBUG, "%s: requested number of keys, %d, " " is larger than the maximum of %d\n", __func__, @@ -86,7 +89,7 @@ PVFS_error PVFS_isys_listeattr( return ret; } - for( i=0; i < resp_p->nkey; i++ ) + for( i=0; i < nkey; i++ ) { if( resp_p->key_array[i].buffer_sz > PVFS_MAX_XATTR_NAMELEN ) { diff --git a/src/client/sysint/sys-lookup.sm b/src/client/sysint/sys-lookup.sm index 27087e5..699c761 100644 --- a/src/client/sysint/sys-lookup.sm +++ b/src/client/sysint/sys-lookup.sm @@ -171,9 +171,11 @@ static int initialize_context( if(lookup_sm->current_context == lookup_sm->context_count) { + /* we have usee the last available context */ lookup_sm->context_count++; if(lookup_sm->context_count == 1) { + /* first context, so allocate one */ lookup_sm->contexts = malloc(sizeof(PINT_client_lookup_sm_ctx)); if(!lookup_sm->contexts) { @@ -182,6 +184,7 @@ static int initialize_context( } else { + /* no the first one, so realloc to get one more */ lookup_sm->contexts = realloc(lookup_sm->contexts, sizeof(PINT_client_lookup_sm_ctx) * lookup_sm->context_count); @@ -192,203 +195,211 @@ static int initialize_context( } } - if (pathname && (lookup_sm->current_context > -1)) + if (!pathname) { - ctx = &lookup_sm->contexts[lookup_sm->current_context]; - assert(ctx); + return ret; + } + pathlen = strlen(pathname); + num_segments = PINT_string_count_segments(pathname); - prev_ctx_index = (lookup_sm->current_context - 1); + if ((pathlen == 0) || (num_segments == 0)) + { + return ret; + } - pathlen = strlen(pathname); - num_segments = PINT_string_count_segments(pathname); + if ((pathlen > (PVFS_REQ_LIMIT_PATH_NAME_BYTES - 1)) || + (num_segments > PVFS_REQ_LIMIT_PATH_SEGMENT_COUNT)) + { + gossip_err("Filename %s is too long\n", pathname); + return -PVFS_ENAMETOOLONG; + } - if ((pathlen == 0) || (num_segments == 0)) - { - return ret; - } + /* initialize new context */ + if (lookup_sm->current_context < 0) + { + return ret; + } + ctx = &lookup_sm->contexts[lookup_sm->current_context]; + assert(ctx); - if ((pathlen > (PVFS_REQ_LIMIT_PATH_NAME_BYTES - 1)) || - (num_segments > PVFS_REQ_LIMIT_PATH_SEGMENT_COUNT)) - { - gossip_err("Filename %s is too long\n", pathname); - return -PVFS_ENAMETOOLONG; - } + prev_ctx_index = (lookup_sm->current_context - 1); - memset(ctx, 0, sizeof(PINT_client_lookup_sm_ctx)); + memset(ctx, 0, sizeof(PINT_client_lookup_sm_ctx)); - ctx->current_segment = 0; - ctx->total_segments = 0; - ctx->ctx_starting_refn = ctx_starting_refn; + ctx->current_segment = 0; + ctx->total_segments = 0; + ctx->ctx_starting_refn = ctx_starting_refn; - /* initialize all segments within the context */ - orig_pathname = strdup(pathname); - gossip_debug(GOSSIP_LOOKUP_DEBUG, " original pathname is: %s\n", + /* initialize all segments within the context */ + orig_pathname = strdup(pathname); + gossip_debug(GOSSIP_LOOKUP_DEBUG, " original pathname is: %s\n", orig_pathname); - while(!PINT_string_next_segment(pathname,&cur_seg_name,&state)) - { - /* grab the next segment in the context to fill in */ - cur_seg = &(ctx->segments[cur_seg_index]); - assert(cur_seg); - memset(cur_seg, 0, sizeof(PINT_client_lookup_sm_segment)); + while(!PINT_string_next_segment(pathname, &cur_seg_name, &state)) + { + /* grab the next segment in the context to fill in */ + cur_seg = &(ctx->segments[cur_seg_index]); + assert(cur_seg); + memset(cur_seg, 0, sizeof(PINT_client_lookup_sm_segment)); - gossip_debug(GOSSIP_LOOKUP_DEBUG, " cur_seg_name[%d]: %s\n", - cur_seg_index, cur_seg_name); - gossip_debug(GOSSIP_LOOKUP_DEBUG, " pathname is: %s\n", - pathname); + gossip_debug(GOSSIP_LOOKUP_DEBUG, " cur_seg_name[%d]: %s\n", + cur_seg_index, cur_seg_name); + gossip_debug(GOSSIP_LOOKUP_DEBUG, " pathname is: %s\n", + pathname); - if (strcmp(cur_seg_name,".") == 0) - { - /* reset the count of consecutive dot dot segments */ - num_consecutive_prev_ctx_dot_dots = 0; + if (strcmp(cur_seg_name,".") == 0) + { + /* reset the count of consecutive dot dot segments */ + num_consecutive_prev_ctx_dot_dots = 0; - gossip_debug(GOSSIP_LOOKUP_DEBUG, + gossip_debug(GOSSIP_LOOKUP_DEBUG, " ignoring useless segment\n"); - continue; - } - else if (strcmp(cur_seg_name,"..") == 0) + continue; + } + else if (strcmp(cur_seg_name,"..") == 0) + { + /* + if this isn't true, we need to + grab the previous context's previous segment + + if this weren't true, we'd normally: + assert(cur_seg_index > 0); + */ + if ((cur_seg_index < 1) || + (num_consecutive_prev_ctx_dot_dots > 0)) { - /* - if this isn't true, we need to - grab the previous context's previous segment + PINT_client_lookup_sm_segment *prev_ctx_prev_seg; + + gossip_debug( + GOSSIP_LOOKUP_DEBUG, " got a '..' segment that " + "requires attention of the previous context\n"); - if this weren't true, we'd normally: - assert(cur_seg_index > 0); + init_next_prev_segment: + /* + grab the previous context to access the segments + within it, assuming a previous context is available */ - if ((cur_seg_index < 1) || - (num_consecutive_prev_ctx_dot_dots > 0)) + if (prev_ctx_index < 0) { - PINT_client_lookup_sm_segment *prev_ctx_prev_seg; + gossip_debug(GOSSIP_LOOKUP_DEBUG, "there are no " + "more previous contexts available: " + "failing lookup\n"); + free(orig_pathname); + return -PVFS_ENOENT; + } - gossip_debug( - GOSSIP_LOOKUP_DEBUG, " got a '..' segment that " - "requires attention of the previous context\n"); - - init_next_prev_segment: - /* - grab the previous context to access the segments - within it, assuming a previous context is - available - */ - if (prev_ctx_index < 0) - { - gossip_debug(GOSSIP_LOOKUP_DEBUG, "there are no " - "more previous contexts available: " - "failing lookup\n"); - free(orig_pathname); - return -PVFS_ENOENT; - } + prev_ctx = &lookup_sm->contexts[prev_ctx_index]; + assert(prev_ctx); + assert(prev_ctx->current_segment > 0); - prev_ctx = &lookup_sm->contexts[prev_ctx_index]; - assert(prev_ctx); - assert(prev_ctx->current_segment > 0); + num_consecutive_prev_ctx_dot_dots++; + gossip_debug( + GOSSIP_LOOKUP_DEBUG, "num consecutive '..' " + "segments requiring the previous segment " + "is now %d\n", num_consecutive_prev_ctx_dot_dots); - num_consecutive_prev_ctx_dot_dots++; - gossip_debug( - GOSSIP_LOOKUP_DEBUG, "num consecutive '..' " - "segments requiring the previous segment " - "is now %d\n", num_consecutive_prev_ctx_dot_dots); - - /* - further, if we have a number of consecutive '..' - segments, we may need to keep backing up into - the previous contexts' space - */ - if (prev_ctx->current_segment - - num_consecutive_prev_ctx_dot_dots < 0) + /* + further, if we have a number of consecutive '..' + segments, we may need to keep backing up into + the previous contexts' space + */ + if (prev_ctx->current_segment - + num_consecutive_prev_ctx_dot_dots < 0) + { + /* skip to next previous context, if any */ + if (prev_ctx_index > -1) { - /* skip to next previous context, if any */ - if (prev_ctx_index > -1) - { - /* - bump down dot dot count since it wasn't - used yet if we got here - */ - num_consecutive_prev_ctx_dot_dots--; - prev_ctx_index--; - goto init_next_prev_segment; - } - gossip_debug( - GOSSIP_LOOKUP_DEBUG, "there are no more segments " - "in the previous context: failing lookup\n"); - free(orig_pathname); - return -PVFS_ENOENT; + /* + bump down dot dot count since it wasn't + used yet if we got here + */ + num_consecutive_prev_ctx_dot_dots--; + prev_ctx_index--; + goto init_next_prev_segment; } - - prev_ctx_prev_seg = &prev_ctx->segments[ - prev_ctx->current_segment - - num_consecutive_prev_ctx_dot_dots]; - assert(prev_ctx_prev_seg); - - /* - instead of decrementing the seg index and - continuing, we need to replace the last segment - copied from the last context in this case. (so - we drop through to segment init) - */ - ctx_starting_refn = - prev_ctx_prev_seg->seg_starting_refn; - cur_seg_name = prev_ctx_prev_seg->seg_name; gossip_debug( - GOSSIP_LOOKUP_DEBUG, - "using previous segment: %s\n", cur_seg_name); - - cur_seg_index--; - } - else - { - gossip_debug(GOSSIP_LOOKUP_DEBUG, - " got a '..' segment\n"); - cur_seg_index--; - continue; + GOSSIP_LOOKUP_DEBUG, "there are no more segments " + "in the previous context: failing lookup\n"); + free(orig_pathname); + return -PVFS_ENOENT; } + + prev_ctx_prev_seg = &prev_ctx->segments[ + prev_ctx->current_segment - + num_consecutive_prev_ctx_dot_dots]; + assert(prev_ctx_prev_seg); + + /* + instead of decrementing the seg index and + continuing, we need to replace the last segment + copied from the last context in this case. (so + we drop through to segment init) + */ + ctx_starting_refn = + prev_ctx_prev_seg->seg_starting_refn; + cur_seg_name = prev_ctx_prev_seg->seg_name; + gossip_debug( + GOSSIP_LOOKUP_DEBUG, + "using previous segment: %s\n", cur_seg_name); + + cur_seg_index--; } else { - /* reset the count of consecutive dot dot segments */ - num_consecutive_prev_ctx_dot_dots = 0; + gossip_debug(GOSSIP_LOOKUP_DEBUG, + " got a '..' segment\n"); + cur_seg_index--; + continue; } + } + else + { + /* reset the count of consecutive dot dot segments */ + num_consecutive_prev_ctx_dot_dots = 0; + } - /* - fill in the current segment now. the first segment - MUST have the same starting refn as the context - */ - if (cur_seg_index == 0) - { - cur_seg->seg_starting_refn = ctx_starting_refn; - } - if (cur_seg->seg_name) - { - free(cur_seg->seg_name); - } - cur_seg->seg_name = strdup(cur_seg_name); - assert(cur_seg->seg_name); - - slash_str = orig_pathname; - for (i = 0; i < cur_seg_index; i++) { - slash_str = strchr(slash_str, '/'); - if (slash_str == NULL) { - break; - } - slash_str++; - } - /* seg_remaining = strstr(orig_pathname, cur_seg_name); */ - seg_remaining = slash_str; - if (seg_remaining) - { - gossip_debug(GOSSIP_LOOKUP_DEBUG, - " *seg_remaining is: %s\n", seg_remaining); + /* + fill in the current segment now. the first segment + MUST have the same starting refn as the context + */ + if (cur_seg_index == 0) + { + cur_seg->seg_starting_refn = ctx_starting_refn; + } + if (cur_seg->seg_name) + { + free(cur_seg->seg_name); + } + cur_seg->seg_name = strdup(cur_seg_name); + assert(cur_seg->seg_name); - cur_seg->seg_remaining = strdup(seg_remaining); - assert(cur_seg->seg_remaining); - } - else + slash_str = orig_pathname; + for (i = 0; i < cur_seg_index; i++) + { + slash_str = strchr(slash_str, '/'); + if (slash_str == NULL) { - cur_seg->seg_remaining = NULL; + break; } + slash_str++; + } + /* seg_remaining = strstr(orig_pathname, cur_seg_name); */ + seg_remaining = slash_str; + if (seg_remaining) + { + gossip_debug(GOSSIP_LOOKUP_DEBUG, + " *seg_remaining is: %s\n", seg_remaining); - cur_seg_index++; + cur_seg->seg_remaining = strdup(seg_remaining); + assert(cur_seg->seg_remaining); + } + else + { + cur_seg->seg_remaining = NULL; } - free(orig_pathname); + + cur_seg_index++; + } + free(orig_pathname); #if 0 /* DEBUGGING ONLY */ @@ -405,10 +416,9 @@ static int initialize_context( } #endif - ctx->total_segments = cur_seg_index; - assert(ctx->current_segment == 0); - ret = 0; - } + ctx->total_segments = cur_seg_index; + assert(ctx->current_segment == 0); + ret = 0; return ret; } @@ -497,6 +507,13 @@ PVFS_error PVFS_isys_ref_lookup( gossip_err("%s: failed to init context (path = %s)\n", __func__, relative_pathname); + if (ret == -PVFS_ENOENT && sm_p->u.lookup.lookup_resp->error_path) + { + /* copy out error path */ + strncpy(sm_p->u.lookup.lookup_resp->error_path, + relative_pathname, + sm_p->u.lookup.lookup_resp->error_path_size); + } PVFS_util_release_credentials(sm_p->cred_p); PINT_smcb_free(smcb); return ret; @@ -629,9 +646,10 @@ static int lookup_segment_query_ncache(struct PINT_smcb *smcb, parent_ref.fs_id = cur_seg->seg_starting_refn.fs_id; parent_ref.handle = cur_seg->seg_starting_refn.handle; - + ret = PINT_ncache_get_cached_entry(cur_seg->seg_name, &object_ref, &parent_ref); + if (ret == 0) { gossip_debug(GOSSIP_NCACHE_DEBUG, @@ -707,7 +725,7 @@ static PINT_sm_action lookup_segment_setup_msgpair(struct PINT_smcb *smcb, msg_p->handle = cur_seg->seg_starting_refn.handle; msg_p->retry_flag = PVFS_MSGPAIR_RETRY; msg_p->comp_fn = lookup_segment_lookup_comp_fn; - + ret = PINT_cached_config_map_to_server( &msg_p->svr_addr, msg_p->handle, msg_p->fs_id); @@ -906,6 +924,13 @@ static PINT_sm_action lookup_segment_handle_relative_link( cur_seg->seg_starting_refn); if (ret) { + if (ret == -PVFS_ENOENT && sm_p->u.lookup.lookup_resp->error_path) + { + /* copy out error path */ + strncpy(sm_p->u.lookup.lookup_resp->error_path, + relative_symlink_target, + sm_p->u.lookup.lookup_resp->error_path_size); + } js_p->error_code = ret; } return SM_ACTION_COMPLETE; @@ -945,7 +970,17 @@ static PINT_sm_action lookup_segment_handle_absolute_link( gossip_debug(GOSSIP_CLIENT_DEBUG, "PVFS_util_resolve returned %d on %s\n", ret, cur_seg->seg_attr.u.sym.target_path); - js_p->error_code = 1; + if (ret == -PVFS_ENOENT && sm_p->u.lookup.lookup_resp->error_path) + { + /* copy out error path */ + strncpy(sm_p->u.lookup.lookup_resp->error_path, + cur_seg->seg_attr.u.sym.target_path, + /*absolute_symlink_target,*/ + sm_p->u.lookup.lookup_resp->error_path_size); + /* set special error code */ + ret = -PVFS_ENOTPVFS; + } + js_p->error_code = ret; return SM_ACTION_COMPLETE; } @@ -964,10 +999,17 @@ static PINT_sm_action lookup_segment_handle_absolute_link( assert(ret == 0); ret = initialize_context(&sm_p->u.lookup, - absolute_symlink_target+1, + absolute_symlink_target + 1, root_refn); if (ret) { + if (ret == -PVFS_ENOENT && sm_p->u.lookup.lookup_resp->error_path) + { + /* copy out error path */ + strncpy(sm_p->u.lookup.lookup_resp->error_path, + absolute_symlink_target + 1, + sm_p->u.lookup.lookup_resp->error_path_size); + } js_p->error_code = ret; } return SM_ACTION_COMPLETE; diff --git a/src/client/sysint/sys-mkdir.sm b/src/client/sysint/sys-mkdir.sm index b984824..bc4dfe1 100644 --- a/src/client/sysint/sys-mkdir.sm +++ b/src/client/sysint/sys-mkdir.sm @@ -34,7 +34,8 @@ enum { MKDIR_RETRY = 180, MKDIR_SKIP_EATTR = 181, - OSD_MKDIR_MSGPAIR = 2001 + OSD_MKDIR_MSGPAIR = 2001, + CREATE_COLLECTION = 2002 }; static int mkdir_msg_comp_fn( @@ -54,6 +55,7 @@ machine pvfs2_client_mkdir_sm state init { run mkdir_init; + CREATE_COLLECTION => create_collection; default => parent_getattr; } @@ -122,7 +124,7 @@ machine pvfs2_client_mkdir_sm state mkdir_crdirent_xfer_msgpair { jump pvfs2_msgpairarray_sm; - success => create_collection; + success => cleanup; default => mkdir_crdirent_failure; } @@ -136,7 +138,7 @@ machine pvfs2_client_mkdir_sm state create_collection_xfer_msgpair { jump pvfs2_osd_msgpairarray_sm; - success => cleanup; + success => parent_getattr; default => mkdir_crdirent_failure; } @@ -280,11 +282,19 @@ static PINT_sm_action mkdir_init( { struct PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); job_id_t tmp_id; + struct server_configuration_s *server_config; + + server_config = PINT_get_server_config_struct( + sm_p->object_ref.fs_id); + PINT_put_server_config_struct(server_config); + + if (server_config->member_attr) + js_p->error_code = CREATE_COLLECTION; gossip_debug(GOSSIP_CLIENT_DEBUG, "mkdir state: init\n"); assert((js_p->error_code == 0) || - (js_p->error_code == MKDIR_RETRY)); + (js_p->error_code == MKDIR_RETRY) || (js_p->error_code == CREATE_COLLECTION)); PINT_SM_GETATTR_STATE_FILL( sm_p->getattr, @@ -385,6 +395,8 @@ static PINT_sm_action mkdir_msg_setup_msgpair( return SM_ACTION_COMPLETE; } + sm_p->u.mkdir.sys_attr.cid = sm_p->object_ref.cid; + PINT_SERVREQ_MKDIR_FILL( msg_p->req, *sm_p->cred_p, @@ -516,7 +528,7 @@ static int create_collection_comp_fn(void *v_p, osd_error_xerrno(ret, "%s: attr_resolve failed", __func__); } - get_ntohll(sm_p->msgarray_op.msgpair.osd_command.attr[0].val); + sm_p->object_ref.cid = get_ntohll(sm_p->msgarray_op.msgpair.osd_command.attr[0].val); osd_command_attr_free(&sm_p->msgarray_op.msgpair.osd_command); return 0; @@ -791,8 +803,13 @@ static PINT_sm_action mkdir_seteattr_setup_msgpair( js_p->error_code = -PVFS_ENOMEM; return SM_ACTION_COMPLETE; } +#ifdef WIN32 + _snprintf((char*)sm_p->u.mkdir.val_array[cur_index].buffer, + 16, "%d", sm_p->getattr.attr.u.dir.hint.dfile_count); +#else snprintf((char*)sm_p->u.mkdir.val_array[cur_index].buffer, 16, "%d", sm_p->getattr.attr.u.dir.hint.dfile_count); +#endif sm_p->u.mkdir.val_array[cur_index].buffer_sz = strlen((char*)sm_p->u.mkdir.val_array[cur_index].buffer) + 1; diff --git a/src/client/sysint/sys-osd-io.sm b/src/client/sysint/sys-osd-io.sm index fb03fc2..44b6218 100755 --- a/src/client/sysint/sys-osd-io.sm +++ b/src/client/sysint/sys-osd-io.sm @@ -36,7 +36,9 @@ enum { LOOP_NEXT_CHUNK = 1012, - OSD_CREATE_WRITE = 2001 + OSD_CREATE_WRITE = 2001, + CREATE_AND_WRITE_DONE = 2002, + CREATE_AND_WRITE_NOT_DONE = 2003 }; static int osd_io_completion_fn(void *user_args, @@ -47,7 +49,6 @@ static int create_and_write_comp_fn(void *v_p, static int setattr_comp_fn(void *v_p, struct PVFS_server_resp *resp_p, int index); - %% nested machine pvfs2_client_osd_io_sm @@ -69,7 +70,7 @@ nested machine pvfs2_client_osd_io_sm state xfer_create_and_write { jump pvfs2_osd_msgpairarray_sm; - success => setattr_setup_msgpair; + success => maybe_xfer_more; default => cleanup; } @@ -105,6 +106,8 @@ nested machine pvfs2_client_osd_io_sm { run osd_io_maybe_xfer_more; LOOP_NEXT_CHUNK => setup_msgpairs; + CREATE_AND_WRITE_DONE => setattr_setup_msgpair; + CREATE_AND_WRITE_NOT_DONE => create_and_write; default => analyze_results; } @@ -130,12 +133,6 @@ static int osd_io_init(struct PINT_smcb *smcb, job_status_s *js_p) PVFS_object_attr *attr = &sm_p->getattr.attr; int i, ret; - if(io->buffer && !io->datafile_count) { - /* object has not been created */ - js_p->error_code = OSD_CREATE_WRITE; - return SM_ACTION_COMPLETE; - } - ret = PINT_msgpairarray_init(&sm_p->msgarray_op, io->datafile_count); if (ret) goto out; @@ -168,11 +165,18 @@ static int osd_io_init(struct PINT_smcb *smcb, job_status_s *js_p) io->file_data = malloc(io->datafile_count * sizeof(*io->file_data)); if (!io->file_data) goto out; + io->file_data[0].fsize = 0; io->file_data[0].server_ct = attr->u.meta.dfile_count; io->file_data[0].dist = attr->u.meta.dist; io->file_data[0].extend_flag = 1; /* always disable fsize checking */ + if(io->buffer && !io->datafile_count) { + /* object has not been created */ + ret = OSD_CREATE_WRITE; + goto out; + } + for (i=0; idatafile_count; i++) { PVFS_handle datafile_handle = attr->u.meta.dfile_array[ io->datafile_index_array[i]]; @@ -246,7 +250,6 @@ static int osd_io_setup_msgpairs(struct PINT_smcb *smcb, job_status_s *js_p) gossip_debug(GOSSIP_IO_DEBUG, "%s: SCSI buffer %lld cant handle %lld\n", __func__, lld(KERNEL_BUFSIZE), lld(sbytemax)); sbytemax = KERNEL_BUFSIZE; - } /* for each datafile/io server/osd write ALL of its data */ @@ -259,7 +262,6 @@ static int osd_io_setup_msgpairs(struct PINT_smcb *smcb, job_status_s *js_p) datafile_handle = attr->u.meta.dfile_array[io->datafile_index_array[i]]; - if (PINT_REQUEST_DONE(&io->file_req_state[i]) || io->short_read[i]) { gossip_debug(GOSSIP_IO_DEBUG, "%s: Nothing to do for server %d\n", __func__, i); @@ -375,7 +377,7 @@ static int osd_io_setup_msgpairs(struct PINT_smcb *smcb, job_status_s *js_p) sm_p->msgarray_op.msgarray[i].osd_sgl = NULL; p = io->buffer; - + if (sresult.segs == 1) { /* contiguous server buff to write to */ if (csegs_count == 1) { p += offseta[0]; @@ -658,7 +660,17 @@ static PINT_sm_action create_and_write_setup_msgpair( js_p->error_code = 0; - len = sm_p->u.io.mem_req->aggregate_size - sm_p->u.io.file_req_offset; + if(sm_p->u.io.mem_req->aggregate_size <= KERNEL_BUFSIZE) { + /* then we can complete the write process in a single run */ + len = sm_p->u.io.mem_req->aggregate_size; + } else { + /* we need to make multiple calls to complete write */ + if((sm_p->u.io.mem_req->aggregate_size - sm_p->u.io.total_size) > KERNEL_BUFSIZE) { + len = KERNEL_BUFSIZE; + } else { + len = sm_p->u.io.mem_req->aggregate_size - sm_p->u.io.total_size; + } + } sm_p->u.io.datafile_count = 1; sm_p->u.create.layout.algorithm = PVFS_SYS_LAYOUT_ROUND_ROBIN; @@ -723,33 +735,46 @@ static PINT_sm_action create_and_write_setup_msgpair( struct attribute_list attrs[] = {{ ATTR_GET, CUR_CMD_ATTR_PG, CCAP_OID, NULL, CCAP_OID_LEN }, { ATTR_SET, USER_COLL_PG, 1, &attrval, 8}}; - set_htonll(&attrval, COLLECTION_OID_LB); + if(!sm_p->object_ref.cid) { + sm_p->object_ref.cid = COLLECTION_OID_LB; /* root directory */ + } + set_htonll(&attrval, sm_p->object_ref.cid); - ret = osd_command_set_create_and_write(command, PVFS_OSD_DATA_PID, 0, len, 0); - command->outdata = sm_p->u.io.buffer; - command->outlen = len; + if(sm_p->u.io.mem_req->aggregate_size > KERNEL_BUFSIZE && sm_p->u.io.total_size) { + /* this means we are completing the write operation in multiple steps + * and we have already gone through the initial create_and_write step + * thus we just need to write the remaining data in the buffer + */ + ret = osd_command_set_write(command, PVFS_OSD_DATA_PID, sm_p->u.create.datafile_handles[0], len, sm_p->u.io.total_size); + command->outdata = sm_p->u.io.buffer + sm_p->u.io.total_size; + command->outlen = len; + } else { + ret = osd_command_set_create_and_write(command, PVFS_OSD_DATA_PID, 0, len, 0); + command->outdata = sm_p->u.io.buffer; + command->outlen = len; - if (ret) { - osd_error_xerrno(ret, "%s: osd_command_set_create failed", + if (ret) { + osd_error_xerrno(ret, "%s: osd_command_set_create failed", __func__); - js_p->error_code = ret; - return 1; - } + js_p->error_code = ret; + return 1; + } - ret = osd_command_attr_build(command, attrs, 2); - if (ret) { - osd_error_xerrno(ret, "%s: osd_command_attr_build failed", + ret = osd_command_attr_build(command, attrs, 2); + if (ret) { + osd_error_xerrno(ret, "%s: osd_command_attr_build failed", __func__); - js_p->error_code = ret; - return 1; + js_p->error_code = ret; + return 1; + } } } msg_p->fs_id = sm_p->object_ref.fs_id; msg_p->handle = sm_p->u.create.io_handle_extent_array[0]. extent_array[0].first; - msg_p->retry_flag = PVFS_MSGPAIR_NO_RETRY; msg_p->comp_fn = create_and_write_comp_fn; + msg_p->retry_flag = PVFS_MSGPAIR_NO_RETRY; msg_p->svr_addr = sm_p->u.create.data_server_addrs[0]; PINT_sm_push_frame(smcb, 0, &sm_p->msgarray_op); @@ -775,28 +800,32 @@ static int create_and_write_comp_fn(void *v_p, return status; } - ret = osd_command_attr_resolve(&sm_p->msgarray_op.msgpair.osd_command); - if (ret) { - osd_error_xerrno(ret, "%s: attr_resolve failed", __func__); - } - - oid = get_ntohll(sm_p->msgarray_op.msgarray[index].osd_command.attr[0].val); + if(!(sm_p->u.io.mem_req->aggregate_size > KERNEL_BUFSIZE && sm_p->u.io.total_size)) { + ret = osd_command_attr_resolve(&sm_p->msgarray_op.msgpair.osd_command); + if (ret) { + osd_error_xerrno(ret, "%s: attr_resolve failed", __func__); + } - /* allocate memory for the data handles if we haven't already */ - if (sm_p->u.create.datafile_handles == NULL) - { - sm_p->u.create.datafile_handles = (PVFS_handle *)malloc( - sm_p->u.io.datafile_count * sizeof(PVFS_handle)); + oid = get_ntohll(sm_p->msgarray_op.msgarray[index].osd_command.attr[0].val); + /* allocate memory for the data handles if we haven't already */ if (sm_p->u.create.datafile_handles == NULL) { - gossip_err("create: Failed to allocate data handle array\n"); - return -PVFS_ENOMEM; + sm_p->u.create.datafile_handles = (PVFS_handle *)malloc( + sm_p->u.io.datafile_count * sizeof(PVFS_handle)); + + if (sm_p->u.create.datafile_handles == NULL) + { + gossip_err("create: Failed to allocate data handle array\n"); + return -PVFS_ENOMEM; + } + memset(sm_p->u.create.datafile_handles, 0, + sm_p->u.io.datafile_count * sizeof(PVFS_handle)); } - memset(sm_p->u.create.datafile_handles, 0, - sm_p->u.io.datafile_count * sizeof(PVFS_handle)); + sm_p->u.create.datafile_handles[index] = oid; } - sm_p->u.create.datafile_handles[index] = oid; + + sm_p->u.io.total_size += sm_p->msgarray_op.msgpair.osd_command.outlen; return 0; } @@ -834,7 +863,7 @@ static PINT_sm_action setattr_setup_msgpair( msg_p->req.u.setattr.attr.owner = sm_p->getattr.attr.owner; msg_p->req.u.setattr.attr.perms = sm_p->getattr.attr.perms; msg_p->req.u.setattr.attr.mask = sm_p->getattr.attr.mask; - + msg_p->fs_id = sm_p->object_ref.fs_id; msg_p->handle = sm_p->object_ref.handle; msg_p->retry_flag = PVFS_MSGPAIR_NO_RETRY; @@ -857,23 +886,13 @@ static int setattr_comp_fn(void *v_p, struct PVFS_server_resp *resp_p, int index) { - int res, status; - PINT_smcb *smcb = v_p; - PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_MSGPAIR_PARENT_SM); + int status; gossip_debug(GOSSIP_CLIENT_DEBUG, "create_setattr_comp_fn\n"); assert(resp_p->op == PVFS_SERV_SETATTR); status = resp_p->status; - res = PINT_copy_object_attr(&sm_p->u.create.cache_attr, - &sm_p->msgarray_op.msgpair.req.u.setattr.attr); - - if(res != 0) - { - return res; - } - return status; } @@ -983,6 +1002,11 @@ static int osd_io_maybe_xfer_more(struct PINT_smcb *smcb, job_status_s *js_p) struct PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); struct PINT_client_io_sm *io = &sm_p->u.io; int i, more = 1; + struct server_configuration_s *server_config; + + server_config = PINT_get_server_config_struct( + sm_p->object_ref.fs_id); + PINT_put_server_config_struct(server_config); gossip_debug(GOSSIP_IO_DEBUG, "%s: total %lld want %lld.\n", __func__, lld(io->total_size), lld(io->mem_req->aggregate_size)); @@ -990,6 +1014,16 @@ static int osd_io_maybe_xfer_more(struct PINT_smcb *smcb, job_status_s *js_p) if (io->total_size == io->mem_req->aggregate_size) more = 0; + if(server_config->post_create) { + /* we are doing most create */ + if(more) { + /* not done with write */ + js_p->error_code = CREATE_AND_WRITE_NOT_DONE; + } else { + js_p->error_code = CREATE_AND_WRITE_DONE; + } + return 1; + } /* * If all short read, done. @@ -1093,7 +1127,7 @@ out: } static int osd_io_cleanup(struct PINT_smcb *smcb, job_status_s *js_p) -{ +{ struct PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); struct PINT_client_io_sm *io = &sm_p->u.io; struct server_configuration_s *server_config; @@ -1102,21 +1136,16 @@ static int osd_io_cleanup(struct PINT_smcb *smcb, job_status_s *js_p) sm_p->object_ref.fs_id); PINT_put_server_config_struct(server_config); - if(server_config->post_create) { - free(sm_p->msgarray_op.msgarray); - sm_p->msgarray_op.msgarray = NULL; - sm_p->msgarray_op.count = 0; - PINT_free_request_states(io->file_req_state); - PINT_free_request_states(io->mem_req_state); - PINT_free_request_state(io->temp_req_state); - free(io->short_read); - free(io->file_data); - - /* return this to PVFS_sys_io */ - io->io_resp_p->total_completed = sm_p->u.io.total_size; - } - - io->io_resp_p->total_completed = sm_p->u.io.mem_req->aggregate_size - sm_p->u.io.file_req_offset;; + sm_p->msgarray_op.msgarray = NULL; + sm_p->msgarray_op.count = 0; + PINT_free_request_states(io->file_req_state); + PINT_free_request_states(io->mem_req_state); + PINT_free_request_state(io->temp_req_state); + free(io->short_read); + free(io->file_data); + + /* return this to PVFS_sys_io */ + io->io_resp_p->total_completed = sm_p->u.io.total_size; return 1; } diff --git a/src/client/sysint/sys-readdir.sm b/src/client/sysint/sys-readdir.sm index ce4d732..41bcbd2 100644 --- a/src/client/sysint/sys-readdir.sm +++ b/src/client/sysint/sys-readdir.sm @@ -237,6 +237,12 @@ static PINT_sm_action readdir_msg_setup_msgpair( } js_p->error_code = 0; + if(!sm_p->getattr.attr.cid) { + sm_p->object_ref.cid = COLLECTION_OID_LB; /* root directory */ + } else { + sm_p->object_ref.cid = sm_p->getattr.attr.cid; + } + gossip_debug(GOSSIP_READDIR_DEBUG," readdir: posting readdir req\n"); gossip_debug( diff --git a/src/client/sysint/sys-readdirplus.sm b/src/client/sysint/sys-readdirplus.sm index a603213..3c7f772 100644 --- a/src/client/sysint/sys-readdirplus.sm +++ b/src/client/sysint/sys-readdirplus.sm @@ -382,6 +382,14 @@ static int create_partition_handles(PVFS_fs_id fsid, int input_handle_count, int ret; ret = PINT_cached_config_map_to_server(&tmp_svr_addr, input_handle_array[i].handle, fsid); + + if( ret != 0 ) + { + gossip_debug(GOSSIP_CLIENT_DEBUG, "%s: failure mapping " + "handle to server\n", __func__); + return ret; + } + /* unique server address to find index */ is_unique_server(tmp_svr_addr, *svr_count, *svr_addr_array, &svr_index); @@ -558,7 +566,7 @@ static PINT_sm_action readdirplus_fetch_attrs_setup_msgpair(struct PINT_smcb *sm } js_p->error_code = OSD_MSGPAIR; - } else { + } else { PINT_SERVREQ_LISTATTR_FILL( msg_p->req, *sm_p->cred_p, @@ -570,7 +578,7 @@ static PINT_sm_action readdirplus_fetch_attrs_setup_msgpair(struct PINT_smcb *sm /* immediate return. next state jumps to msgpairarray machine */ js_p->error_code = 0; } - } + } PINT_sm_push_frame(smcb, 0, &sm_p->msgarray_op); return SM_ACTION_COMPLETE; @@ -745,7 +753,12 @@ static PINT_sm_action readdirplus_fetch_sizes_setup_msgpair( struct PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); PINT_sm_msgpair_state *msg_p; int is_osd = fsid_is_osd(sm_p->object_ref.fs_id); - + struct server_configuration_s *server_config; + + server_config = PINT_get_server_config_struct( + sm_p->object_ref.fs_id); + PINT_put_server_config_struct(server_config); + PINT_msgpairarray_destroy(&sm_p->msgarray_op); /* don't need sizes */ @@ -768,72 +781,109 @@ static PINT_sm_action readdirplus_fetch_sizes_setup_msgpair( return SM_ACTION_COMPLETE; } - ret = PINT_msgpairarray_init(&sm_p->msgarray_op, sm_p->u.readdirplus.svr_count); - if(ret != 0) - { - gossip_err("Failed to initialize %d msgpairs\n", - sm_p->u.readdirplus.svr_count); - js_p->error_code = ret; - return SM_ACTION_COMPLETE; - } - if (is_osd) { - PINT_msgpair_init(&sm_p->msgarray_op); - msg_p = &sm_p->msgarray_op.msgpair; + js_p->error_code = OSD_MSGPAIR; - msg_p->fs_id = sm_p->object_ref.fs_id; - msg_p->retry_flag = PVFS_MSGPAIR_RETRY; - msg_p->svr_addr = sm_p->u.readdirplus.server_addresses[0]; - msg_p->comp_fn = readdirplus_fetch_sizes_comp_fn; + if(server_config->member_attr) { + PINT_msgpair_init(&sm_p->msgarray_op); + msg_p = &sm_p->msgarray_op.msgpair; + + msg_p->fs_id = sm_p->object_ref.fs_id; + msg_p->retry_flag = PVFS_MSGPAIR_RETRY; + msg_p->svr_addr = sm_p->u.readdirplus.server_addresses[0]; + msg_p->comp_fn = readdirplus_fetch_sizes_comp_fn; - if(sm_p->u.readdirplus.nhandles == 1) { - msg_p->handle = sm_p->u.readdirplus.input_handle_array[0].handle; - } else { msg_p->handle = find_min_handle(sm_p->u.readdirplus.input_handle_array, sm_p->u.readdirplus.nhandles); - } + struct attribute_list attr[sm_p->u.readdirplus.nhandles]; + /* Set attr type, page and number */ + for (i = 0; i < sm_p->u.readdirplus.nhandles; i++) { + if (sm_p->u.readdirplus.nhandles == 1) { + attr[i].type = ATTR_GET; + } else { + attr[i].type = ATTR_GET_MULTI; + } + attr[i].page = 0x1; + attr[i].number = 0x82; /* logical length (not used capacity) */ + attr[i].len = sizeof(uint64_t); + } - struct osd_command *command = &sm_p->msgarray_op.msgarray[0].osd_command; + struct osd_command *command = &sm_p->msgarray_op.msgarray[0].osd_command; - struct attribute_list attr[sm_p->u.readdirplus.nhandles]; - /* Set attr type, page and number */ - for (i = 0; i < sm_p->u.readdirplus.nhandles; i++) { - if (sm_p->u.readdirplus.nhandles == 1) { - attr[i].type = ATTR_GET; - } else { - attr[i].type = ATTR_GET_MULTI; + ret = osd_command_set_get_member_attributes(command, PVFS_OSD_DATA_PID, sm_p->object_ref.cid, msg_p->handle); + if (ret) { + osd_error_xerrno(ret, "%s: osd_command_set_get_member_attributes failed", + __func__); + js_p->error_code = ret; + return 1; } - attr[i].page = 0x1; - attr[i].number = 0x82; /* logical length (not used capacity) */ - attr[i].len = sizeof(uint64_t); - } - ret = osd_command_set_get_member_attributes(command, PVFS_OSD_DATA_PID, COLLECTION_OID_LB, msg_p->handle); - if (ret) { - osd_error_xerrno(ret, "%s: osd_command_set_get_member_attributes failed", - __func__); - js_p->error_code = ret; - return 1; - } + ret = osd_command_multi_attr_build(command, attr, sm_p->u.readdirplus.nhandles, sm_p->u.readdirplus.nhandles); + if (ret) { + osd_error_xerrno(ret, "%s: osd_command_attr_build failed", + __func__); + js_p->error_code = ret; + return 1; + } + } else { + ret = PINT_msgpairarray_init(&sm_p->msgarray_op, sm_p->u.readdirplus.nhandles); + if(ret != 0) + { + gossip_err("Failed to initialize %d msgpairs\n", + sm_p->u.readdirplus.svr_count); + js_p->error_code = ret; + return SM_ACTION_COMPLETE; + } - js_p->error_code = OSD_MSGPAIR; + foreach_msgpair(&sm_p->msgarray_op, msg_p, i) + { + struct osd_command *command = &sm_p->msgarray_op.msgarray[i].osd_command; + + msg_p->fs_id = sm_p->object_ref.fs_id; + msg_p->retry_flag = PVFS_MSGPAIR_RETRY; + msg_p->comp_fn = readdirplus_fetch_sizes_comp_fn; + msg_p->svr_addr = sm_p->u.readdirplus.server_addresses[0]; + msg_p->handle = sm_p->u.readdirplus.input_handle_array[i].handle; + + struct attribute_list id = { + .type = ATTR_GET, + .page = 0x1, + .number = 0x82, /* logical length (not used capacity) */ + .len = sizeof(uint64_t), + }; + + ret = osd_command_set_get_attributes(command, PVFS_OSD_DATA_PID, + sm_p->u.readdirplus.input_handle_array[i].handle); + + if (ret) { + osd_error_xerrno(ret, + "%s: osd_command_set_get_attributes failed", + __func__); + js_p->error_code = ret; + return 1; + } - ret = osd_command_multi_attr_build(command, attr, sm_p->u.readdirplus.nhandles, sm_p->u.readdirplus.nhandles); - if (ret) { - osd_error_xerrno(ret, "%s: osd_command_attr_build failed", - __func__); + ret = osd_command_attr_build(command, &id, 1); + if (ret) { + osd_error_xerrno(ret, "%s: osd_command_attr_build failed", + __func__); + js_p->error_code = ret; + return 1; + } + } + } + } else { + ret = PINT_msgpairarray_init(&sm_p->msgarray_op, sm_p->u.readdirplus.svr_count); + if(ret != 0) + { + gossip_err("Failed to initialize %d msgpairs\n", + sm_p->u.readdirplus.svr_count); js_p->error_code = ret; - return 1; + return SM_ACTION_COMPLETE; } - } else { foreach_msgpair(&sm_p->msgarray_op, msg_p, i) { - msg_p->fs_id = sm_p->object_ref.fs_id; - msg_p->retry_flag = PVFS_MSGPAIR_RETRY; - msg_p->svr_addr = sm_p->u.readdirplus.server_addresses[0]; - msg_p->comp_fn = readdirplus_fetch_sizes_comp_fn; - msg_p->handle = PVFS_HANDLE_NULL; PINT_SERVREQ_LISTATTR_FILL( msg_p->req, *sm_p->cred_p, @@ -842,6 +892,11 @@ static PINT_sm_action readdirplus_fetch_sizes_setup_msgpair( sm_p->u.readdirplus.handle_count[i], sm_p->u.readdirplus.handles[i], sm_p->hints); + msg_p->fs_id = sm_p->object_ref.fs_id; + msg_p->handle = PVFS_HANDLE_NULL; + msg_p->retry_flag = PVFS_MSGPAIR_RETRY; + msg_p->comp_fn = readdirplus_fetch_sizes_comp_fn; + msg_p->svr_addr = sm_p->u.readdirplus.server_addresses[i]; } /* immediate return. next state jumps to msgpairarray machine */ js_p->error_code = 0; @@ -860,6 +915,11 @@ static int readdirplus_fetch_sizes_comp_fn(void *v_p, PVFS_error status; int64_t size[sm_p->u.readdirplus.nhandles]; int is_osd = fsid_is_osd(sm_p->object_ref.fs_id); + struct server_configuration_s *server_config; + + server_config = PINT_get_server_config_struct( + sm_p->object_ref.fs_id); + PINT_put_server_config_struct(server_config); gossip_debug(GOSSIP_LISTATTR_DEBUG, "readdirplus_fetch_sizes_comp_fn called\n"); @@ -906,60 +966,76 @@ static int readdirplus_fetch_sizes_comp_fn(void *v_p, return ret; } - struct attribute_list *attr = command->attr; - - for (i=0; iu.readdirplus.nhandles; i++) { - if(sm_p->u.readdirplus.nhandles == 1) { - if (command->attr->outlen != sizeof(uint64_t)) { - gossip_err("%s: expecting 8 bytes returned, got %u.\n", __func__, - command->attr->outlen); - return ret; + if(server_config->member_attr) { + struct attribute_list *attr = command->attr; + + for (i=0; iu.readdirplus.nhandles; i++) { + if(sm_p->u.readdirplus.nhandles == 1) { + if (command->attr->outlen != sizeof(uint64_t)) { + gossip_err("%s: expecting 8 bytes returned, got %u.\n", __func__, + command->attr->outlen); + return ret; + } + } else { + if (((struct attribute_get_multi_results *)attr[0].val)->outlen[((struct attribute_get_multi_results *)attr[0].val)->numoid-(sm_p->u.readdirplus.nhandles-i)] != sizeof(uint64_t)) { + gossip_err("%s: expecting 8 bytes returned, got %u.\n", __func__, + command->attr->outlen); + return ret; + } } - } else { - if (((struct attribute_get_multi_results *)attr[0].val)->outlen[((struct attribute_get_multi_results *)attr[0].val)->numoid-(sm_p->u.readdirplus.nhandles-i)] != sizeof(uint64_t)) { - gossip_err("%s: expecting 8 bytes returned, got %u.\n", __func__, - command->attr->outlen); - return ret; - } } - } - for (i=0; iu.readdirplus.nhandles; i++) { - if(sm_p->u.readdirplus.nhandles == 1) { - size[i] = get_ntohll(command->attr[i].val); - } else { - size[i] = get_ntohll(((struct attribute_get_multi_results *)attr[0].val)->val[((struct attribute_get_multi_results *)attr[0].val)->numoid-(sm_p->u.readdirplus.nhandles-i)]); + for (i=0; iu.readdirplus.nhandles; i++) { + if(sm_p->u.readdirplus.nhandles == 1) { + size[i] = get_ntohll(command->attr[i].val); + } else { + size[i] = get_ntohll(((struct attribute_get_multi_results *)attr[0].val)->val[((struct attribute_get_multi_results *)attr[0].val)->numoid-(sm_p->u.readdirplus.nhandles-i)]); + } } - } - for (i = 0; i < sm_p->u.readdirplus.nhandles; i++) - { - if(sm_p->u.readdirplus.nhandles == 1) { - if(sm_p->msgarray_op.msgarray[index].handle == sm_p->u.readdirplus.input_handle_array[i].handle) - { - handle_index = sm_p->u.readdirplus.input_handle_array[0].handle_index; - aux_index = sm_p->u.readdirplus.input_handle_array[0].aux_index; - sm_p->u.readdirplus.size_array[handle_index][aux_index] = size[0]; - } - } else { - for (i = 0; i < sm_p->u.readdirplus.handle_count[index]; i++) { + for (i = 0; i < sm_p->u.readdirplus.nhandles; i++) + { + if(sm_p->u.readdirplus.nhandles == 1) { + if(sm_p->msgarray_op.msgarray[index].handle == sm_p->u.readdirplus.input_handle_array[i].handle) + { + handle_index = sm_p->u.readdirplus.input_handle_array[0].handle_index; + aux_index = sm_p->u.readdirplus.input_handle_array[0].aux_index; + sm_p->u.readdirplus.size_array[handle_index][aux_index] = size[0]; + } + } else { + for (i = 0; i < sm_p->u.readdirplus.handle_count[index]; i++) { //gossip_err("%d\n", sm_p->u.readdirplus.input_handle_array[i]); //gossip_err("%d\n", ((struct attribute_get_multi_results *)attr[0].val)->oid[((struct attribute_get_multi_results *)attr[0].val)->numoid-(sm_p->u.readdirplus.nhandles-i)]); - } + } - for (i = 0; i < sm_p->u.readdirplus.handle_count[index]; i++) { - get_handle_index(sm_p->u.readdirplus.input_handle_array, + for (i = 0; i < sm_p->u.readdirplus.handle_count[index]; i++) { + get_handle_index(sm_p->u.readdirplus.input_handle_array, sm_p->u.readdirplus.nhandles, ((struct attribute_get_multi_results *)attr[0].val)->oid[((struct attribute_get_multi_results *)attr[0].val)->numoid-(sm_p->u.readdirplus.nhandles-i)], &handle_index, &aux_index); - sm_p->u.readdirplus.size_array[handle_index][aux_index] = size[i]; - } + sm_p->u.readdirplus.size_array[handle_index][aux_index] = size[i]; + } + } } - } - + } else { + if (command->attr->outlen != sizeof(uint64_t)) { + gossip_err("%s: expecting 8 bytes returned, got %u.\n", __func__, + command->attr->outlen); + return ret; + } + + get_handle_index(sm_p->u.readdirplus.input_handle_array, + sm_p->u.readdirplus.nhandles, + sm_p->msgarray_op.msgarray[index].handle, + &handle_index, + &aux_index); + sm_p->u.readdirplus.size_array[handle_index][aux_index] = get_ntohll(command->attr->val); + } + osd_command_attr_free(command); + } else { /* make sure that we get back responses for all handles that we sent out */ assert(resp_p->u.listattr.nhandles == sm_p->u.readdirplus.handle_count[index]); diff --git a/src/client/sysint/sys-rename.sm b/src/client/sysint/sys-rename.sm index a535f4f..191b042 100644 --- a/src/client/sysint/sys-rename.sm +++ b/src/client/sysint/sys-rename.sm @@ -467,8 +467,13 @@ static int rename_rmdirent_comp_fn(void *v_p, int index) { PINT_smcb *smcb = v_p; +#ifdef WIN32 + PINT_client_sm *sm_p = + PINT_sm_frame(smcb, PINT_MSGPAIR_PARENT_SM); +#else PINT_client_sm *sm_p __attribute__((unused)) = PINT_sm_frame(smcb, PINT_MSGPAIR_PARENT_SM); +#endif gossip_debug(GOSSIP_CLIENT_DEBUG, "rename_rmdirent_comp_fn\n"); assert(resp_p->op == PVFS_SERV_RMDIRENT); diff --git a/src/client/sysint/sys-set-eattr.sm b/src/client/sysint/sys-set-eattr.sm index 0698a2a..a6c5d15 100644 --- a/src/client/sysint/sys-set-eattr.sm +++ b/src/client/sysint/sys-set-eattr.sm @@ -4,9 +4,15 @@ * See COPYING in top-level directory. */ +/** \file PVFS system calls for setting extended attributes + * \ingroup sysint + */ + #include #include +#ifndef WIN32 #include +#endif #include "client-state-machine.h" #include "pvfs2-debug.h" @@ -117,6 +123,20 @@ PVFS_error PVFS_isys_seteattr_list( smcb, op_id, user_ptr); } +PVFS_error PVFS_isys_seteattr( + PVFS_object_ref ref, + const PVFS_credentials *credentials, + PVFS_ds_keyval *key_p, + PVFS_ds_keyval *val_p, + int32_t flags, + PVFS_sys_op_id *op_id, + PVFS_hint hints, + void *user_ptr) +{ + return PVFS_isys_seteattr_list(ref, credentials, 1, key_p, val_p, flags, + op_id, hints, user_ptr); +} + PVFS_error PVFS_sys_seteattr_list( PVFS_object_ref ref, const PVFS_credentials *credentials, diff --git a/src/client/sysint/sys-setattr.sm b/src/client/sysint/sys-setattr.sm index b369bd5..28f10da 100644 --- a/src/client/sysint/sys-setattr.sm +++ b/src/client/sysint/sys-setattr.sm @@ -362,6 +362,7 @@ static PINT_sm_action setattr_cleanup( /* either update acache or invalidate depending on if we were successful * or not */ + if(sm_p->error_code == 0) { PINT_CONVERT_ATTR(&attr, &sm_p->u.setattr.sys_attr, 0); diff --git a/src/client/sysint/sys-small-io.sm b/src/client/sysint/sys-small-io.sm index 40d7946..de7eded 100644 --- a/src/client/sysint/sys-small-io.sm +++ b/src/client/sysint/sys-small-io.sm @@ -252,8 +252,13 @@ static int small_io_completion_fn(void * user_args, PINT_client_small_io_ctx *ctx = &(sm_p->u.io.small_io_ctx[msg_p->req.u.small_io.server_nr]); uint32_t server_nr = msg_p->req.u.small_io.server_nr; +#ifdef WIN32 + PVFS_object_attr *attr = &(sm_p->getattr.attr); + PVFS_metafile_attr *meta = &(attr->u.meta); +#else PVFS_object_attr *attr __attribute__((unused)) = &(sm_p->getattr.attr); PVFS_metafile_attr *meta __attribute__((unused)) = &(attr->u.meta); +#endif int ret = 0; @@ -377,11 +382,11 @@ static int small_io_completion_fn(void * user_args, */ gossip_debug(GOSSIP_IO_DEBUG,"handle=%llu \toperation=%d \toffset=%ld " - "\taggregate_size=%ld\n" - ,llu(msg_p->req.u.small_io.handle) - ,msg_p->req.u.small_io.io_type - ,msg_p->req.u.small_io.file_req_offset - ,msg_p->req.u.small_io.aggregate_size); + "\taggregate_size=%ld\n", + llu(msg_p->req.u.small_io.handle), + msg_p->req.u.small_io.io_type, + ((long int)msg_p->req.u.small_io.file_req_offset), + ((long int)msg_p->req.u.small_io.aggregate_size)); /* if ( (sm_p->u.io.io_type == PVFS_IO_READ) @@ -401,7 +406,9 @@ static int small_io_completion_fn(void * user_args, static int small_io_check_for_retries( struct PINT_smcb *smcb , job_status_s *js_p) { +#ifndef WIN32 gossip_debug(GOSSIP_MIRROR_DEBUG,"Executing %s..\n",__func__); +#endif struct PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); struct PVFS_object_attr *attr = &(sm_p->getattr.attr); @@ -423,6 +430,9 @@ static int small_io_check_for_retries( struct PINT_smcb *smcb int k = 0; int ret = 0; +#ifdef WIN32 + gossip_debug(GOSSIP_MIRROR_DEBUG,"Executing %s..\n",__func__); +#endif /*if we are processing a write request, then msgpairarray handles retries. *if we are processing a read and the source file is mirrored, then *SMALL-IO handles the retries. diff --git a/src/client/usrint/iocommon.c b/src/client/usrint/iocommon.c index c71ff17..3951167 100644 --- a/src/client/usrint/iocommon.c +++ b/src/client/usrint/iocommon.c @@ -1,20 +1,70 @@ -#include - -int init=0; - -/* Perform PVFS initialization if not already finished */ -void iocommon_ensure_init() -{ - - /* Initialize the file system with mount points */ - int ret; - if (!init){ - ret = PVFS_util_init_defaults(); - assert(ret==PVFS_FD_SUCCESS); - init=1; - } +/* + * (C) 2011 Clemson University and The University of Chicago + * + * See COPYING in top-level directory. + */ -} +/** \file + * \ingroup usrint + * + * PVFS2 user interface routines - low level calls to system interface + */ +#define USRINT_SOURCE 1 +#include "usrint.h" +#include "posix-ops.h" +#include "openfile-util.h" +#include "iocommon.h" +#include "ucache.h" + +/* Functions in this file generally define a label errorout + * for cleanup before exit and return an int rc which is -1 + * on error with the error code in errno, 0 on success. + * IOCOMMON_RETURN_ERR checks a return code from a function + * returns the same protocol and goto errorout: if less than 0 + * IOCOMMON_CHECK_ERR assumes the return code contains the + * negative of the error code as encoded by PVFS sysint + * functions and decodes these before jumping to errorout. + * PVFS sysint calls always return error codes in the return + * value, but system calls inside them might set errno to + * a value that may or may not have meaning for the programmer + * calling this library. Steps are taken to ensure errno + * is not modified unless the code in this lib wants to + * modify it. CHECK_ERR should be called after each sysint + * call to correctly pass error codes. + */ +extern PVFS_error PINT_errno_mapping[]; +#define IOCOMMON_RETURN_ERR(rc) \ +do { \ + if ((rc) < 0) \ + { \ + goto errorout; \ + } \ +} while (0) + +#define IOCOMMON_CHECK_ERR(rc) \ +do { \ + errno = orig_errno; \ + if ((rc) < 0) \ + { \ + if (IS_PVFS_NON_ERRNO_ERROR(-(rc))) \ + { \ + pvfs_errno = -rc; \ + errno = EIO; \ + } \ + else if (IS_PVFS_ERROR(-(rc))) \ + { \ + errno = PINT_errno_mapping[(-(rc)) & 0x7f]; \ + } \ + rc = -1; \ + goto errorout; \ + } \ +} while (0) + +/** this is a global analog of errno for pvfs specific + * errors errno is set to EIO and this si set to the + * original code + */ +int pvfs_errno; void iocommon_cred(PVFS_credentials **credentials) { @@ -34,89 +84,213 @@ void iocommon_cred(PVFS_credentials **credentials) int iocommon_fsync(pvfs_descriptor *pd) { + int rc = 0; + int orig_errno = errno; PVFS_credentials *credentials; + + pvfs_sys_init(); + if (!pd || pd->is_in_use != PVFS_FS) + { + errno = EBADF; + return -1; + } iocommon_cred(&credentials); - return PVFS_sys_flush(pd->pvfs_ref, credentials, PVFS_HINT_NULL); + if(ucache!=0 && ucache_locks!=0) + { + ucache_flush(pd); + } + rc = PVFS_sys_flush(pd->pvfs_ref, credentials, PVFS_HINT_NULL); + IOCOMMON_CHECK_ERR(rc); + +errorout: + return rc; } -/* +/** * Find the PVFS handle to an object (file, dir sym) * assumes an absoluate path */ -int iocommon_lookup_absolute( const char *abs_path, PVFS_object_ref *ref) +int iocommon_lookup_absolute(const char *abs_path, + PVFS_object_ref *ref, + char *error_path, + int error_path_size) { - int rc; - char pvfs_path[256]; + int rc = 0; + int orig_errno = errno; + char pvfs_path[PVFS_PATH_MAX]; PVFS_fs_id lookup_fs_id; + PVFS_credentials *credentials; + PVFS_sysresp_lookup resp_lookup; + + /* Initialize any variables */ + memset(&resp_lookup, 0, sizeof(resp_lookup)); + + pvfs_sys_init(); + iocommon_cred(&credentials); /* Determine the fs_id and pvfs_path */ - rc = PVFS_util_resolve(abs_path, &lookup_fs_id, pvfs_path, 256); + rc = PVFS_util_resolve(abs_path, &lookup_fs_id, pvfs_path, PVFS_PATH_MAX); + IOCOMMON_CHECK_ERR(rc); - if (0 == rc) - { - PVFS_credentials *credentials; - PVFS_sysresp_lookup resp_lookup; + /* set up buffer to return partially looked up path */ + /* in failure. This is most likely a non-PVFS path */ - iocommon_cred(&credentials); - rc = PVFS_sys_lookup(lookup_fs_id, pvfs_path, - credentials, &resp_lookup, - PVFS2_LOOKUP_LINK_FOLLOW, NULL); - *ref = resp_lookup.ref; + /* Set up error path */ + if (error_path) + { + memset(error_path, 0, error_path_size); + resp_lookup.error_path = error_path; + resp_lookup.error_path_size = error_path_size; } else { - fprintf(stderr, "Error: No matching fstab entry for %s\n", abs_path); + resp_lookup.error_path = NULL; + resp_lookup.error_path_size = 0; } + rc = PVFS_sys_lookup(lookup_fs_id, pvfs_path, + credentials, &resp_lookup, + PVFS2_LOOKUP_LINK_FOLLOW, NULL); + IOCOMMON_CHECK_ERR(rc); + *ref = resp_lookup.ref; + +errorout: return rc; } -/* +/** * Lookup a file via the PVFS system interface + * + * Assumes we have already looked up part of the path + * POSIX assumes we can handle at least 1024 char paths + * and potentially 4096 char paths (depending on which + * include file you look at). PVFS cannot deal with more + * than 255 chars at a time so we must break long paths + * into pieces and do multiple relative lookups */ int iocommon_lookup_relative(const char *rel_path, PVFS_object_ref parent_ref, /* by value */ int follow_links, - PVFS_object_ref *ref ) + PVFS_object_ref *ref, + char *error_path, + int error_path_size) { - int rc; + int rc = 0; + int orig_errno = errno; + PVFS_object_ref current_seg_ref; + char current_seg_path[PVFS_NAME_MAX]; + char *cur, *last, *start; PVFS_credentials *credentials; PVFS_sysresp_lookup resp_lookup; + /* Initialize any variables */ + pvfs_sys_init(); + memset(&resp_lookup, 0, sizeof(resp_lookup)); + /* Set credentials */ iocommon_cred(&credentials); - /* Contact server */ - rc = PVFS_sys_ref_lookup(parent_ref.fs_id, - (char*)rel_path, - parent_ref, - credentials, - &resp_lookup, - follow_links, - PVFS_HINT_NULL); - *ref = resp_lookup.ref; + /* Set up error path */ + if (error_path) + { + memset(error_path, 0, error_path_size); + resp_lookup.error_path = error_path; + resp_lookup.error_path_size = error_path_size; + } + else + { + resp_lookup.error_path = NULL; + resp_lookup.error_path_size = 0; + } + + current_seg_ref = parent_ref; + cur = (char *)rel_path; + last = (char *)rel_path; + start = (char *)rel_path; + + /* loop over segments of the path with max PVFS_NAME_MAX chars */ + while(*cur) + { + /* loop over chars to find a complete path segment */ + /* that is no longer than PVFS_NAME_MAX chars */ + while(*cur) + { + /* find next path seperator / */ + /* cur either points to a slash */ + /* or the first char of the path */ + /* there must be at least one */ + /* so n either case increment it first */ + for(cur++; *cur && *cur != '/'; cur++); + if (cur - start > PVFS_NAME_MAX-1) + { + /* we over-shot the limit go back to last */ + cur = last; + if (cur == start) + { + /* single segment larger than PVFS_NAME_MAX */ + errno = ENAMETOOLONG; + rc = -1; + goto errorout; + } + break; + } + else + { + /* set up to add the next path segment */ + last = cur; + } + } + memset(current_seg_path, 0, PVFS_NAME_MAX); + strncpy(current_seg_path, start, (cur - start) + 1); + start = cur; + last = cur; + + /* Contact server */ + rc = PVFS_sys_ref_lookup(parent_ref.fs_id, + current_seg_path, + current_seg_ref, + credentials, + &resp_lookup, + follow_links, + PVFS_HINT_NULL); + IOCOMMON_CHECK_ERR(rc); + if (*cur) + { + current_seg_ref = resp_lookup.ref; + } + else + { + *ref = resp_lookup.ref; + } + } +errorout: return rc; } -/* +/** * Create a file via the PVFS system interface */ -int iocommon_create_file( const char *filename, - mode_t file_permission, - PVFS_hint file_creation_param, - PVFS_object_ref parent_ref, - PVFS_object_ref *ref ) +int iocommon_create_file(const char *filename, + mode_t mode, + PVFS_hint file_creation_param, + PVFS_object_ref parent_ref, + PVFS_object_ref *ref ) { - int rc; + int rc = 0; + int orig_errno = errno; mode_t mode_mask; mode_t user_mode; - PVFS_sys_attr attributes; + PVFS_sys_attr attr; PVFS_credentials *credentials; PVFS_sysresp_create resp_create; + PVFS_sys_dist *dist = NULL; + PVFS_sys_layout *layout = NULL; - /* Create distribution var */ - PVFS_sys_dist *dist=NULL; + /* Initialize */ + pvfs_sys_init(); + memset(&attr, 0, sizeof(attr)); + memset(&resp_create, 0, sizeof(resp_create)); /* this is not right - need to pull parameters out of hints */ /* investigate PVFS hint mechanism */ @@ -132,14 +306,12 @@ int iocommon_create_file( const char *filename, } #endif - /* Set attributes */ - memset(&attributes, 0, sizeof(attributes)); - attributes.owner = getuid(); - attributes.group = getgid(); - attributes.atime = time(NULL); - attributes.mtime = attributes.atime; - attributes.ctime = attributes.atime; - attributes.mask = PVFS_ATTR_SYS_ALL_SETABLE; + attr.owner = geteuid(); + attr.group = getegid(); + attr.atime = time(NULL); + attr.mtime = attr.atime; + attr.ctime = attr.atime; + attr.mask = PVFS_ATTR_SYS_ALL_SETABLE; #if 0 if (file_creation_param.striping_factor > 0){ @@ -151,44 +323,44 @@ int iocommon_create_file( const char *filename, /* Extract the users umask (and restore it to the original value) */ mode_mask = umask(0); umask(mode_mask); - user_mode = file_permission & ~mode_mask; + user_mode = mode & ~mode_mask; /* Set file permissions */ if (user_mode & S_IXOTH) { - attributes.perms |= PVFS_O_EXECUTE; + attr.perms |= PVFS_O_EXECUTE; } if (user_mode & S_IWOTH) { - attributes.perms |= PVFS_O_WRITE; + attr.perms |= PVFS_O_WRITE; } if (user_mode & S_IROTH) { - attributes.perms |= PVFS_O_READ; + attr.perms |= PVFS_O_READ; } if (user_mode & S_IXGRP) { - attributes.perms |= PVFS_G_EXECUTE; + attr.perms |= PVFS_G_EXECUTE; } if (user_mode & S_IWGRP) { - attributes.perms |= PVFS_G_WRITE; + attr.perms |= PVFS_G_WRITE; } if (user_mode & S_IRGRP) { - attributes.perms |= PVFS_G_READ; + attr.perms |= PVFS_G_READ; } if (user_mode & S_IXUSR) { - attributes.perms |= PVFS_U_EXECUTE; + attr.perms |= PVFS_U_EXECUTE; } if (user_mode & S_IWUSR) { - attributes.perms |= PVFS_U_WRITE; + attr.perms |= PVFS_U_WRITE; } if (user_mode & S_IRUSR) { - attributes.perms |= PVFS_U_READ; + attr.perms |= PVFS_U_READ; } /* Set credentials */ @@ -197,53 +369,61 @@ int iocommon_create_file( const char *filename, /* Contact server */ rc = PVFS_sys_create((char*)filename, parent_ref, - attributes, + attr, credentials, dist, &resp_create, - NULL, + layout, NULL); + IOCOMMON_CHECK_ERR(rc); *ref = resp_create.ref; - if (dist) PINT_dist_free(dist); - +errorout: + if (dist) + { + PVFS_sys_dist_free(dist); + } return rc; } -/* pvfs_open implementation, return file info in fd */ -/* assumes path is fully qualified */ -/* if pdir is not NULL, it is the parent directory */ -pvfs_descriptor *iocommon_open(const char *pathname, int flag, +/** pvfs_open implementation, return file info in fd + * assumes path is fully qualified + * if pdir is not NULL, it is the parent directory + */ +pvfs_descriptor *iocommon_open(const char *path, + int flags, PVFS_hint file_creation_param, - mode_t file_permission, - PVFS_object_ref *pdir) + mode_t mode, + pvfs_descriptor *pdir) { - int rc; + int rc = 0; + int orig_errno = errno; int follow_link; - char *directory; - char *filename; + char *directory = NULL; + char *filename = NULL; + char error_path[256]; PVFS_object_ref file_ref; PVFS_object_ref parent_ref; - int fs_id = 0; pvfs_descriptor *pd = NULL; /* invalid pd until file is opened */ + PVFS_sysresp_getattr attributes_resp; + PVFS_credentials *credentials; + + /* Initialize */ + memset(&file_ref, 0, sizeof(file_ref)); + memset(&parent_ref, 0, sizeof(parent_ref)); + memset(&attributes_resp, 0, sizeof(attributes_resp)); + memset(error_path, 0, sizeof(error_path)); + + pvfs_sys_init(); + iocommon_cred(&credentials); /* Split the path into a directory and file */ - rc = split_pathname(pathname, &directory, &filename); - if (0 != rc && (0 == directory || 0 == filename)) - { - errno = ENOMEM; - return pd; - } - else if (rc != 0) - { - fprintf(stderr, "Error: %s is not a legal PVFS path.\n", pathname); - errno = EACCES; - return pd; - } + rc = split_pathname(path, 0, &directory, &filename); + IOCOMMON_RETURN_ERR(rc); - /* Check the flag to determine if links are followed */ - if (flag & O_NOFOLLOW) + /* Check the flags to determine if links are followed */ + if (flags & O_NOFOLLOW) { follow_link = PVFS2_LOOKUP_LINK_NO_FOLLOW; } @@ -253,97 +433,223 @@ pvfs_descriptor *iocommon_open(const char *pathname, int flag, } /* Get reference for the parent directory */ - rc = iocommon_lookup_absolute(directory, &parent_ref); - if (0 == rc) + if (pdir == NULL) { + rc = iocommon_lookup_absolute(directory, &parent_ref, NULL, 0); + IOCOMMON_RETURN_ERR(rc); + } + else + { + if (directory) + { + rc = iocommon_lookup_relative(directory, + pdir->pvfs_ref, + follow_link, + &parent_ref, + NULL, + 0); + IOCOMMON_RETURN_ERR(rc); + } + else + { + parent_ref = pdir->pvfs_ref; + } + } - /* An open procedure safe for multiprocessing */ - - //Attempt to find file - rc = iocommon_lookup_relative(filename, parent_ref, follow_link, &file_ref); + /* An open procedure safe for multiprocessing */ - //File was found - if (rc==0){ - //if EXCLUSIVE, fail - if ((flag & O_EXCL) && (flag & O_CREAT)){ - return pd; - } + /* Attempt to find file */ + rc = iocommon_lookup_relative(filename, + parent_ref, + follow_link, + &file_ref, + error_path, + sizeof(error_path)); + if ((rc == 0) && (flags & O_EXCL) && (flags & O_CREAT)) + { + /* File was found but EXCLUSIVE so fail */ + rc = -1; + errno = EEXIST; + goto errorout; + } + if (rc < 0) + { + /* if an error code was returned */ + if (errno == EIO && pvfs_errno == PVFS_ENOTPVFS && + flags & O_NOTPVFS) + { + struct stat sbuf; + /* try to open using glibc */ + rc = (*glibc_ops.open)(error_path, flags & 01777777, mode); + IOCOMMON_RETURN_ERR(rc); + pd = pvfs_alloc_descriptor(&glibc_ops, -1, NULL); + pd->is_in_use = PVFS_FS; /* indicate fd is valid! */ + pd->true_fd = rc; + pd->flags = flags; /* open flags */ + fstat(rc, &sbuf); + pd->mode = sbuf.st_mode; + goto errorout; /* not really an error, but bailing out */ } - //File wasn't found - else { - //create file? - if (flag & O_CREAT){ - rc = iocommon_create_file(filename, file_permission, file_creation_param, parent_ref, &file_ref); - //create failed, the file must have been created by a different process - if (rc){ - //get existing handle - rc = iocommon_lookup_relative(filename, parent_ref, follow_link, &file_ref); - } + if (errno != ENOENT || !(flags & O_CREAT)) + { + /* either file not found and no create flag */ + /* or some other error */ + goto errorout; + } + /* file not found but create flag */ + /* clear errno, it was not an error */ + errno = orig_errno; + rc = iocommon_create_file(filename, + mode, + file_creation_param, + parent_ref, + &file_ref); + if (rc < 0) + { + /* error on the create */ + if (errno != EEXIST) + { + goto errorout; } + /* the file exists so must have been + * created by a different process + * just open it + */ + rc = iocommon_lookup_relative(filename, + parent_ref, + follow_link, + &file_ref, + NULL, + 0); + IOCOMMON_RETURN_ERR(rc); } } - else + + /* If we get here the file was created and/or opened */ + /* Translate the pvfs reference into a file descriptor */ + /* Set the file information */ + /* create fd object */ + pd = pvfs_alloc_descriptor(&pvfs_ops, -1, &file_ref); + if (!pd) { - errno = ENOTDIR; - return pd; + rc = -1; + goto errorout; } + pd->flags = flags; /* open flags */ + pd->is_in_use = PVFS_FS; /* indicate fd is valid! */ - /* Free directory and filename memory */ - free(directory); - free(filename); + /* Get the file's type information from its attributes */ + rc = PVFS_sys_getattr(pd->pvfs_ref, + PVFS_ATTR_SYS_ALL_NOHINT, + credentials, + &attributes_resp, + NULL); + IOCOMMON_CHECK_ERR(rc); + pd->mode = attributes_resp.attr.perms; /* this may change */ - /* Translate the pvfs reference into a file descriptor */ - if (0 == rc) + if (attributes_resp.attr.objtype == PVFS_TYPE_METAFILE) { - /* Set the file information */ - /* create fd object */ - pd = pvfs_alloc_descriptor(&pvfs_ops); - pd->pvfs_ref = file_ref; - pd->flags = flag; - pd->is_in_use = 1; //indicate fd is valid! + pd->mode |= S_IFREG; } - else + if (attributes_resp.attr.objtype == PVFS_TYPE_DIRECTORY) { - /* Inidicate that an error occurred */ - errno = EACCES; - return pd; + pd->mode |= S_IFDIR; + if (pdir) + { + pd->dpath = (char *)malloc(strlen(pdir->dpath) + strlen(path) + 2); + strcpy(pd->dpath, pdir->dpath); + strcat(pd->dpath, "/"); + strcat(pd->dpath, path); + } + else + { + pd->dpath = (char *)malloc(strlen(path) + 1); + strcpy(pd->dpath, path); + } + } + if (attributes_resp.attr.objtype == PVFS_TYPE_SYMLINK) + { + pd->mode |= S_IFLNK; } /* Truncate the file if neccesary */ - if (flag & O_TRUNC) + if (flags & O_TRUNC) { - PVFS_credentials *credentials; - iocommon_cred(&credentials); - PVFS_sys_truncate(file_ref, 0, credentials, NULL); + rc = PVFS_sys_truncate(file_ref, 0, credentials, NULL); + IOCOMMON_CHECK_ERR(rc); } /* Move to the end of file if necessary */ - if (flag & O_APPEND) - iocommon_lseek(pd, 0, 0, SEEK_END); + if (flags & O_APPEND) + { + rc = iocommon_lseek(pd, 0, 0, SEEK_END); + } + +errorout: + + /* Free directory and filename memory */ + if (directory) + { + free(directory); + } + if (filename) + { + free(filename); + } + if (rc < 0) + { + return NULL; + } + else + { + return pd; + } +} + +/** + * Implementation of truncate via PVFS + * + */ +int iocommon_truncate(PVFS_object_ref file_ref, off64_t length) +{ + int rc = 0; + int orig_errno = errno; + PVFS_credentials *credentials; + + pvfs_sys_init(); + iocommon_cred(&credentials); + rc = PVFS_sys_truncate(file_ref, length, credentials, NULL); + IOCOMMON_CHECK_ERR(rc); - return pd; +errorout: + return rc; } +/** + * Implementation of lseek for file and directory via PVFS + * + */ off64_t iocommon_lseek(pvfs_descriptor *pd, off64_t offset, PVFS_size unit_size, int whence) { + int rc = 0; + int orig_errno = errno; - if (0 == pd) + if (!pd || pd->is_in_use != PVFS_FS) { errno = EBADF; - return PVFS_FD_FAILURE; + return -1; } - switch(whence) { case SEEK_SET: { - pd->file_pointer = offset*unit_size; + pd->file_pointer = (offset * unit_size); break; } case SEEK_CUR: { - pd->file_pointer += offset*unit_size; + pd->file_pointer += (offset * unit_size); break; } case SEEK_END: @@ -351,297 +657,709 @@ off64_t iocommon_lseek(pvfs_descriptor *pd, off64_t offset, PVFS_credentials *credentials; PVFS_sysresp_getattr attributes_resp; - /* Construct credentials*/ + memset(&attributes_resp, 0, sizeof(attributes_resp)); iocommon_cred(&credentials); - /* Get the file's size in bytes as the ending offset */ - PVFS_sys_getattr(pd->pvfs_ref, PVFS_ATTR_SYS_SIZE, - credentials, &attributes_resp, NULL); - - pd->file_pointer = attributes_resp.attr.size + offset*unit_size; + rc = PVFS_sys_getattr(pd->pvfs_ref, + PVFS_ATTR_SYS_SIZE, + credentials, + &attributes_resp, + NULL); + IOCOMMON_CHECK_ERR(rc); + pd->file_pointer = attributes_resp.attr.size + (offset * unit_size); break; } default: { errno = EINVAL; - return PVFS_FD_FAILURE; + goto errorout; + } + } + /* if this is a directory adjust token, the hard way */ + if (S_ISDIR(pd->mode)) + { + int dirent_no; + PVFS_credentials *credentials; + PVFS_sysresp_readdir readdir_resp; + + memset(&readdir_resp, 0, sizeof(readdir_resp)); + iocommon_cred(&credentials); + dirent_no = pd->file_pointer / sizeof(PVFS_dirent); + pd->file_pointer = dirent_no * sizeof(PVFS_dirent); + pd->token = PVFS_READDIR_START; + if(dirent_no) + { + rc = PVFS_sys_readdir(pd->pvfs_ref, + pd->token, + dirent_no, + credentials, + &readdir_resp, + NULL); + IOCOMMON_CHECK_ERR(rc); + pd->token = readdir_resp.token; + free(readdir_resp.dirent_array); } } return pd->file_pointer; + +errorout: + return -1; } -/* - * pvfs_unlink implementation - * need to verify this is a file or symlink - * use rmdir for directory +/** + * implements unlink and rmdir + * + * dirflag indicates trying to remove a dir (rmdir) */ -int iocommon_remove (const char *pathname, int dirflag) +int iocommon_remove (const char *path, + PVFS_object_ref *pdir, + int dirflag) { int rc = 0; - char *parentdir = 0; - char *file = 0; - PVFS_object_ref parent_ref; + int orig_errno = errno; + char *parentdir = NULL; + char *file = NULL; + PVFS_object_ref parent_ref, file_ref; PVFS_credentials *credentials; PVFS_sys_attr attr; + /* Initialize */ + memset(&parent_ref, 0, sizeof(parent_ref)); + memset(&file_ref, 0, sizeof(file_ref)); + memset(&attr, 0, sizeof(attr)); + /* Initialize the system interface for this process */ - iocommon_ensure_init(); + pvfs_sys_init(); iocommon_cred(&credentials); - if (0 == rc) + rc = split_pathname(path, dirflag, &parentdir, &file); + IOCOMMON_RETURN_ERR(rc); + + if (!pdir) { - rc = split_pathname(pathname, &parentdir, &file); + rc = iocommon_lookup_absolute(parentdir, &parent_ref, NULL, 0); + IOCOMMON_RETURN_ERR(rc); } - - if (0 == rc) + else { - rc = iocommon_lookup_absolute(parentdir, &parent_ref); + if (parentdir) + { + rc = iocommon_lookup_relative(parentdir, *pdir, + PVFS2_LOOKUP_LINK_FOLLOW, &parent_ref, NULL, 0); + IOCOMMON_RETURN_ERR(rc); + } + else + { + parent_ref = *pdir; + } } + /* need to verify this is a file or symlink */ - /* WBL - What is going on here ??? */ - iocommon_lookup_relative(parentdir, parent_ref, - PVFS2_LOOKUP_LINK_NO_FOLLOW, &parent_ref); - iocommon_getattr(parent_ref, &attr); - if ((attr.objtype & PVFS_TYPE_DIRECTORY) && dirflag) + rc = iocommon_lookup_relative(file, parent_ref, + PVFS2_LOOKUP_LINK_NO_FOLLOW, &file_ref, NULL, 0); + IOCOMMON_RETURN_ERR(rc); + + rc = iocommon_getattr(file_ref, &attr, PVFS_ATTR_SYS_TYPE); + IOCOMMON_RETURN_ERR(rc); + + if ((attr.objtype == PVFS_TYPE_DIRECTORY) && !dirflag) { errno = EISDIR; - return -1; + goto errorout; } - else if (!(attr.objtype & PVFS_TYPE_DIRECTORY) && !dirflag) + else if ((attr.objtype != PVFS_TYPE_DIRECTORY) && dirflag) { errno = ENOTDIR; - return -1; + goto errorout; } - if (0 == rc) + /* should check to see if any process has file open */ + /* but at themoment we don't have a way to do that */ + rc = PVFS_sys_remove(file, parent_ref, credentials, PVFS_HINT_NULL); + IOCOMMON_CHECK_ERR(rc); + +errorout: + if (parentdir) { - rc = PVFS_sys_remove(file, parent_ref, credentials, PVFS_HINT_NULL); + free(parentdir); } - - free(parentdir); - free(file); - if (0 != rc) + if (file) + { + free(file); + } + if (rc < 0) { return -1; } - return 0; + else + { + return 0; + } } -int iocommon_unlink(const char *pathname) +/** + * wrapper for unlink + */ +int iocommon_unlink(const char *path, + PVFS_object_ref *pdir) { - return iocommon_remove(pathname, 1); + return iocommon_remove(path, pdir, 0); } -int iocommon_rmdir(const char *pathname) +/** + * wrapper for rmdir + */ +int iocommon_rmdir(const char *path, + PVFS_object_ref *pdir) { - return iocommon_remove(pathname, 0); + return iocommon_remove(path, pdir, 1); } -/* if dir(s) are NULL, assume name is absolute */ -int iocommon_rename(pvfs_descriptor *olddir, const char *oldname, - pvfs_descriptor *newdir, const char *newname) +/** if dir(s) are NULL, assume name is absolute */ +int iocommon_rename(PVFS_object_ref *oldpdir, const char *oldpath, + PVFS_object_ref *newpdir, const char *newpath) { - int rc; - char *oldent, *newent, *oldpath, *newpath; + int rc = 0; + int orig_errno = errno; + char *olddir = NULL, *newdir = NULL, *oldname = NULL, *newname = NULL; PVFS_object_ref oldref, newref; PVFS_credentials *creds; PVFS_hint hints = PVFS_HINT_NULL; + /* Initialize */ + memset(&oldref, 0, sizeof(oldref)); + memset(&newref, 0, sizeof(newref)); + iocommon_cred(&creds); - if (olddir) + rc = split_pathname(oldpath, 0, &olddir, &oldname); + IOCOMMON_RETURN_ERR(rc); + + if (!oldpdir) + { + rc = iocommon_lookup_absolute(olddir, &oldref, NULL, 0); + IOCOMMON_RETURN_ERR(rc); + } + else + { + if (olddir) + { + rc = iocommon_lookup_relative(olddir, *oldpdir, + PVFS2_LOOKUP_LINK_FOLLOW, &oldref, NULL, 0); + IOCOMMON_RETURN_ERR(rc); + } + else + { + oldref = *oldpdir; + } + } + rc = split_pathname(newpath, 0, &newdir, &newname); + IOCOMMON_RETURN_ERR(rc); + if (!newpdir) { - /* do relative lookup */ + rc = iocommon_lookup_absolute(newdir, &newref, NULL, 0); + IOCOMMON_RETURN_ERR(rc); } else { - /* do absolute lookup */ - rc = split_pathname(oldname, &oldpath, &oldent); - rc = iocommon_lookup_absolute(oldpath, &oldref); + if (newdir) + { + rc = iocommon_lookup_relative(newdir, *newpdir, + PVFS2_LOOKUP_LINK_FOLLOW, &newref, NULL, 0); + IOCOMMON_RETURN_ERR(rc); + } + else + { + newref = *newpdir; + } + } + rc = PVFS_sys_rename(oldname, oldref, newname, newref, creds, hints); + IOCOMMON_CHECK_ERR(rc); + +errorout: + if (olddir) + { + free(olddir); + } + if (oldname) + { + free(oldname); } if (newdir) { - /* do relative lookup */ + free(newdir); } - else + if (newname) { - /* do absolute lookup */ - rc = split_pathname(newname, &newpath, &newent); - rc = iocommon_lookup_absolute(newpath, &newref); + free(newname); } - rc = PVFS_sys_rename(oldent, oldref, newent, newref, creds, hints); return rc; } -/* do a blocking read or write - * extra_offset = extra padding to the pd's offset, independent of the pd's offset */ -int iocommon_readorwrite( enum PVFS_io_type which, - pvfs_descriptor *pd, PVFS_size offset, void *buf, - PVFS_Request etype_req, PVFS_Request file_req, size_t count) - //returned by nonblocking operations +/*The Wrapper Fuction calls to the "nocache" version of + * io_common_readorwrite (below) + */ +/** do a blocking read or write, possibly utilizing the user cache. + * + */ +int iocommon_readorwrite(enum PVFS_io_type which, + pvfs_descriptor *pd, + PVFS_size offset, + void *buf, + PVFS_Request mem_req, + PVFS_Request file_req, + size_t count, + const struct iovec *vector) { - int rc; - PVFS_Request contig_memory_req; - PVFS_credentials *creds; - PVFS_sysresp_io read_resp; - PVFS_size req_size; - - memset(&contig_memory_req, 0, sizeof(PVFS_Request)); - - //Ensure descriptor is used for the correct type of access - if (which==PVFS_IO_READ && (O_WRONLY & pd->flags)){ - errno = EBADF; - return PVFS_FD_FAILURE; - } - else if (which==PVFS_IO_WRITE && (O_RDONLY == (pd->flags & O_ACCMODE))) - { - errno = EBADF; - return PVFS_FD_FAILURE; - } + /* Incorporate this elsewhere to enable/disable caching */ + int USE_CACHE = (int)(ucache!=0 && ucache_locks!=0); + /* Eventually, a per file flag */ + int CACHE_FILE = 1; - /* Create the memory request of a contiguous region: 'mem_req' x count */ - rc = PVFS_Request_contiguous(count, etype_req, &contig_memory_req); + if(!USE_CACHE || !CACHE_FILE) + { + /* Bypass the ucache */ + return iocommon_readorwrite_nocache(which, pd, offset, buf, mem_req, + file_req); + } + int rc = 0; + int tag_cnt = 0; + uint64_t remainder = 0; + uint32_t blk_size = CACHE_BLOCK_SIZE_K * 1024; + uint64_t pos = 0; + uint64_t end = offset + count; + PVFS_fs_id *fs_id = &(pd->pvfs_ref.fs_id); + PVFS_handle *handle = &(pd->pvfs_ref.handle); + /* Used to determine if we finished writing a block without filling up the + * current io segment + */ + unsigned char scratch = 0; + /* The offset into the last io semgment that was partially used (so use + * this ptr then move on to the next io segment) . + */ + void *scratch_ptr = 0; + uint64_t scratch_left = 0; + int iovec_ndx = 0; + uint32_t block_ndx = 0; - iocommon_cred(&creds); - rc = PVFS_sys_io(pd->pvfs_ref, file_req, offset, buf, - contig_memory_req, creds, &read_resp, - which, PVFS_HINT_NULL); + /* How many tags? */ + tag_cnt = count / (CACHE_BLOCK_SIZE_K * 1024); - if (0 != rc) - { - errno = EIO; - return PVFS_FD_FAILURE; - } + /* Add 2 to be sure we have enough tags (may not need them) */ + tag_cnt += 2; - PVFS_Request_size(contig_memory_req, &req_size); - pd->file_pointer += req_size; + /* Array of the tags we need to read/write to */ + uint64_t tags[tag_cnt]; + + remainder = offset % blk_size; - PVFS_Request_free(&contig_memory_req); - return PVFS_FD_SUCCESS; -} + /* Block Aligned */ + if(remainder == 0) + { + tags[0] = offset; + } + else + { + tags[0] = offset - remainder; + } + + /* Loop over positions storing tags (ment identifiers) */ + pos = tags[0] + blk_size; + int i; + for(i = 1; pos < end; i++) + { + tags[i] = pos; + pos += blk_size; + } -/* - * [Do a nonblocking read or write] - * extra_offset = extra padding to the pd's offset, - * independent of the pd's offset - * Returns an op_id, response, and ret_mem_request - * (which represents an etype_req*count region) - * Note that the none of the PVFS_Requests are freed - */ -int iocommon_ireadorwrite( enum PVFS_io_type which, - pvfs_descriptor *pd, PVFS_size extra_offset, void *buf, - PVFS_Request etype_req, PVFS_Request file_req, size_t count, - PVFS_sys_op_id *ret_op_id, PVFS_sysresp_io *ret_resp, - PVFS_Request *ret_memory_req) -{ - int rc; - PVFS_Request contig_memory_req; - PVFS_credentials *credentials; - PVFS_size req_size; + /* This should represent the number of blks */ + tag_cnt = i - 1; - //Ensure descriptor is used for the correct type of access - if (which==PVFS_IO_READ && (O_WRONLY & pd->flags)){ - errno = EBADF; - return PVFS_FD_FAILURE; - } - else if (which==PVFS_IO_WRITE && (O_RDONLY == (pd->flags & O_ACCMODE))) + /* Now that tags are set build array of lookup responses*/ + unsigned char hits[tag_cnt]; + for(i = 0; i < tag_cnt; i++) + { + /* if lookup returns nil set char to 0, otherwise 1 */ + if(ucache_lookup(fs_id, handle, tags[i], NULL) == (void *)NIL) { - errno = EBADF; - return PVFS_FD_FAILURE; + hits[tag_cnt] = 0; /* miss */ } - - //Create the memory request of a contiguous region: 'mem_req' x count - rc = PVFS_Request_contiguous(count, etype_req, &contig_memory_req); - - iocommon_cred(&credentials); - - rc = PVFS_isys_io(pd->pvfs_ref, file_req, - pd->file_pointer+extra_offset, - buf, contig_memory_req, - credentials, - ret_resp, - which, - ret_op_id, PVFS_HINT_NULL, NULL); - - assert(*ret_op_id!=-1);//TODO: handle this - - if (rc!=0){ - errno = EIO; - return PVFS_FD_FAILURE; + else{ + hits[tag_cnt] = 1; /* hit */ } + } - PVFS_Request_size(contig_memory_req, &req_size); - pd->file_pointer += req_size; - - *ret_memory_req = contig_memory_req; - - return PVFS_FD_SUCCESS; -} - -int iocommon_getattr(PVFS_object_ref obj, PVFS_sys_attr *attr) -{ - int ret = 0; - PVFS_credentials *credentials; - PVFS_sysresp_getattr getattr_response; + //Could do this serially or in parallel + uint64_t block_loc = 0; + for(i = 0; i < tag_cnt; i++) + { + if(which == 1) /* Read */ + { + if(hits[i] == 1) /* Hit */ + { + /* Read from Cache */ + //instead of looking up again, save lookup somehow + block_loc = (voidp_t)ucache_lookup(fs_id, handle, tags[i], &block_ndx); + lock_lock(ucache_lock); + lock_lock(&ucache_block_lock[block_ndx]); + rc = place_data(1, block_loc, vector, &iovec_ndx, + &scratch, &scratch_ptr, &scratch_left); + lock_unlock(&ucache_block_lock[block_ndx]); + lock_unlock(ucache_lock); + } + else /* Miss */ + { + /* read from fs into user mem */ + rc = iocommon_readorwrite_nocache(which, pd, offset, + buf, mem_req, file_req); + if(rc > 0) + { + block_loc = (voidp_t)ucache_insert(fs_id, handle, tags[i], + &block_ndx); + } + /* Copy into cache if possible */ + if(block_loc != (uint64_t)NIL) + { + lock_lock(ucache_lock); + lock_lock(&ucache_block_lock[block_ndx]); + rc = place_data(2, block_loc, vector, &iovec_ndx, + &scratch, &scratch_ptr, &scratch_left); + lock_unlock(&ucache_block_lock[block_ndx]); + lock_unlock(ucache_lock); + } + } + } + else if(which == 2) /* Write */ + { + if(hits[i] == 1) /* Hit */ + { + /* Overwrite block in cache */ + /* //or use previous return value */ + block_loc = (voidp_t)ucache_lookup(fs_id, handle, tags[i], &block_ndx); + lock_lock(ucache_lock); + lock_lock(&ucache_block_lock[block_ndx]); + rc = place_data(2, block_loc, vector, &iovec_ndx, + &scratch, &scratch_ptr, &scratch_left); + lock_unlock(&ucache_block_lock[block_ndx]); + lock_unlock(ucache_lock); + } + else /* Miss */ + { + /* Attempt ucache insert, on fail, send to file system */ + block_loc = (voidp_t)ucache_insert(fs_id, handle, tags[i], &block_ndx); + if(block_loc != (uint64_t)NIL) + { + lock_lock(ucache_lock); + lock_lock(&ucache_block_lock[block_ndx]); + rc = place_data(2, block_loc, vector, &iovec_ndx, + &scratch, &scratch_ptr, &scratch_left); + lock_unlock(&ucache_block_lock[block_ndx]); + lock_unlock(ucache_lock); + } + else + { + rc = iocommon_readorwrite_nocache(which, pd, offset, + buf, mem_req, file_req); + } + } + } + } + return rc; +} - /* check credentials */ - iocommon_cred(&credentials); +/** TODO + * 1: read, read from user cache and write to user mem + * 2: write, read from user mem and write to user cache + */ +uint32_t place_data(enum PVFS_io_type which, const uint64_t block, + const struct iovec *vector, + int *iovec_ndx, unsigned char *scratch, + void **scratch_ptr, uint64_t *scratch_left) +{ + const uint64_t block_size = CACHE_BLOCK_SIZE_K * 1024; + /* Bytes of block remaining to be read/written */ + uint64_t left = CACHE_BLOCK_SIZE_K * 1024; + void *user_mem = 0; /* Where to read/write */ + uint64_t user_mem_size = 0; /* How much to read/write */ + + /* Continue read/writing strips of data until the whole block completed */ + while(left != 0) + { + /* Do we need to use the scratch_ptr or a fresh segment */ + if(*scratch) + { + /* Use a previously used buffer that wasn't quite filled by the + * previous cache block. + */ + user_mem = *scratch_ptr; + user_mem_size = *scratch_left; + *scratch = 0; + } + else + { + user_mem = vector[*iovec_ndx].iov_base; + user_mem_size = vector[*iovec_ndx].iov_len; + } - /* now get attributes */ - ret = PVFS_sys_getattr(obj, - PVFS_ATTR_SYS_ALL_NOHINT, - credentials, - &getattr_response, NULL); + /* Will this transfer complete the block but not the user mem segment */ + if(user_mem_size > left) + { + /* Save a reference to where we left off with this segment*/ + *scratch_ptr = (void *)(user_mem + left); + *scratch_left = user_mem_size - left; + *scratch = 1; + } + else + { + /* We're done with this user mem segment */ + (*iovec_ndx)++; + } - *attr = getattr_response.attr; + /* More Data! */ + if(which == 1) + { + /* Read */ + memcpy(user_mem, (void *)(voidp_t)(block + (block_size - left)), (size_t)user_mem_size); + } + else + { + /* Write */ + memcpy((void*)(voidp_t)(block + (block_size - left)), user_mem, (size_t)user_mem_size); + } + + left -= user_mem_size; + } + return 1; +} + +/** do a blocking read or write + * + */ +int iocommon_readorwrite_nocache(enum PVFS_io_type which, + pvfs_descriptor *pd, + PVFS_size offset, + void *buf, + PVFS_Request mem_req, + PVFS_Request file_req) + //returned by nonblocking operations +{ + int rc = 0; + int orig_errno = errno; + PVFS_credentials *creds; + PVFS_sysresp_io io_resp; - if(ret < 0) + if (!pd || pd->is_in_use != PVFS_FS) { - errno = EACCES; /* need to get proper return code */ + errno = EBADF; + return -1; + } + /* Initialize */ + memset(&io_resp, 0, sizeof(io_resp)); + + //Ensure descriptor is used for the correct type of access + if ((which==PVFS_IO_READ && (O_WRONLY == (pd->flags & O_ACCMODE))) || + (which==PVFS_IO_WRITE && (O_RDONLY == (pd->flags & O_ACCMODE)))) + { + errno = EBADF; return -1; } + iocommon_cred(&creds); + + rc = PVFS_sys_io(pd->pvfs_ref, + file_req, + offset, + buf, + mem_req, + creds, + &io_resp, + which, + PVFS_HINT_NULL); + IOCOMMON_CHECK_ERR(rc); + return io_resp.total_completed; + +errorout: + return rc; +} + +/** Do a nonblocking read or write, possibly utilizing the user cache. + * + * extra_offset = extra padding to the pd's offset, + * independent of the pd's offset + * Returns an op_id, response, and ret_mem_request + * (which represents an etype_req*count region) + * Note that the none of the PVFS_Requests are freed + * +int iocommon_ireadorwrite(enum PVFS_io_type which, + pvfs_descriptor *pd, + PVFS_size extra_offset, + void *buf, + PVFS_Request etype_req, + PVFS_Request file_req, + size_t count, + PVFS_sys_op_id *ret_op_id, + PVFS_sysresp_io *ret_resp, + PVFS_Request *ret_memory_req) +{ + #ifndef UCACHE_ENABLED + // No cache + return iocommon_ireadorwrite_nocache(which, pd, extra_offset, buf, + etype_req, file_req, count, ret_op_id, ret_resp, ret_memory_req); + #endif // UCACHE_ENABLED + + //if read then check cache..if not there..then read from i/o node and store into correct location + //Possibly Data Transfer + //Possibly More Cache Routines +} +*/ + +/** Do a nonblocking read or write + * + * extra_offset = extra padding to the pd's offset, + * independent of the pd's offset + * Returns an op_id, response, and ret_mem_request + * (which represents an etype_req*count region) + * Note that the none of the PVFS_Requests are freed + */ +int iocommon_ireadorwrite(enum PVFS_io_type which, + pvfs_descriptor *pd, + PVFS_size extra_offset, + void *buf, + PVFS_Request etype_req, + PVFS_Request file_req, + size_t count, + PVFS_sys_op_id *ret_op_id, + PVFS_sysresp_io *ret_resp, + PVFS_Request *ret_memory_req) +{ + int rc = 0; + int orig_errno = errno; + PVFS_Request contig_memory_req; + PVFS_credentials *credentials; + PVFS_size req_size; + + if (!pd || pd->is_in_use != PVFS_FS) + { + errno = EBADF; + return -1; + } + //Ensure descriptor is used for the correct type of access + if ((which==PVFS_IO_READ && (O_WRONLY == (pd->flags & O_ACCMODE))) || + (which==PVFS_IO_WRITE && (O_RDONLY == (pd->flags & O_ACCMODE)))) + { + errno = EBADF; + return PVFS_FD_FAILURE; + } + + //Create the memory request of a contiguous region: 'mem_req' x count + rc = PVFS_Request_contiguous(count, etype_req, &contig_memory_req); + + iocommon_cred(&credentials); + + rc = PVFS_isys_io(pd->pvfs_ref, + file_req, + pd->file_pointer+extra_offset, + buf, + contig_memory_req, + credentials, + ret_resp, + which, + ret_op_id, + PVFS_HINT_NULL, + NULL); + IOCOMMON_CHECK_ERR(rc); + + assert(*ret_op_id!=-1);//TODO: handle this + + PVFS_Request_size(contig_memory_req, &req_size); + pd->file_pointer += req_size; + *ret_memory_req = contig_memory_req; return 0; + +errorout: + return rc; } -/* WBL - question - should attr not be a pointer */ -int iocommon_setattr(PVFS_object_ref obj, PVFS_sys_attr *attr) +/** Implelments an object attribute get or read + * + */ +int iocommon_getattr(PVFS_object_ref obj, PVFS_sys_attr *attr, uint32_t mask) { - int ret = 0; - PVFS_credentials *credentials; + int rc = 0; + int orig_errno = errno; + PVFS_credentials *credentials; + PVFS_sysresp_getattr getattr_response; + + /* Initialize */ + memset(&getattr_response, 0, sizeof(getattr_response)); /* check credentials */ iocommon_cred(&credentials); /* now get attributes */ - ret = PVFS_sys_setattr(obj, *attr, credentials, NULL); + rc = PVFS_sys_getattr(obj, + mask, + credentials, + &getattr_response, NULL); + IOCOMMON_CHECK_ERR(rc); + *attr = getattr_response.attr; - if(ret < 0) - { - errno = EACCES; /* need to get proper return code */ - return -1; - } +errorout: + return rc; +} - return 0; +/** Implelments an object attribute set or write + * + */ +int iocommon_setattr(PVFS_object_ref obj, PVFS_sys_attr *attr) +{ + int rc = 0; + int orig_errno = errno; + PVFS_credentials *credentials; + + /* check credentials */ + iocommon_cred(&credentials); + + /* now get attributes */ + rc = PVFS_sys_setattr(obj, *attr, credentials, NULL); + IOCOMMON_CHECK_ERR(rc); + +errorout: + return rc; } -int iocommon_stat(pvfs_descriptor *pd, struct stat *buf) +int iocommon_stat(pvfs_descriptor *pd, struct stat *buf, uint32_t mask) { - int ret = 0; - PVFS_sys_attr attr; + int rc = 0; + PVFS_sys_attr attr; + + if (!pd || pd->is_in_use != PVFS_FS) + { + errno = EBADF; + return -1; + } + /* Initialize */ + memset(&attr, 0, sizeof(attr)); - iocommon_getattr(pd->pvfs_ref, &attr); + rc = iocommon_getattr(pd->pvfs_ref, &attr, mask); + IOCOMMON_RETURN_ERR(rc); /* copy attributes into standard stat struct */ buf->st_dev = pd->pvfs_ref.fs_id; buf->st_ino = pd->pvfs_ref.handle; buf->st_mode = attr.perms; - if (attr.objtype & PVFS_TYPE_METAFILE) + if (attr.objtype == PVFS_TYPE_METAFILE) + { buf->st_mode |= S_IFREG; - if (attr.objtype & PVFS_TYPE_DIRECTORY) + } + if (attr.objtype == PVFS_TYPE_DIRECTORY) + { buf->st_mode |= S_IFDIR; - if (attr.objtype & PVFS_TYPE_SYMLINK) + } + if (attr.objtype == PVFS_TYPE_SYMLINK) + { buf->st_mode |= S_IFLNK; + } buf->st_nlink = 1; /* PVFS does not allow hard links */ buf->st_uid = attr.owner; buf->st_gid = attr.group; @@ -653,30 +1371,46 @@ int iocommon_stat(pvfs_descriptor *pd, struct stat *buf) buf->st_mtime = attr.mtime; buf->st_ctime = attr.ctime; - return 0; +errorout: + return rc; } /* * The only difference here is that buf is stat64 which * means some of its fields are defined as different types */ -int iocommon_stat64(pvfs_descriptor *pd, struct stat64 *buf) +int iocommon_stat64(pvfs_descriptor *pd, struct stat64 *buf, uint32_t mask) { - int ret = 0; - PVFS_sys_attr attr; + int rc = 0; + PVFS_sys_attr attr; + + if (!pd || pd->is_in_use != PVFS_FS) + { + errno = EBADF; + return -1; + } + /* Initialize */ + memset(&attr, 0, sizeof(attr)); - iocommon_getattr(pd->pvfs_ref, &attr); + rc = iocommon_getattr(pd->pvfs_ref, &attr, mask); + IOCOMMON_RETURN_ERR(rc); /* copy attributes into standard stat struct */ buf->st_dev = pd->pvfs_ref.fs_id; buf->st_ino = pd->pvfs_ref.handle; buf->st_mode = attr.perms; - if (attr.objtype & PVFS_TYPE_METAFILE) + if (attr.objtype == PVFS_TYPE_METAFILE) + { buf->st_mode |= S_IFREG; - if (attr.objtype & PVFS_TYPE_DIRECTORY) + } + if (attr.objtype == PVFS_TYPE_DIRECTORY) + { buf->st_mode |= S_IFDIR; - if (attr.objtype & PVFS_TYPE_SYMLINK) + } + if (attr.objtype == PVFS_TYPE_SYMLINK) + { buf->st_mode |= S_IFLNK; + } buf->st_nlink = 1; /* PVFS does not allow hard links */ buf->st_uid = attr.owner; buf->st_gid = attr.group; @@ -688,46 +1422,66 @@ int iocommon_stat64(pvfs_descriptor *pd, struct stat64 *buf) buf->st_mtime = attr.mtime; buf->st_ctime = attr.ctime; - return 0; +errorout: + return rc; } int iocommon_chown(pvfs_descriptor *pd, uid_t owner, gid_t group) { - int ret = 0; - PVFS_sys_attr attr; + int rc = 0; + PVFS_sys_attr attr; + + if (!pd || pd->is_in_use != PVFS_FS) + { + errno = EBADF; + return -1; + } + /* Initialize */ + memset(&attr, 0, sizeof(attr)); if (owner != -1) + { attr.owner = owner; - if (owner != -1) + attr.mask |= PVFS_ATTR_SYS_UID; + } + if (group != -1) + { attr.group = group; - attr.mask = PVFS_ATTR_SYS_UID | PVFS_ATTR_SYS_GID; - - ret = iocommon_setattr(pd->pvfs_ref, &attr); + attr.mask |= PVFS_ATTR_SYS_GID; + } - return ret; + rc = iocommon_setattr(pd->pvfs_ref, &attr); + return rc; } int iocommon_chmod(pvfs_descriptor *pd, mode_t mode) { - int ret = 0; - PVFS_sys_attr attr; + int rc = 0; + PVFS_sys_attr attr; + + if (!pd || pd->is_in_use != PVFS_FS) + { + errno = EBADF; + return -1; + } + /* Initialize */ + memset(&attr, 0, sizeof(attr)); attr.perms = mode & 07777; /* mask off any stray bits */ attr.mask = PVFS_ATTR_SYS_PERM; - ret = iocommon_setattr(pd->pvfs_ref, &attr); - - return ret; + rc = iocommon_setattr(pd->pvfs_ref, &attr); + return rc; } -iocommon_make_directory(const char *pvfs_path, const int mode) +int iocommon_make_directory(const char *pvfs_path, + const int mode, + PVFS_object_ref *pdir) { - int ret = 0; - char parent_dir[PVFS_NAME_MAX] = ""; - char base[PVFS_NAME_MAX] = ""; - char realpath[PVFS_NAME_MAX] = ""; - char * parentdir_ptr = NULL; - char * basename_ptr = NULL; + int rc = 0; + int orig_errno = errno; + char *parentdir = NULL; + char *filename = NULL; PVFS_sys_attr attr; PVFS_sysresp_lookup resp_lookup; PVFS_object_ref parent_ref; @@ -740,61 +1494,78 @@ iocommon_make_directory(const char *pvfs_path, const int mode) memset(&parent_ref, 0, sizeof(parent_ref)); memset(&resp_mkdir, 0, sizeof(resp_mkdir)); + pvfs_sys_init(); iocommon_cred(&credentials); - /* - * Copy the file name into structures to be passed to dirname and basename - * These calls change the parameter, so we don't want to mess with original - */ - strcpy(parent_dir, pvfs_path); - strcpy(base, pvfs_path); + rc = split_pathname(pvfs_path, 1, &parentdir, &filename); + IOCOMMON_RETURN_ERR(rc); - parentdir_ptr = dirname(parent_dir); - basename_ptr = basename(base); + /* Make sure we don't try and create the root or current directory */ - /* Make sure we don't try and create the root directory */ - if( strcmp(basename_ptr, "/") == 0 ) + /* lookup parent */ + if (!pdir) { - errno = EEXIST; - return(-1); + rc = iocommon_lookup_absolute(parentdir, &parent_ref, NULL, 0); + IOCOMMON_RETURN_ERR(rc); + } + else + { + if (parentdir) + { + rc = iocommon_lookup_relative(parentdir, *pdir, + PVFS2_LOOKUP_LINK_FOLLOW, &parent_ref, NULL, 0); + IOCOMMON_RETURN_ERR(rc); + } + else + { + parent_ref = *pdir; + } } - - /* lookup parent */ - ret = iocommon_lookup_absolute(parentdir_ptr, &parent_ref); /* Set the attributes for the new directory */ - attr.owner = credentials->uid; - attr.group = credentials->gid; - attr.perms = mode; + attr.owner = geteuid(); + attr.group = getegid(); + attr.perms = mode & 07777; /* mask off stray bits */ attr.mask = (PVFS_ATTR_SYS_ALL_SETABLE); - /* Clear out any info from previous calls */ - memset(&resp_mkdir, 0, sizeof(PVFS_sysresp_mkdir)); + rc = PVFS_sys_mkdir(filename, + parent_ref, + attr, + credentials, + &resp_mkdir, NULL); + IOCOMMON_CHECK_ERR(rc); - ret = PVFS_sys_mkdir(basename_ptr, - parent_ref, - attr, - credentials, - &resp_mkdir, NULL); - - if (ret != 0) +errorout: + if (parentdir) { - errno = ret; - return(-1); + free(parentdir); } - - return(0); + if (filename) + { + free(filename); + } + return(rc); } int iocommon_readlink(pvfs_descriptor *pd, char *buf, int size) { - int ret = 0; - PVFS_sys_attr attr; + int rc = 0; + PVFS_sys_attr attr; + + if (!pd || pd->is_in_use != PVFS_FS) + { + errno = EBADF; + return -1; + } + /* Initialize any variables */ + memset(&attr, 0, sizeof(attr)); - iocommon_getattr(pd->pvfs_ref, &attr); + rc = iocommon_getattr(pd->pvfs_ref, &attr, PVFS_ATTR_SYS_TYPE | + PVFS_ATTR_SYS_LNK_TARGET); + IOCOMMON_RETURN_ERR(rc); /* copy attributes into standard stat struct */ - if (attr.objtype & PVFS_TYPE_SYMLINK) + if (attr.objtype == PVFS_TYPE_SYMLINK) { strncpy(buf, attr.link_target, size); } @@ -804,18 +1575,18 @@ int iocommon_readlink(pvfs_descriptor *pd, char *buf, int size) return -1; } - return 0; +errorout: + return rc; } -int iocommon_symlink(const char *pvfs_path, - const char *link_target) +int iocommon_symlink(const char *pvfs_path, /* where new linkis created */ + const char *link_target, /* contents of the link */ + PVFS_object_ref *pdir) /* suports symlinkat */ { - int ret = 0; - char parent_dir[PVFS_NAME_MAX] = ""; - char base[PVFS_NAME_MAX] = ""; - char realpath[PVFS_NAME_MAX] = ""; - char * parentdir_ptr = NULL; - char * basename_ptr = NULL; + int rc = 0; + int orig_errno = errno; + char *parentdir = NULL; + char *filename = NULL; PVFS_sys_attr attr; PVFS_object_ref parent_ref; PVFS_sysresp_symlink resp_symlink; @@ -826,60 +1597,742 @@ int iocommon_symlink(const char *pvfs_path, memset(&parent_ref, 0, sizeof(parent_ref)); memset(&resp_symlink,0, sizeof(resp_symlink)); + pvfs_sys_init(); iocommon_cred(&credentials); - /* - * Copy the file name into structures to be passed to dirname and basename - * These calls change the parameter, so we don't want to mess with original - */ - strcpy(parent_dir, pvfs_path); - strcpy(base, pvfs_path); - parentdir_ptr = dirname(parent_dir); - basename_ptr = basename(base); + rc = split_pathname(pvfs_path, 0, &parentdir, &filename); + IOCOMMON_RETURN_ERR(rc); - /* Make sure we don't try and create the root directory */ - if( strcmp(basename_ptr, "/") == 0 ) - { - errno = EEXIST; - return(-1); - } + /* Make sure we don't try and create the root or current directory */ /* lookup parent */ - ret = iocommon_lookup_absolute(parentdir_ptr, &parent_ref); + if (!pdir) + { + rc = iocommon_lookup_absolute(parentdir, &parent_ref, NULL, 0); + IOCOMMON_RETURN_ERR(rc); + } + else + { + if (parentdir) + { + rc = iocommon_lookup_relative(parentdir, *pdir, + PVFS2_LOOKUP_LINK_FOLLOW, &parent_ref, NULL, 0); + IOCOMMON_RETURN_ERR(rc); + } + else + { + parent_ref = *pdir; + } + } /* Set the attributes for the new directory */ - attr.owner = credentials->uid; - attr.group = credentials->gid; + attr.owner = getuid(); + attr.group = getgid(); attr.perms = 0777; attr.mask = (PVFS_ATTR_SYS_ALL_SETABLE); - /* Clear out any info from previous calls */ - memset(&resp_symlink, 0, sizeof(PVFS_sysresp_symlink)); + rc = PVFS_sys_symlink(filename, + parent_ref, + (char *)link_target, + attr, + credentials, + &resp_symlink, + NULL); + IOCOMMON_CHECK_ERR(rc); - ret = PVFS_sys_symlink(basename_ptr, - parent_ref, - (char *)link_target, - attr, - credentials, - &resp_symlink, - NULL); +errorout: + if (parentdir) + { + free(parentdir); + } + if (filename) + { + free(filename); + } + return(rc); +} - if (ret != 0) +int iocommon_getdents(pvfs_descriptor *pd, /**< pvfs fiel descriptor */ + struct dirent *dirp, /**< pointer to buffer */ + unsigned int size) /**< number of bytes in buffer */ +{ + int rc = 0; + int orig_errno = errno; + int name_max; + int count; /* number of records to read */ + PVFS_credentials *credentials; + PVFS_sysresp_readdir readdir_resp; + PVFS_ds_position token; + int bytes = 0, i = 0; + + if (!pd || pd->is_in_use != PVFS_FS) { - errno = ret; - return(-1); + errno = EBADF; + return -1; } - - return(0); + if (pd->token == PVFS_READDIR_END) + { + return -1; /* EOF */ + } + + if (!S_ISDIR(pd->mode)) + { + errno = ENOENT; + return -1; + } + + /* Initialize */ + memset(&readdir_resp, 0, sizeof(readdir_resp)); + + iocommon_cred(&credentials); + + token = pd->token == 0 ? PVFS_READDIR_START : pd->token; + + /* posix deals in bytes in buffer and bytes read */ + /* PVFS deals in number of records to read or were read */ + count = size / sizeof(struct dirent); + if (count > PVFS_REQ_LIMIT_DIRENT_COUNT) + { + count = PVFS_REQ_LIMIT_DIRENT_COUNT; + } + rc = PVFS_sys_readdir(pd->pvfs_ref, + token, + count, + credentials, + &readdir_resp, + NULL); + IOCOMMON_CHECK_ERR(rc); + + pd->token = readdir_resp.token; + name_max = PVFS_util_min(NAME_MAX, PVFS_NAME_MAX); + for(i = 0; i < readdir_resp.pvfs_dirent_outcount; i++) + { + /* copy a PVFS_dirent to a struct dirent */ + dirp->d_ino = (long)readdir_resp.dirent_array[i].handle; + dirp->d_off = pd->file_pointer; + dirp->d_reclen = sizeof(PVFS_dirent); + memcpy(dirp->d_name, readdir_resp.dirent_array[i].d_name, name_max); + dirp->d_name[name_max] = 0; + pd->file_pointer += sizeof(struct dirent); + bytes += sizeof(struct dirent); + dirp++; + } + free(readdir_resp.dirent_array); + return bytes; + +errorout: + return rc; +} + +int iocommon_getdents64(pvfs_descriptor *pd, + struct dirent64 *dirp, + unsigned int size) +{ + int rc = 0; + int orig_errno = errno; + int name_max; + int count; + PVFS_credentials *credentials; + PVFS_sysresp_readdir readdir_resp; + PVFS_ds_position token; + int bytes = 0, i = 0; + + if (!pd || pd->is_in_use != PVFS_FS) + { + errno = EBADF; + return -1; + } + if (pd->token == PVFS_READDIR_END) + { + return -1; /* EOF */ + } + + if (!S_ISDIR(pd->mode)) + { + errno = ENOENT; + return -1; + } + + /* Initialize */ + memset(&readdir_resp, 0, sizeof(readdir_resp)); + + iocommon_cred(&credentials); + + token = pd->token == 0 ? PVFS_READDIR_START : pd->token; + + count = size / sizeof(struct dirent64); + if (count > PVFS_REQ_LIMIT_DIRENT_COUNT) + { + count = PVFS_REQ_LIMIT_DIRENT_COUNT; + } + rc = PVFS_sys_readdir(pd->pvfs_ref, + token, + count, + credentials, + &readdir_resp, + NULL); + IOCOMMON_CHECK_ERR(rc); + + pd->token = readdir_resp.token; + name_max = PVFS_util_min(NAME_MAX, PVFS_NAME_MAX); + for(i = 0; i < readdir_resp.pvfs_dirent_outcount; i++) + { + /* copy a PVFS_dirent to a struct dirent64 */ + dirp->d_ino = (uint64_t)readdir_resp.dirent_array[i].handle; + dirp->d_off = (off64_t)pd->file_pointer; + dirp->d_reclen = sizeof(struct dirent64); + memcpy(dirp->d_name, readdir_resp.dirent_array[i].d_name, name_max); + dirp->d_name[name_max] = 0; + pd->file_pointer += sizeof(struct dirent64); + bytes += sizeof(struct dirent64); + dirp++; + } + free(readdir_resp.dirent_array); + return bytes; + +errorout: + return rc; +} + +/* Read entries from a directory. + * + * \param token opaque value used to track position in directory + * when more than one read is required. + * \param pvfs_dirent_incount maximum number of entries to read, if + * available, starting from token. +PVFS_error PVFS_sys_readdir( + PVFS_object_ref ref, + PVFS_ds_position token, + int32_t pvfs_dirent_incount, + const PVFS_credentials *credentials, + PVFS_sysresp_readdir *resp, + PVFS_hint hints) + */ +/* Read entries from a directory and their associated attributes + * in an efficient manner. + * + * \param token opaque value used to track position in directory + * when more than one read is required. + * \param pvfs_dirent_incount maximum number of entries to read, if + * available, starting from token. +PVFS_error PVFS_sys_readdirplus( + PVFS_object_ref ref, + PVFS_ds_position token, + int32_t pvfs_dirent_incount, + const PVFS_credentials *credentials, + uint32_t attrmask, + PVFS_sysresp_readdirplus *resp, + PVFS_hint hints) + */ + +/** Checks to see if caller has the requested permissions + * + */ +int iocommon_access(const char *pvfs_path, + const int mode, + const int flags, + PVFS_object_ref *pdir) +{ + int rc = 0; + int orig_errno = errno; + char *parentdir = NULL; + char *file = NULL; + int followflag = PVFS2_LOOKUP_LINK_FOLLOW; + int uid = -1, gid = -1; + PVFS_object_ref parent_ref, file_ref; + PVFS_credentials *credentials; + PVFS_sys_attr attr; + + /* Initialize */ + memset(&parent_ref, 0, sizeof(parent_ref)); + memset(&file_ref, 0, sizeof(file_ref)); + memset(&attr, 0, sizeof(attr)); + + /* Initialize the system interface for this process */ + pvfs_sys_init(); + iocommon_cred(&credentials); + + rc = split_pathname(pvfs_path, 0, &parentdir, &file); + IOCOMMON_RETURN_ERR(rc); + + if (!pdir) + { + rc = iocommon_lookup_absolute(parentdir, &parent_ref, NULL, 0); + IOCOMMON_RETURN_ERR(rc); + } + else + { + if (parentdir) + { + rc = iocommon_lookup_relative(parentdir, *pdir, + PVFS2_LOOKUP_LINK_FOLLOW, &parent_ref, NULL, 0); + IOCOMMON_RETURN_ERR(rc); + } + else + { + parent_ref = *pdir; + } + } + /* Attempt to find file */ + if (flags & AT_SYMLINK_NOFOLLOW) + { + followflag = PVFS2_LOOKUP_LINK_NO_FOLLOW; + } + rc = iocommon_lookup_relative(file, + parent_ref, + followflag, + &file_ref, + NULL, + 0); + IOCOMMON_CHECK_ERR(rc); + /* Get file atributes */ + rc = iocommon_getattr(file_ref, &attr, PVFS_ATTR_SYS_COMMON_ALL); + IOCOMMON_RETURN_ERR(rc); + + if (flags & AT_EACCESS) + { + uid = getuid(); + gid = getgid(); + } + else + { + uid = geteuid(); + gid = getegid(); + } + if (uid == attr.owner) + { + if (((R_OK & mode) && !(S_IRUSR & attr.perms)) || + ((W_OK & mode) && !(S_IWUSR & attr.perms)) || + ((X_OK & mode) && !(S_IXUSR & attr.perms))) + { + errno = EACCES; + rc = -1; + goto errorout; + } + } + else if (gid == attr.group) + { + if (((R_OK & mode) && !(S_IRGRP & attr.perms)) || + ((W_OK & mode) && !(S_IWGRP & attr.perms)) || + ((X_OK & mode) && !(S_IXGRP & attr.perms))) + { + errno = EACCES; + rc = -1; + goto errorout; + } + } + else + { + if (((R_OK & mode) && !(S_IROTH & attr.perms)) || + ((W_OK & mode) && !(S_IWOTH & attr.perms)) || + ((X_OK & mode) && !(S_IXOTH & attr.perms))) + { + errno = EACCES; + rc = -1; + goto errorout; + } + } + /* Access is allowed, rc should be 0 */ + +errorout: + if (parentdir) + { + free(parentdir); + } + if (file) + { + free(file); + } + return rc; +} + +int iocommon_statfs(pvfs_descriptor *pd, struct statfs *buf) +{ + int rc = 0; + int orig_errno = errno; + int block_size = 2*1024*1024; /* optimal transfer size 2M */ + PVFS_credentials *credentials; + PVFS_sysresp_statfs statfs_resp; + + if (!pd || pd->is_in_use != PVFS_FS) + { + errno = EBADF; + return -1; + } + /* Initialize the system interface for this process */ + pvfs_sys_init(); + iocommon_cred(&credentials); + memset(&statfs_resp, 0, sizeof(statfs_resp)); + + rc = PVFS_sys_statfs(pd->pvfs_ref.fs_id, + credentials, + &statfs_resp, + NULL); + IOCOMMON_CHECK_ERR(rc); + /* assign fields for statfs struct */ + /* this is a fudge because they don't line up */ + buf->f_type = PVFS2_SUPER_MAGIC; + buf->f_bsize = block_size; + buf->f_blocks = statfs_resp.statfs_buf.bytes_total/1024; + buf->f_bfree = statfs_resp.statfs_buf.bytes_available/1024; + buf->f_bavail = statfs_resp.statfs_buf.bytes_available/1024; + buf->f_files = statfs_resp.statfs_buf.handles_total_count; + buf->f_ffree = statfs_resp.statfs_buf.handles_available_count; + buf->f_fsid.__val[0] = statfs_resp.statfs_buf.fs_id; + buf->f_fsid.__val[1] = 0; + buf->f_namelen = PVFS_NAME_MAX; + +errorout: + return rc; +} + +int iocommon_statfs64(pvfs_descriptor *pd, struct statfs64 *buf) +{ + int rc = 0; + int orig_errno = errno; + int block_size = 2*1024*1024; /* optimal transfer size 2M */ + PVFS_credentials *credentials; + PVFS_sysresp_statfs statfs_resp; + + if (!pd || pd->is_in_use != PVFS_FS) + { + errno = EBADF; + return -1; + } + /* Initialize the system interface for this process */ + pvfs_sys_init(); + iocommon_cred(&credentials); + memset(&statfs_resp, 0, sizeof(statfs_resp)); + + rc = PVFS_sys_statfs(pd->pvfs_ref.fs_id, + credentials, + &statfs_resp, + NULL); + IOCOMMON_CHECK_ERR(rc); + /* assign fields for statfs struct */ + /* this is a fudge because they don't line up */ + buf->f_type = PVFS2_SUPER_MAGIC; + buf->f_bsize = block_size; + buf->f_blocks = statfs_resp.statfs_buf.bytes_total/1024; + buf->f_bfree = statfs_resp.statfs_buf.bytes_available/1024; + buf->f_bavail = statfs_resp.statfs_buf.bytes_available/1024; + buf->f_files = statfs_resp.statfs_buf.handles_total_count; + buf->f_ffree = statfs_resp.statfs_buf.handles_available_count; + buf->f_fsid.__val[0] = statfs_resp.statfs_buf.fs_id; + buf->f_fsid.__val[1] = 0; + buf->f_namelen = PVFS_NAME_MAX; + +errorout: + return rc; } -int iocommon_getdents() +int iocommon_sendfile(int sockfd, pvfs_descriptor *pd, + off64_t *offset, size_t count) { + int rc = 0, bytes_read = 0; + PVFS_Request mem_req, file_req; + char *buffer; + int buffer_size = (8*1024*1024); + + if (!pd || pd->is_in_use != PVFS_FS) + { + errno = EBADF; + return -1; + } + buffer = (char *)malloc(buffer_size); + + PVFS_Request_contiguous(buffer_size, PVFS_BYTE, &mem_req); + file_req = PVFS_BYTE; + + rc = iocommon_readorwrite_nocache(PVFS_IO_READ, pd, *offset + bytes_read, + buffer, mem_req, file_req); + while(rc > 0) + { + int flags = 0; + bytes_read += rc; + if (bytes_read + buffer_size < count) + { + flags = MSG_MORE; + } + rc = glibc_ops.send(sockfd, buffer, rc, flags); + if (rc < 0) + { + break; + } + rc = iocommon_readorwrite_nocache(PVFS_IO_READ, pd, *offset + bytes_read, + buffer, mem_req, file_req); + } + PVFS_Request_free(&mem_req); + free(buffer); + if (rc < 0) + { + return -1; + } + else + { + *offset += bytes_read; + return bytes_read; + } +} + +/** Implelments an extended attribute get or read + * + * The PVFS server enforces namespaces as prefixes on the + * attribute keys. Thus they are not checked here. + * Probably would be more efficient to do so. + */ +int iocommon_geteattr(pvfs_descriptor *pd, + const char *key_p, + void *val_p, + int size) +{ + int rc = 0; + int orig_errno = errno; + PVFS_credentials *credentials; + PVFS_ds_keyval key, val; + + if (!pd || pd->is_in_use != PVFS_FS) + { + errno = EBADF; + return -1; + } + /* Initialize */ + memset(&key, 0, sizeof(key)); + memset(&val, 0, sizeof(val)); + + /* check credentials */ + iocommon_cred(&credentials); + + key.buffer = (char *)key_p; + key.buffer_sz = strlen(key_p) + 1; + val.buffer = val_p; + val.buffer_sz = size; + + /* now get attributes */ + rc = PVFS_sys_geteattr(pd->pvfs_ref, + credentials, + &key, + &val, + NULL); + IOCOMMON_CHECK_ERR(rc); + rc = val.read_sz; + +errorout: + return rc; } -int iocommon_access() +/** Implelments an extended attribute set or write + * + * The flag can be used to control whether to overwrite + * or create a new attribute. The default is to create + * if needed and overwrite if a previus value exists. + * The PVFS server enforces namespaces as prefixes on the + * attribute keys. Thus they are not checked here. + * Probably would be more efficient to do so. + */ +int iocommon_seteattr(pvfs_descriptor *pd, + const char *key_p, + const void *val_p, + int size, + int flag) { + int rc = 0; + int pvfs_flag = 0; + int orig_errno = errno; + PVFS_credentials *credentials; + PVFS_ds_keyval key, val; + + if (!pd || pd->is_in_use != PVFS_FS) + { + errno = EBADF; + return -1; + } + /* Initialize */ + memset(&key, 0, sizeof(key)); + memset(&val, 0, sizeof(val)); + + /* check credentials */ + iocommon_cred(&credentials); + + key.buffer = (char *)key_p; + key.buffer_sz = strlen(key_p) + 1; + val.buffer = (void *)val_p; + val.buffer_sz = size; + + if (flag & XATTR_CREATE)//TODO + { + pvfs_flag |= PVFS_XATTR_CREATE; + } + if (flag & XATTR_REPLACE)//TODO + { + pvfs_flag |= PVFS_XATTR_REPLACE; + } + + /* now set attributes */ + rc = PVFS_sys_seteattr(pd->pvfs_ref, + credentials, + &key, + &val, + pvfs_flag, + NULL); + IOCOMMON_CHECK_ERR(rc); + +errorout: + return rc; +} + +/** Implements an extended attribute delete or remove + * + * The PVFS server enforces namespaces as prefixes on the + * attribute keys. Thus they are not checked here. + * Probably would be more efficient to do so. + */ +int iocommon_deleattr(pvfs_descriptor *pd, + const char *key_p) +{ + int rc = 0; + int orig_errno = errno; + PVFS_credentials *credentials; + PVFS_ds_keyval key; + + if (!pd || pd->is_in_use != PVFS_FS) + { + errno = EBADF; + return -1; + } + /* Initialize */ + memset(&key, 0, sizeof(key)); + + /* check credentials */ + iocommon_cred(&credentials); + + key.buffer = (char *)key_p; + key.buffer_sz = strlen(key_p) + 1; + + /* now set attributes */ + rc = PVFS_sys_deleattr(pd->pvfs_ref, + credentials, + &key, + NULL); + IOCOMMON_CHECK_ERR(rc); + +errorout: + return rc; +} + +/** Implelments an extended attribute key list + * + * All of the keys for athe specified object are returned + * in the specified buffer, NULL delimited. The number + * of keys is returned. If the size passed in is 0, then + * only the number of keys available is returned. + * The PVFS server enforces namespaces as prefixes on the + * attribute keys. Thus they are not checked here. + * Probably would be more efficient to do so. + */ +int iocommon_listeattr(pvfs_descriptor *pd, + char *list, + int size, + int *numkeys) +{ + int rc = 0; + int orig_errno = errno; + int k, total_size, total_keys, max_keys; + int32_t nkey; + PVFS_ds_position token; + PVFS_credentials *credentials; + PVFS_sysresp_listeattr listeattr_resp; + + if (!pd || pd->is_in_use != PVFS_FS) + { + errno = EBADF; + return -1; + } + /* Initialize */ + memset(&listeattr_resp, 0, sizeof(listeattr_resp)); + token = PVFS_ITERATE_START; + total_size = 0; + total_keys = 0; + nkey = 0; + + /* check credentials */ + iocommon_cred(&credentials); + + /* find number of attributes */ + rc = PVFS_sys_listeattr(pd->pvfs_ref, + token, + nkey, + credentials, + &listeattr_resp, + NULL); + IOCOMMON_CHECK_ERR(rc); + + /* get available keys */ + nkey = listeattr_resp.nkey; + + if (size == 0) + { + *numkeys = nkey; + goto errorout; + } + + /* allocate key_array */ + if (nkey < PVFS_MAX_XATTR_LISTLEN) + { + max_keys = PVFS_MAX_XATTR_LISTLEN; + } + else + { + max_keys = nkey; + } + listeattr_resp.key_array = (PVFS_ds_keyval *)malloc(max_keys * + sizeof(PVFS_ds_keyval)); + for (k = 0; k < max_keys; k++) + { + listeattr_resp.key_array[k].buffer_sz = PVFS_MAX_XATTR_NAMELEN; + listeattr_resp.key_array[k].buffer = + (char *)malloc(PVFS_MAX_XATTR_NAMELEN); + } + + /* now list attributes */ + do + { + token = listeattr_resp.token; + listeattr_resp.nkey = max_keys; + rc = PVFS_sys_listeattr(pd->pvfs_ref, + token, + nkey, + credentials, + &listeattr_resp, + NULL); + IOCOMMON_CHECK_ERR(rc); + + /* copy keys out to caller */ + for (k = 0; k < listeattr_resp.nkey; k++) + { + if (total_size + listeattr_resp.key_array[k].read_sz > size) + { + total_size = size; + break; /* ran out of buffer space */ + } + strncpy(list, listeattr_resp.key_array[k].buffer, + listeattr_resp.key_array[k].read_sz); + list += listeattr_resp.key_array[k].read_sz; + total_size += listeattr_resp.key_array[k].read_sz; + } + total_keys += listeattr_resp.nkey; + } while (total_keys < nkey && listeattr_resp.nkey > 0 && + total_size < size); + /* free key_array */ + for (k = 0; k < max_keys; k++) + { + free(listeattr_resp.key_array[k].buffer); + } + free(listeattr_resp.key_array); + +errorout: + return rc; } /* diff --git a/src/client/usrint/iocommon.h b/src/client/usrint/iocommon.h index 4eb3ad7..ac07a63 100644 --- a/src/client/usrint/iocommon.h +++ b/src/client/usrint/iocommon.h @@ -1,3 +1,14 @@ +/* + * (C) 2011 Clemson University and The University of Chicago + * + * See COPYING in top-level directory. + */ + +/** \file + * \ingroup usrint + * + * PVFS2 user interface routines + */ #ifndef IOCOMMON_H #define IOCOMMON_H 1 @@ -11,15 +22,22 @@ #define O_NOFOLLOW 0 #endif -// Base pvfs file handle info: -// native-lib and mpi-io both wrap around pvfs_descriptor for their file table entries +/* Base pvfs file handle info: + * native-lib and mpi-io both wrap around + * pvfs_descriptor for their file table entries + */ #define PVFS_NULL_OBJ ((PVFS_object_ref *)NULL) +/* this global is set when a pvfs specific error is returned + * and errno is set to EIO + */ +extern int pvfs_errno; + /* prototypes */ /* Perform PVFS initialization if not already finished */ -void iocommon_ensure_init(); +void iocommon_ensure_init(void); void iocommon_cred(PVFS_credentials **credentials); @@ -29,24 +47,29 @@ int iocommon_fsync(pvfs_descriptor *pvfs_info); * Find the PVFS handle to an object (file, dir sym) * assumes an absoluate path */ -int iocommon_lookup_absolute( const char *abs_path, PVFS_object_ref *ref); +int iocommon_lookup_absolute(const char *abs_path, + PVFS_object_ref *ref, + char *error_path, + int error_path_size); /* * Lookup a file via the PVFS system interface */ -int iocommon_lookup_relative( const char *rel_path, +int iocommon_lookup_relative(const char *rel_path, PVFS_object_ref parent_ref, int follow_links, - PVFS_object_ref *ref ); + PVFS_object_ref *ref, + char *error_path, + int error_path_size); /* * Create a file via the PVFS system interface */ -int iocommon_create_file( const char *filename, +int iocommon_create_file(const char *filename, mode_t file_permission, PVFS_hint file_creation_param, PVFS_object_ref parent_ref, - PVFS_object_ref *ref ); + PVFS_object_ref *ref); /* pvfs_open implementation, return file info in fd */ @@ -55,30 +78,70 @@ int iocommon_create_file( const char *filename, pvfs_descriptor *iocommon_open(const char *pathname, int flag, PVFS_hint file_creation_param, mode_t file_permission, - PVFS_object_ref *pdir); + pvfs_descriptor *pdir); + +int iocommon_truncate(PVFS_object_ref file_ref, + off64_t length); -off64_t iocommon_lseek(pvfs_descriptor *pd, off64_t offset, PVFS_size unit_size, int whence); +off64_t iocommon_lseek(pvfs_descriptor *pd, + off64_t offset, + PVFS_size unit_size, + int whence); /* * pvfs_unlink implementation * need to verify this is a file or symlink * use rmdir for directory */ -int iocommon_remove (const char *pathname, int dirflag) ; +int iocommon_remove (const char *pathname, PVFS_object_ref *pdir, int dirflag); -int iocommon_unlink(const char *pathname); +int iocommon_unlink(const char *pathname, PVFS_object_ref *pdir); -int iocommon_rmdir(const char *pathname); +int iocommon_rmdir(const char *pathname, PVFS_object_ref *pdir); /* if dir(s) are NULL, assume name is absolute */ -int iocommon_rename(pvfs_descriptor *olddir, const char *oldname, - pvfs_descriptor *newdir, const char *newname); +int iocommon_rename(PVFS_object_ref *oldpdir, const char *oldname, + PVFS_object_ref *newpdir, const char *newname); + +/* R/W Wrapper Functions, possibly utilizing user cache */ +/* do a blocking read or write + */ +int iocommon_readorwrite(enum PVFS_io_type which, + pvfs_descriptor *pd, + PVFS_size offset, + void *buf, + PVFS_Request mem_req, + PVFS_Request file_req, + size_t count, + const struct iovec *vector); + +/* Read or write block data to/from cache */ +uint32_t place_data(enum PVFS_io_type which, const uint64_t block, const struct iovec *vector, + int *iovec_ndx, unsigned char *scratch, void **scratch_ptr, + uint64_t *scratch_left); + + +/* [Do a nonblocking read or write] */ +int iocommon_ireadorwrite_nocache(enum PVFS_io_type which, + pvfs_descriptor *pd, + PVFS_size extra_offset, + void *buf, + PVFS_Request etype_req, + PVFS_Request file_req, + size_t count, + PVFS_sys_op_id *ret_op_id, + PVFS_sysresp_io *ret_resp, + PVFS_Request *ret_memory_req); + /* do a blocking read or write * extra_offset = extra padding to the pd's offset, independent of the pd's offset */ -int iocommon_readorwrite( enum PVFS_io_type which, - pvfs_descriptor *pd, PVFS_size offset, void *buf, - PVFS_Request etype_req, PVFS_Request file_req, size_t count); +int iocommon_readorwrite_nocache(enum PVFS_io_type which, + pvfs_descriptor *pd, + PVFS_size offset, + void *buf, + PVFS_Request mem_req, + PVFS_Request file_req); //returned by nonblocking operations /* @@ -89,38 +152,72 @@ int iocommon_readorwrite( enum PVFS_io_type which, * (which represents an etype_req*count region) * Note that the none of the PVFS_Requests are freed */ -int iocommon_ireadorwrite( enum PVFS_io_type which, - pvfs_descriptor *pd, PVFS_size extra_offset, void *buf, - PVFS_Request etype_req, PVFS_Request file_req, size_t count, - PVFS_sys_op_id *ret_op_id, PVFS_sysresp_io *ret_resp, - PVFS_Request *ret_memory_req); - -int iocommon_getattr(PVFS_object_ref obj, PVFS_sys_attr *attr); +int iocommon_ireadorwrite_nocache(enum PVFS_io_type which, + pvfs_descriptor *pd, + PVFS_size extra_offset, + void *buf, + PVFS_Request etype_req, + PVFS_Request file_req, + size_t count, + PVFS_sys_op_id *ret_op_id, + PVFS_sysresp_io *ret_resp, + PVFS_Request *ret_memory_req); + +int iocommon_getattr(PVFS_object_ref obj, PVFS_sys_attr *attr, uint32_t mask); int iocommon_setattr(PVFS_object_ref obj, PVFS_sys_attr *attr); -int iocommon_stat(pvfs_descriptor *pd, struct stat *buf); +int iocommon_stat(pvfs_descriptor *pd, struct stat *buf, uint32_t mask); /* * The only difference here is that buf is stat64 which * means some of its fields are defined as different types */ -int iocommon_stat64(pvfs_descriptor *pd, struct stat64 *buf); +int iocommon_stat64(pvfs_descriptor *pd, struct stat64 *buf, uint32_t mask); + +int iocommon_statfs(pvfs_descriptor *pd, struct statfs *buf); + +int iocommon_statfs64(pvfs_descriptor *pd, struct statfs64 *buf); + +int iocommon_seteattr(pvfs_descriptor *pd, const char *key, const void *val, int size, int flag); + +int iocommon_geteattr(pvfs_descriptor *pd, const char *key, void *val, int size); + +int iocommon_listeattr(pvfs_descriptor *pd, char *list, int size, int *numkeys); + +int iocommon_deleattr(pvfs_descriptor *pd, const char * key); int iocommon_chown(pvfs_descriptor *pd, uid_t owner, gid_t group); int iocommon_chmod(pvfs_descriptor *pd, mode_t mode); -int iocommon_make_directory(const char *pvfs_path, const int mode); +int iocommon_make_directory(const char *pvfs_path, + int mode, + PVFS_object_ref *pdir); int iocommon_readlink(pvfs_descriptor *pd, char *buf, int size); -int iocommon_symlink(const char *pvfs_path, const char *link_target); +int iocommon_symlink(const char *pvfs_path, + const char *link_target, + PVFS_object_ref *pdir); + +int iocommon_getdents(pvfs_descriptor *pd, + struct dirent *dirp, + unsigned int count); -int iocommon_getdents(); +int iocommon_getdents64(pvfs_descriptor *pd, + struct dirent64 *dirp, + unsigned int count); -int iocommon_access(); +int iocommon_access(const char *pvfs_path, + int mode, + int flags, + PVFS_object_ref *pdir); +int iocommon_sendfile(int sockfd, + pvfs_descriptor *pd, + off64_t *offset, + size_t count); /* * Local variables: * c-indent-level: 4 diff --git a/src/client/usrint/openfile-util.c b/src/client/usrint/openfile-util.c index 84dadac..934963d 100644 --- a/src/client/usrint/openfile-util.c +++ b/src/client/usrint/openfile-util.c @@ -1,82 +1,367 @@ -#include +/* + * (C) 2011 Clemson University and The University of Chicago + * + * See COPYING in top-level directory. + */ + +/** \file + * \ingroup usrint + * + * PVFS2 user interface routines - routines to manage open files + */ +#define USRINT_SOURCE 1 +#include "usrint.h" +#include +#ifndef SYS_readdir +#define SYS_readdir 89 +#endif +#include "posix-ops.h" +#include "openfile-util.h" +#include "posix-pvfs.h" +#include "ucache.h" -static int pvfs_is_sys_initialized = 0; +static struct glibc_redirect_s +{ + int (*stat)(int ver, const char *path, struct stat *buf); + int (*stat64)(int ver, const char *path, struct stat64 *buf); + int (*fstat)(int ver, int fd, struct stat *buf); + int (*fstat64)(int ver, int fd, struct stat64 *buf); + int (*fstatat)(int ver, int fd, const char *path, struct stat *buf, int flag); + int (*fstatat64)(int ver, int fd, const char *path, struct stat64 *buf, int flag); + int (*lstat)(int ver, const char *path, struct stat *buf); + int (*lstat64)(int ver, const char *path, struct stat64 *buf); + int (*mknod)(int ver, const char *path, mode_t mode, dev_t dev); + int (*mknodat)(int ver, int dirfd, const char *path, mode_t mode, dev_t dev); +} glibc_redirect; #define PREALLOC 3 +static char logfilepath[25]; +static int logfile; +static int pvfs_initializing_flag = 0; static int descriptor_table_count = 0; static int descriptor_table_size = 0; -static int next_descriptor = 0; static pvfs_descriptor **descriptor_table; +static char rstate[256]; /* used for random number generation */ + +posix_ops glibc_ops; pvfs_descriptor pvfs_stdin = { .fd = 0, .fsops = &glibc_ops, - .posix_fd = STDIN_FILENO, + .true_fd = STDIN_FILENO, .pvfs_ref.fs_id = 0, .pvfs_ref.handle = 0, .flags = O_RDONLY, + .mode = 0, .file_pointer = 0, - .is_in_use = 1, - .dirty = 0, - .buf = NULL, - .buftotal = 0, - .bufsize = 0, - .buf_off = 0, - .bufptr = NULL + .token = 0, + .dpath = NULL, + .is_in_use = PVFS_FS }; pvfs_descriptor pvfs_stdout = { .fd = 1, .fsops = &glibc_ops, - .posix_fd = STDOUT_FILENO, + .true_fd = STDOUT_FILENO, .pvfs_ref.fs_id = 0, .pvfs_ref.handle = 0, .flags = O_WRONLY | O_APPEND, + .mode = 0, .file_pointer = 0, - .is_in_use = 1, - .dirty = 0, - .buf = NULL, - .buftotal = 0, - .bufsize = 0, - .buf_off = 0, - .bufptr = NULL + .token = 0, + .dpath = NULL, + .is_in_use = PVFS_FS }; pvfs_descriptor pvfs_stderr = { .fd = 2, .fsops = &glibc_ops, - .posix_fd = STDERR_FILENO, + .true_fd = STDERR_FILENO, .pvfs_ref.fs_id = 0, .pvfs_ref.handle = 0, .flags = O_WRONLY | O_APPEND, + .mode = 0, .file_pointer = 0, - .is_in_use = 1, - .dirty = 0, - .buf = NULL, - .buftotal = 0, - .bufsize = 0, - .buf_off = 0, - .bufptr = NULL + .token = 0, + .dpath = NULL, + .is_in_use = PVFS_FS }; +static int my_glibc_stat(const char *path, struct stat *buf) +{ + return glibc_redirect.stat(3, path, buf); +} + +static int my_glibc_stat64(const char *path, struct stat64 *buf) +{ + return glibc_redirect.stat64(3, path, buf); +} + +static int my_glibc_fstat(int fd, struct stat *buf) +{ + return glibc_redirect.fstat(3, fd, buf); +} + +static int my_glibc_fstat64(int fd, struct stat64 *buf) +{ + return glibc_redirect.fstat64(3, fd, buf); +} + +static int my_glibc_fstatat(int fd, const char *path, struct stat *buf, int flag) +{ + return glibc_redirect.fstatat(3, fd, path, buf, flag); +} + +static int my_glibc_fstatat64(int fd, const char *path, struct stat64 *buf, int flag) +{ + return glibc_redirect.fstatat64(3, fd, path, buf, flag); +} + +static int my_glibc_lstat(const char *path, struct stat *buf) +{ + return glibc_redirect.lstat(3, path, buf); +} + +static int my_glibc_lstat64(const char *path, struct stat64 *buf) +{ + return glibc_redirect.lstat64(3, path, buf); +} + +static int my_glibc_mknod(const char *path, mode_t mode, dev_t dev) +{ + return glibc_redirect.mknod(1, path, mode, dev); +} + +static int my_glibc_mknodat(int dirfd, const char *path, mode_t mode, dev_t dev) +{ + return glibc_redirect.mknodat(1, dirfd, path, mode, dev); +} + +static int my_glibc_getdents(u_int fd, struct dirent *dirp, u_int count) +{ + return syscall(SYS_getdents, fd, dirp, count); +} + +static int my_glibc_getdents64(u_int fd, struct dirent64 *dirp, u_int count) +{ + return syscall(SYS_getdents64, fd, dirp, count); +} + +static int my_glibc_fadvise64(int fd, off64_t offset, off64_t len, int advice) +{ + return syscall(SYS_fadvise64, fd, offset, len, advice); +} + +static int my_glibc_fadvise(int fd, off_t offset, off_t len, int advice) +{ + return my_glibc_fadvise64(fd, (off64_t)offset, (off64_t)len, advice); +} + +static int my_glibc_flush(int fd) +{ + errno = ENOSYS; + return -1; +} + +static int my_glibc_readdir(u_int fd, struct dirent *dirp, u_int count) +{ + return syscall(SYS_readdir, fd, dirp, count); +} + +void load_glibc(void) +{ + memset((void *)&glibc_ops, 0, sizeof(glibc_ops)); + glibc_ops.open = dlsym(RTLD_NEXT, "open"); + glibc_ops.open64 = dlsym(RTLD_NEXT, "open64"); + glibc_ops.openat = dlsym(RTLD_NEXT, "openat"); + glibc_ops.openat64 = dlsym(RTLD_NEXT, "openat64"); + glibc_ops.creat = dlsym(RTLD_NEXT, "creat"); + glibc_ops.creat64 = dlsym(RTLD_NEXT, "creat64"); + glibc_ops.unlink = dlsym(RTLD_NEXT, "unlink"); + glibc_ops.unlinkat = dlsym(RTLD_NEXT, "unlinkat"); + glibc_ops.rename = dlsym(RTLD_NEXT, "rename"); + glibc_ops.renameat = dlsym(RTLD_NEXT, "renameat"); + glibc_ops.read = dlsym(RTLD_NEXT, "read"); + glibc_ops.pread = dlsym(RTLD_NEXT, "pread"); + glibc_ops.readv = dlsym(RTLD_NEXT, "readv"); + glibc_ops.pread64 = dlsym(RTLD_NEXT, "pread64"); + glibc_ops.write = dlsym(RTLD_NEXT, "write"); + glibc_ops.pwrite = dlsym(RTLD_NEXT, "pwrite"); + glibc_ops.writev = dlsym(RTLD_NEXT, "writev"); + glibc_ops.pwrite64 = dlsym(RTLD_NEXT, "pwrite64"); + glibc_ops.lseek = dlsym(RTLD_NEXT, "lseek"); + glibc_ops.lseek64 = dlsym(RTLD_NEXT, "lseek64"); + glibc_ops.truncate = dlsym(RTLD_NEXT, "truncate"); + glibc_ops.truncate64 = dlsym(RTLD_NEXT, "truncate64"); + glibc_ops.ftruncate = dlsym(RTLD_NEXT, "ftruncate"); + glibc_ops.ftruncate64 = dlsym(RTLD_NEXT, "ftruncate64"); + glibc_ops.fallocate = dlsym(RTLD_NEXT, "posix_fallocate"); + glibc_ops.close = dlsym(RTLD_NEXT, "close"); + glibc_ops.flush = my_glibc_flush; + glibc_ops.stat = my_glibc_stat; + glibc_redirect.stat = dlsym(RTLD_NEXT, "__xstat"); + glibc_ops.stat64 = my_glibc_stat64; + glibc_redirect.stat64 = dlsym(RTLD_NEXT, "__xstat64"); + glibc_ops.fstat = my_glibc_fstat; + glibc_redirect.fstat = dlsym(RTLD_NEXT, "__fxstat"); + glibc_ops.fstat64 = my_glibc_fstat64; + glibc_redirect.fstat64 = dlsym(RTLD_NEXT, "__fxstat64"); + glibc_ops.fstatat = my_glibc_fstatat; + glibc_redirect.fstatat = dlsym(RTLD_NEXT, "__fxstatat"); + glibc_ops.fstatat64 = my_glibc_fstatat64; + glibc_redirect.fstatat64 = dlsym(RTLD_NEXT, "__fxstatat64"); + glibc_ops.lstat = my_glibc_lstat; + glibc_redirect.lstat = dlsym(RTLD_NEXT, "__lxstat"); + glibc_ops.lstat64 = my_glibc_lstat64; + glibc_redirect.lstat64 = dlsym(RTLD_NEXT, "__lxstat64"); + glibc_ops.dup = dlsym(RTLD_NEXT, "dup"); + glibc_ops.dup2 = dlsym(RTLD_NEXT, "dup2"); + glibc_ops.chown = dlsym(RTLD_NEXT, "chown"); + glibc_ops.fchown = dlsym(RTLD_NEXT, "fchown"); + glibc_ops.fchownat = dlsym(RTLD_NEXT, "fchownat"); + glibc_ops.lchown = dlsym(RTLD_NEXT, "lchown"); + glibc_ops.chmod = dlsym(RTLD_NEXT, "chmod"); + glibc_ops.fchmod = dlsym(RTLD_NEXT, "fchmod"); + glibc_ops.fchmodat = dlsym(RTLD_NEXT, "fchmodat"); + glibc_ops.mkdir = dlsym(RTLD_NEXT, "mkdir"); + glibc_ops.mkdirat = dlsym(RTLD_NEXT, "mkdirat"); + glibc_ops.rmdir = dlsym(RTLD_NEXT, "rmdir"); + glibc_ops.readlink = dlsym(RTLD_NEXT, "readlink"); + glibc_ops.readlinkat = dlsym(RTLD_NEXT, "readlinkat"); + glibc_ops.symlink = dlsym(RTLD_NEXT, "symlink"); + glibc_ops.symlinkat = dlsym(RTLD_NEXT, "symlinkat"); + glibc_ops.link = dlsym(RTLD_NEXT, "link"); + glibc_ops.linkat = dlsym(RTLD_NEXT, "linkat"); + glibc_ops.readdir = my_glibc_readdir; + glibc_ops.getdents = my_glibc_getdents; + glibc_ops.getdents64 = my_glibc_getdents64; + glibc_ops.access = dlsym(RTLD_NEXT, "access"); + glibc_ops.faccessat = dlsym(RTLD_NEXT, "faccessat"); + glibc_ops.flock = dlsym(RTLD_NEXT, "flock"); + glibc_ops.fcntl = dlsym(RTLD_NEXT, "fcntl"); + glibc_ops.sync = dlsym(RTLD_NEXT, "sync"); + glibc_ops.fsync = dlsym(RTLD_NEXT, "fsync"); + glibc_ops.fdatasync = dlsym(RTLD_NEXT, "fdatasync"); + glibc_ops.fadvise = my_glibc_fadvise; + glibc_ops.fadvise64 = my_glibc_fadvise64; + glibc_ops.statfs = dlsym(RTLD_NEXT, "statfs"); + glibc_ops.statfs64 = dlsym(RTLD_NEXT, "statfs64"); + glibc_ops.fstatfs = dlsym(RTLD_NEXT, "fstatfs"); + glibc_ops.fstatfs64 = dlsym(RTLD_NEXT, "fstatfs64"); + glibc_ops.mknod = my_glibc_mknod; + glibc_redirect.mknod = dlsym(RTLD_NEXT, "__xmknod"); + glibc_ops.mknodat = my_glibc_mknodat; + glibc_redirect.mknodat = dlsym(RTLD_NEXT, "__xmknodat"); + glibc_ops.sendfile = dlsym(RTLD_NEXT, "sendfile"); + glibc_ops.sendfile64 = dlsym(RTLD_NEXT, "sendfile64"); +#ifdef HAVE_ATTR_XATTR_H + glibc_ops.setxattr = dlsym(RTLD_NEXT, "setxattr"); + glibc_ops.lsetxattr = dlsym(RTLD_NEXT, "lsetxattr"); + glibc_ops.fsetxattr = dlsym(RTLD_NEXT, "fsetxattr"); + glibc_ops.getxattr = dlsym(RTLD_NEXT, "getxattr"); + glibc_ops.lgetxattr = dlsym(RTLD_NEXT, "lgetxattr"); + glibc_ops.fgetxattr = dlsym(RTLD_NEXT, "fgetxattr"); + glibc_ops.listxattr = dlsym(RTLD_NEXT, "listxattr"); + glibc_ops.llistxattr = dlsym(RTLD_NEXT, "llistxattr"); + glibc_ops.flistxattr = dlsym(RTLD_NEXT, "flistxattr"); + glibc_ops.removexattr = dlsym(RTLD_NEXT, "removexattr"); + glibc_ops.lremovexattr = dlsym(RTLD_NEXT, "lremovexattr"); + glibc_ops.fremovexattr = dlsym(RTLD_NEXT, "fremovexattr"); +#endif + glibc_ops.socket = dlsym(RTLD_NEXT, "socket"); + glibc_ops.accept = dlsym(RTLD_NEXT, "accept"); + glibc_ops.bind = dlsym(RTLD_NEXT, "bind"); + glibc_ops.connect = dlsym(RTLD_NEXT, "connect"); + glibc_ops.getpeername = dlsym(RTLD_NEXT, "getpeername"); + glibc_ops.getsockname = dlsym(RTLD_NEXT, "getsockname"); + glibc_ops.getsockopt = dlsym(RTLD_NEXT, "getsockopt"); + glibc_ops.setsockopt = dlsym(RTLD_NEXT, "setsockopt"); + glibc_ops.ioctl = dlsym(RTLD_NEXT, "ioctl"); + glibc_ops.listen = dlsym(RTLD_NEXT, "listen"); + glibc_ops.recv = dlsym(RTLD_NEXT, "recv"); + glibc_ops.recvfrom = dlsym(RTLD_NEXT, "recvfrom"); + glibc_ops.recvmsg = dlsym(RTLD_NEXT, "recvmsg"); + //glibc_ops.select = dlsym(RTLD_NEXT, "select"); + //glibc_ops.FD_CLR = dlsym(RTLD_NEXT, "FD_CLR"); + //glibc_ops.FD_ISSET = dlsym(RTLD_NEXT, "FD_ISSET"); + //glibc_ops.FD_SET = dlsym(RTLD_NEXT, "FD_SET"); + //glibc_ops.FD_ZERO = dlsym(RTLD_NEXT, "FD_ZERO"); + //glibc_ops.pselect = dlsym(RTLD_NEXT, "pselect"); + glibc_ops.send = dlsym(RTLD_NEXT, "send"); + glibc_ops.sendto = dlsym(RTLD_NEXT, "sendto"); + glibc_ops.sendmsg = dlsym(RTLD_NEXT, "sendmsg"); + glibc_ops.shutdown = dlsym(RTLD_NEXT, "shutdown"); + glibc_ops.socketpair = dlsym(RTLD_NEXT, "socketpair"); + glibc_ops.pipe = dlsym(RTLD_NEXT, "pipe"); + glibc_ops.umask = dlsym(RTLD_NEXT, "umask"); + glibc_ops.getumask = dlsym(RTLD_NEXT, "getumask"); + glibc_ops.getdtablesize = dlsym(RTLD_NEXT, "getdtablesize"); + +/* PVFS does not implement socket ops */ + pvfs_ops.socket = dlsym(RTLD_NEXT, "socket"); + pvfs_ops.accept = dlsym(RTLD_NEXT, "accept"); + pvfs_ops.bind = dlsym(RTLD_NEXT, "bind"); + pvfs_ops.connect = dlsym(RTLD_NEXT, "connect"); + pvfs_ops.getpeername = dlsym(RTLD_NEXT, "getpeername"); + pvfs_ops.getsockname = dlsym(RTLD_NEXT, "getsockname"); + pvfs_ops.getsockopt = dlsym(RTLD_NEXT, "getsockopt"); + pvfs_ops.setsockopt = dlsym(RTLD_NEXT, "setsockopt"); + pvfs_ops.ioctl = dlsym(RTLD_NEXT, "ioctl"); + pvfs_ops.listen = dlsym(RTLD_NEXT, "listen"); + pvfs_ops.recv = dlsym(RTLD_NEXT, "recv"); + pvfs_ops.recvfrom = dlsym(RTLD_NEXT, "recvfrom"); + pvfs_ops.recvmsg = dlsym(RTLD_NEXT, "recvmsg"); + //pvfs_ops.select = dlsym(RTLD_NEXT, "select"); + //pvfs_ops.FD_CLR = dlsym(RTLD_NEXT, "FD_CLR"); + //pvfs_ops.FD_ISSET = dlsym(RTLD_NEXT, "FD_ISSET"); + //pvfs_ops.FD_SET = dlsym(RTLD_NEXT, "FD_SET"); + //pvfs_ops.FD_ZERO = dlsym(RTLD_NEXT, "FD_ZERO"); + //pvfs_ops.pselect = dlsym(RTLD_NEXT, "pselect"); + pvfs_ops.send = dlsym(RTLD_NEXT, "send"); + pvfs_ops.sendto = dlsym(RTLD_NEXT, "sendto"); + pvfs_ops.sendmsg = dlsym(RTLD_NEXT, "sendmsg"); + pvfs_ops.shutdown = dlsym(RTLD_NEXT, "shutdown"); + pvfs_ops.socketpair = dlsym(RTLD_NEXT, "socketpair"); + pvfs_ops.pipe = dlsym(RTLD_NEXT, "pipe"); +} + +static void usrint_cleanup(void) +{ + /* later check for an error that might want us */ + /* to keep this - for now it is empty */ + glibc_ops.unlink(logfilepath); +} /* * Perform PVFS initialization tasks */ -int pvfs_sys_init() { +void pvfs_sys_init(void) { struct rlimit rl; int rc; + static int pvfs_lib_init_flag = 0; - /* initalize the file system */ - PVFS_util_init_defaults(); + if (pvfs_lib_init_flag) + { + return; + } + pvfs_lib_init_flag = 1; /* should only run this once */ + pvfs_initializing_flag = 1; + + /* this allows system calls to run */ + load_glibc(); + PINT_initrand(); + + /* if this fails no much we can do about it */ + atexit(usrint_cleanup); rc = getrlimit(RLIMIT_NOFILE, &rl); /* need to check for "INFINITY" */ + /* set up descriptor table */ descriptor_table_size = rl.rlim_max; descriptor_table = (pvfs_descriptor **)malloc(sizeof(pvfs_descriptor *) * @@ -86,11 +371,33 @@ int pvfs_sys_init() { descriptor_table[0] = &pvfs_stdin; descriptor_table[1] = &pvfs_stdout; descriptor_table[2] = &pvfs_stderr; - next_descriptor = PREALLOC; + descriptor_table_count = PREALLOC; - /* Mark the initialization complete */ - pvfs_is_sys_initialized = 1; - return PVFS_FD_SUCCESS; + sprintf(logfilepath, "/tmp/pvfsuid-%05d.log", (int)(getuid())); + logfile = glibc_ops.open(logfilepath, O_RDWR|O_CREAT, 0600); + if (logfile < 0) + { + perror("failed in pvfs_sys_init"); + exit(-1); + } + + /* initalize PVFS */ + PVFS_util_init_defaults(); + if (errno == EINPROGRESS) + { + errno = 0; + } + + /* call other initialization routines */ + + /* Initialize User Cache */ + if(ucache && ucache_locks) + { + ucache_initialize(); + } + + //PVFS_perror_gossip_silent(); + pvfs_initializing_flag = 0; } int pvfs_descriptor_table_size(void) @@ -98,78 +405,128 @@ int pvfs_descriptor_table_size(void) return descriptor_table_size; } - /* * Allocate a new pvfs_descriptor * initialize fsops to the given set */ - pvfs_descriptor *pvfs_alloc_descriptor(posix_ops *fsops) + pvfs_descriptor *pvfs_alloc_descriptor(posix_ops *fsops, int fd, + PVFS_object_ref *file_ref + ) { - int i; - if (descriptor_table_count == (descriptor_table_size - PREALLOC)) - { - // print error - return NULL; - } - - /* find next empty slot in table */ - for (i = next_descriptor; descriptor_table[i]; - i = (i == descriptor_table_size-1) ? PREALLOC : i++); - - /* found a slot */ - descriptor_table[i] = malloc(sizeof(pvfs_descriptor)); - if (descriptor_table[i] == NULL) - { - // print error - return NULL; - } - next_descriptor = ((i == descriptor_table_size-1) ? PREALLOC : i++); + int newfd, flags = 0; + if (fsops == NULL) + { + errno = EINVAL; + return NULL; + } + pvfs_sys_init(); + + if (fd == -1) + { + /* PVFS file allocate a real descriptor for it */ + newfd = glibc_ops.dup(logfile); + } + else + { + /* opened by glibc, make sure this is a valid fd */ + newfd = fd; + flags = glibc_ops.fcntl(newfd, F_GETFL); + if (flags < 0) + { + return NULL; + } + } descriptor_table_count++; + descriptor_table[newfd] = + (pvfs_descriptor *)malloc(sizeof(pvfs_descriptor)); + if (!descriptor_table[newfd]) + { + return NULL; + } /* fill in descriptor */ - descriptor_table[i]->fd = i; - descriptor_table[i]->dup_cnt = 1; - descriptor_table[i]->fsops = fsops; - descriptor_table[i]->posix_fd = i; - descriptor_table[i]->pvfs_ref.fs_id = 0; - descriptor_table[i]->pvfs_ref.handle = 0; - descriptor_table[i]->flags = 0; - descriptor_table[i]->file_pointer = 0; - descriptor_table[i]->is_in_use = 0; - descriptor_table[i]->dirty = 0; - descriptor_table[i]->eof = 0; - descriptor_table[i]->error = 0; - descriptor_table[i]->buf = NULL; - descriptor_table[i]->buftotal = 0; - descriptor_table[i]->bufsize = 0; - descriptor_table[i]->buf_off = 0; - descriptor_table[i]->bufptr = NULL; - - return descriptor_table[i]; + /* add reference to chache objects here */ + descriptor_table[newfd]->fd = newfd; + descriptor_table[newfd]->dup_cnt = 1; + descriptor_table[newfd]->fsops = fsops; + descriptor_table[newfd]->true_fd = newfd; + descriptor_table[newfd]->pvfs_ref.fs_id = file_ref->fs_id; + descriptor_table[newfd]->pvfs_ref.handle = file_ref->handle; + descriptor_table[newfd]->flags = flags; + descriptor_table[newfd]->mode = 0; + descriptor_table[newfd]->file_pointer = 0; + descriptor_table[newfd]->token = 0; + descriptor_table[newfd]->dpath = NULL; + descriptor_table[newfd]->is_in_use = PVFS_FS; + descriptor_table[newfd]->mtbl = NULL; + +#if 0 + /* File reference won't always be passed in */ + if(file_ref != NULL) + { + /* We have the file identifiers, so insert file info into ucache */ + rc = ucache_open_file(&(file_ref->fs_id), &(file_ref->handle), + descriptor_table[newfd]->mtbl); + /* Unique Entry */ + if(rc > 0) + { + descriptor_table[newfd]->mtbl->ref_cnt = 1; + } + /* File already in Cache */ + else if(rc == 0){ + descriptor_table[newfd]->mtbl->ref_cnt++; + } + /* Could not insert */ + else + { + /* TODO: probably need modify this */ + } + } +#endif + + return descriptor_table[newfd]; } /* - * Function for dupliating a descriptor - used in dup and dup2 calls + * Function for duplicating a descriptor - used in dup and dup2 calls */ int pvfs_dup_descriptor(int oldfd, int newfd) { + int rc = 0; + if (oldfd < 0 || oldfd >= descriptor_table_size) + { + errno = EBADF; + return -1; + } if (newfd == -1) { - /* find next empty slot in table */ - for (newfd = next_descriptor; descriptor_table[newfd]; - newfd = (newfd == descriptor_table_size-1) ? PREALLOC : newfd++); + newfd = glibc_ops.dup(logfile); + if (newfd < 0) + { + return newfd; + } } else { if (descriptor_table[newfd] != NULL) { /* close old file in new slot */ - pvfs_close(newfd); + rc = pvfs_free_descriptor(newfd); + if (rc < 0) + { + return rc; + } } } + rc = glibc_ops.dup2(oldfd, newfd); + if (rc < 0) + { + return rc; + } descriptor_table[newfd] = descriptor_table[oldfd]; descriptor_table[newfd]->dup_cnt++; descriptor_table_count++; + return 0; } /* @@ -179,34 +536,91 @@ int pvfs_dup_descriptor(int oldfd, int newfd) */ pvfs_descriptor *pvfs_find_descriptor(int fd) { - return descriptor_table[fd]; + pvfs_descriptor *pd; + if (fd < 0 || fd >= descriptor_table_size) + { + errno = EBADF; + return NULL; + } + pd = descriptor_table[fd]; + if (!pd) + { + int flags; + /* see if glibc opened this file without our knowing */ + flags = glibc_ops.fcntl(fd, F_GETFL); + if (flags < 0) + { + errno = EBADF; + return NULL; + } + pd = (pvfs_descriptor *)malloc(sizeof(pvfs_descriptor)); + /* fill in descriptor */ + pd->fd = fd; + pd->dup_cnt = 1; + pd->fsops = &glibc_ops; + pd->true_fd = fd; + pd->pvfs_ref.fs_id = 0; + pd->pvfs_ref.handle = 0; + pd->flags = flags; + pd->mode = 0; + pd->file_pointer = 0; + pd->token = 0; + pd->dpath = NULL; + pd->is_in_use = PVFS_FS; + descriptor_table[fd] = pd; + } + else if (pd->is_in_use != PVFS_FS) + { + errno = EBADF; + return NULL; + } + return pd; } int pvfs_free_descriptor(int fd) { pvfs_descriptor *pd; + debug("pvfs_free_descriptor called with %d\n", fd); - pd = descriptor_table[fd]; + pd = pvfs_find_descriptor(fd); + if (pd == NULL) + { + return -1; + } /* clear out table entry */ descriptor_table[fd] = NULL; + glibc_ops.close(fd); /* keep up with used descriptors */ - descriptor_table_count++; + descriptor_table_count--; /* check if last copy */ if (--(pd->dup_cnt) <= 0) { - /* free buffer space */ - if (pd->buf) + if (pd->dpath) + { + free(pd->dpath); + } + +#if 0 + /* release cache objects here */ + pd->mtbl->ref_cnt--; + if(pd->mtbl->ref_cnt == 0) { - free(pd->buf); + /* Flush dirty blocks before file removal from cache */ + ucache_flush(&(pd->pvfs_ref.fs_id), &(pd->pvfs_ref.handle)); + /* remove all of this file's associated data from cache */ + ucache_close_file(&(pd->pvfs_ref.fs_id), &(pd->pvfs_ref.handle)); } +#endif + /* free descriptor - wipe memory first */ memset(pd, 0, sizeof(pvfs_descriptor)); free(pd); } + debug("pvfs_free_descriptor returns %d\n", 0); return 0; } @@ -214,161 +628,243 @@ int pvfs_free_descriptor(int fd) * takes a path that is relative to the working dir and * expands it all the way to the root */ -char * pvfs_qualify_path(const char *path) +char *pvfs_qualify_path(const char *path) { - char *rc = NULL; - int i = 1; int cdsz; int psz; - char *curdir; - char *newpath; + char *curdir = NULL; + char *newpath = NULL; if(path[0] != '/') { - /* loop until our temp buffer is big enough for the */ - /* current directory */ - do - { - if (i > 1) - free(curdir); - curdir = (char *)malloc(i * 256); - if (curdir == NULL) - return NULL; - rc = getcwd(curdir, i * 256); - i++; - } while ((rc == NULL) && (errno == ERANGE)); - if (rc == NULL) + curdir = get_current_dir_name(); + if (curdir == NULL) { - /* some other error, bail out */ - free(curdir); + /* error, bail out */ return NULL; } cdsz = strlen(curdir); psz = strlen(path); /* allocate buffer for whole path and copy */ - newpath = (char *)malloc(cdsz+psz+2); + newpath = (char *)malloc(cdsz + psz + 2); strncpy(newpath, curdir, cdsz); free(curdir); strncat(newpath, "/", 1); strncat(newpath, path, psz); } else + { newpath = (char *)path; + } return newpath; } -/* - *Determines if a path is part of a PVFS Filesystem +/** + * Determines if a path is part of a PVFS Filesystem + * + * returns 1 if PVFS 0 otherwise */ -int is_pvfs_path(const char *path) { - struct statfs file_system; - char * directory = NULL ; - char *str; - - if(path[0] != '/') { - directory = getcwd(NULL, 0); - str = malloc((strlen(directory)+1)*sizeof(char)); - strcpy(str, directory); - free(directory); - } - else { - str = malloc((strlen(path)+1) *sizeof(char)); - strcpy(str, path); - } - if(str == NULL) { - pvfs_debug("Malloc has failed\n"); - } - - int count; - for(count = strlen(str) -2; count > 0; count--) { - if(str[count] == '/') { - str[count] = '\0'; - break; - } - } - /* this must call standard glibc statfs */ - glibc_ops.statfs(str, &file_system); - free(str); - if(file_system.f_type == PVFS_FS) { -#ifdef DEBUG - printf("IS PVFS_PATH\n"); -#endif - return true; - } - else if(file_system.f_type == LINUX_FS) { -#ifdef DEBUG - printf("IS NOT PVFS_PATH\n"); +int is_pvfs_path(const char *path) +{ +#ifdef PVFS_ASSUME_MOUNT + struct statfs file_system; #endif - return false; - } - else { - printf("NO A LINUX OR PVFS FILE SYSTEM!! (BAILING OUT!!!)\n"); - exit(1); - } -} + int rc = 0; + PVFS_fs_id fs_id; + char pvfs_path[256]; + char *newpath = NULL ; -void pvfs_debug(char *fmt, ...) -{ - va_list ap; + if (pvfs_initializing_flag) + { + /* we cannot open a PVFS file while + * initializing PVFS + */ + return 0; + } - va_start(ap, fmt); - vfprintf(stderr, fmt, ap); - va_end(ap); + pvfs_sys_init(); +#ifdef PVFS_ASSUME_MOUNT + memset(&file_system, 0, sizeof(file_system)); + + newpath = pvfs_qualify_path(path); + /* lop off the last segment of the path */ + int count; + for(count = strlen(newpath) -2; count > 0; count--) + { + if(newpath[count] == '/') + { + newpath[count] = '\0'; + break; + } + } + /* this must call standard glibc statfs */ + glibc_ops.statfs(newpath, &file_system); + if (newpath != path) + { + free(newpath); + } + if(file_system.f_type == PVFS_FS) + { + return 1; /* PVFS */ + } + else + { + return 0; /* not PVFS assume the kernel can handle it */ + } +/***************************************************************/ +#else +/***************************************************************/ + newpath = pvfs_qualify_path(path); + rc = PVFS_util_resolve(newpath, &fs_id, pvfs_path, 256); + if (newpath != path) + { + free(newpath); + } + if (rc < 0) + { + if (rc == -PVFS_ENOENT) + { + return 0; /* not a PVFS path */ + } + errno = rc; + return 0; /* an error returned - let glibc deal with it */ + // return -1; /* an error returned */ + } + return 1; /* a PVFS path */ +#endif } /** - * Split a pathname into a directory and a filename. If non-null - * is passed as the directory or filename, the field will be allocated and - * filled with the correct value + * Split a pathname into a directory and a filename. + * If non-null is passed as the directory or filename, + * the field will be allocated and filled with the correct value + * + * A slash at the end of the path is interpreted as no filename + * and is an error. To parse the last dir in a path, remove this + * trailing slash. No filename with no directory is OK. */ int split_pathname( const char *path, + int dirflag, char **directory, char **filename) { - /* chop off pvfs2 prefix */ - if (strncmp(path,"pvfs2:",strlen("pvfs2:")) == 0) - path = &path[strlen("pvfs2:")]; + int i, fnlen, slashes = 0; + int length = strlen("pvfs2"); + if (!path || !directory || !filename) + { + errno = EINVAL; + return -1; + } + /* chop off pvfs2 prefix */ + if (strncmp(path, "pvfs2:", length) == 0) + { + path = &path[length]; + } /* Split path into a directory and filename */ - int path_length = strlen(path); - if ('/' == path[0]) + length = strnlen(path, PVFS_PATH_MAX); + if (length == PVFS_PATH_MAX) + { + errno = ENAMETOOLONG; + return -1; + } + i = length - 1; + if (dirflag) { - int i; - for (i = path_length - 1; i >= 0; --i) + /* skip any trailing slashes */ + for(; i >= 0 && path[i] == '/'; i--) { - if ( '/' == path[i] ) + slashes++; + } + } + for (; i >= 0; i--) + { + if (path[i] == '/') + { + /* parse the directory */ + *directory = malloc(i + 1); + if (!*directory) { - /* parse the directory */ - if (0 != directory) - { - *directory = malloc(i + 1); - if (0 != directory) - { - strncpy(*directory, path, i); - (*directory)[i] = '\0'; - } - } - /* parse the filename */ - if (0 != filename) - { - *filename = malloc(path_length - i + 1); - if (0 != filename) - { - strncpy(*filename, path + i + 1, path_length - i); - (*filename)[path_length - i] = '\0'; - } - } - break; + return -1; } + strncpy(*directory, path, i); + (*directory)[i] = '\0'; + break; } } - else + if (i == -1) + { + /* found no '/' path is all filename */ + *directory = NULL; + } + i++; + /* copy the filename */ + fnlen = length - i - slashes; + if (fnlen == 0) { - fprintf(stderr, "Error: Not an absolute path: %s\n", path); - return PVFS_FD_FAILURE; + filename = NULL; + if (!directory) + { + errno = EISDIR; + } + else + { + errno = ENOENT; + } + return -1; } - return PVFS_FD_SUCCESS; + /* check flag to see if there are slashes to skip */ + *filename = malloc(fnlen + 1); + if (!*filename) + { + if (*directory) + { + free(*directory); + } + *directory = NULL; + *filename = NULL; + return -1; + } + strncpy(*filename, path + i, length - i); + (*filename)[length - i] = '\0'; + return 0; +} + +void PINT_initrand(void) +{ + static int init_called = 0; + pid_t pid; + uid_t uid; + gid_t gid; + struct timeval time; + char *oldstate; + unsigned int seed; + + if (init_called) + { + return; + } + init_called = 1; + pid = getpid(); + uid = getuid(); + gid = getgid(); + gettimeofday(&time, NULL); + seed = (((pid << 16) ^ uid) ^ (gid << 8)) ^ time.tv_usec; + oldstate = initstate(seed, rstate, 256); + setstate(oldstate); +} + +long int PINT_random(void) +{ + char *oldstate; + long int rndval; + + PINT_initrand(); + oldstate = setstate(rstate); + rndval = random(); + setstate(oldstate); + return rndval; } /* diff --git a/src/client/usrint/openfile-util.h b/src/client/usrint/openfile-util.h index afe3157..75d55e2 100644 --- a/src/client/usrint/openfile-util.h +++ b/src/client/usrint/openfile-util.h @@ -1,3 +1,16 @@ +/* + * (C) 2011 Clemson University and The University of Chicago + * + * See COPYING in top-level directory. + */ + +#include "posix-ops.h" + +/** \file + * \ingroup usrint + * + * PVFS2 user interface routines + */ #ifndef OPENFILE_UTIL_H #define OPENFILE_UTIL_H 1 @@ -5,9 +18,12 @@ #define PVFS_FD_SUCCESS 0 #define PVFS_FD_FAILURE -1 -int split_pathname( const char *path, char **directory, char **filename); +int split_pathname(const char *path, + int dirflag, + char **directory, + char **filename); -int pvfs_sys_init(); +void pvfs_sys_init(void); char *pvfs_qualify_path(const char *path); @@ -17,10 +33,6 @@ void pvfs_debug(char *fmt, ...); void load_glibc(void); -int pvfs_split_pathname(const char *path, - char **directory, - char **filename); - int pvfs_lookup_dir(const char *directory, PVFS_object_ref *ref, int *fs_id); @@ -31,13 +43,24 @@ int pvfs_lookup_file(const char *filename, int follow_links, PVFS_object_ref *ref); -pvfs_descriptor* pvfs_alloc_descriptor(posix_ops *fsops); +pvfs_descriptor *pvfs_alloc_descriptor(posix_ops *fsops, + int fd, + PVFS_object_ref *file_ref); + +pvfs_descriptor *pvfs_find_descriptor(int fd); -pvfs_descriptor* pvfs_find_descriptor(int fd); +int pvfs_dup_descriptor(int oldfd, int newfd); +int pvfs_free_descriptor(int fd); + +int pvfs_descriptor_table_size(void); int pvfs_create_file(const char *filename, mode_t mode, PVFS_object_ref parent_ref, PVFS_object_ref *ref); + +void PINT_initrand(void); + +long int PINT_random(void); #endif diff --git a/src/client/usrint/posix-pvfs.c b/src/client/usrint/posix-pvfs.c index d660cd4..39802bd 100644 --- a/src/client/usrint/posix-pvfs.c +++ b/src/client/usrint/posix-pvfs.c @@ -1,8 +1,43 @@ -#include +/* + * (C) 2011 Clemson University and The University of Chicago + * + * See COPYING in top-level directory. + */ + +/** \file + * \ingroup usrint + * + * PVFS2 user interface routines - pvfs version of posix system calls + */ +#define USRINT_SOURCE 1 +#include "usrint.h" +#include "posix-ops.h" +#include "posix-pvfs.h" +#include "openfile-util.h" +#include "iocommon.h" + +#define PVFS_ATTR_DEFAULT_MASK \ +(PVFS_ATTR_SYS_COMMON_ALL | PVFS_ATTR_SYS_SIZE | PVFS_ATTR_SYS_BLKSIZE) static mode_t mask_val = 0022; /* implements umask for pvfs library */ +static char pvfs_cwd[PVFS_PATH_MAX]; + +/* actual implementation of read and write are in these static funcs */ + +static ssize_t pvfs_prdwr64(int fd, + void *buf, + size_t count, + off64_t offset, + int which); -/* pvfs_open */ +static ssize_t pvfs_rdwrv(int fd, + const struct iovec *vector, + size_t count, + int which); + +/** + * pvfs_open + */ int pvfs_open(const char *path, int flags, ...) { va_list ap; @@ -10,7 +45,13 @@ int pvfs_open(const char *path, int flags, ...) PVFS_hint hints; char *newpath; pvfs_descriptor *pd; + debug("pvfs_open: called with %s\n", path); + if (!path) + { + errno = EINVAL; + return -1; + } va_start(ap, flags); if (flags & O_CREAT) mode = va_arg(ap, int); @@ -24,36 +65,64 @@ int pvfs_open(const char *path, int flags, ...) /* fully qualify pathname */ newpath = pvfs_qualify_path(path); + if (!newpath) + { + return -1; + } pd = iocommon_open(newpath, flags, hints, mode, NULL); if (newpath != path) { free(newpath); } - return pd->fd; + if (!pd) + { + return -1; + } + else + { + return pd->fd; + } } -/* pvfs_open64 */ +/** + * pvfs_open64 + */ int pvfs_open64(const char *path, int flags, ...) { va_list ap; int mode; PVFS_hint hints; + if (!path) + { + errno = EINVAL; + return -1; + } va_start(ap, flags); if (flags & O_CREAT) + { mode = va_arg(ap, int); + } else + { mode = 0777; + } if (flags & O_HINTS) + { hints = va_arg(ap, PVFS_hint); + } else + { hints = PVFS_HINT_NULL; + } va_end(ap); flags |= O_LARGEFILE; return pvfs_open(path, flags, mode); } -/* pvfs_openat */ +/** + * pvfs_openat + */ int pvfs_openat(int dirfd, const char *path, int flags, ...) { va_list ap; @@ -61,86 +130,183 @@ int pvfs_openat(int dirfd, const char *path, int flags, ...) PVFS_hint hints; pvfs_descriptor *dpd, *fpd; + if (!path) + { + errno = EINVAL; + return -1; + } va_start(ap, flags); if (flags & O_CREAT) + { mode = va_arg(ap, int); + } else + { mode = 0777; + } if (flags & O_HINTS) + { hints = va_arg(ap, PVFS_hint); + } else + { hints = PVFS_HINT_NULL; + } va_end(ap); - if (path[0] == '/') + if (path[0] == '/' || dirfd == AT_FDCWD) { return pvfs_open(path, flags, mode); } else { + if (dirfd < 0) + { + errno = EBADF; + return -1; + } dpd = pvfs_find_descriptor(dirfd); - fpd = iocommon_open(path, flags, hints, mode, &dpd->pvfs_ref); + if (!dpd) + { + return -1; + } + fpd = iocommon_open(path, flags, hints, mode, dpd); + if (!fpd) + { + return -1; + } return fpd->fd; } - } -/* pvfs_openat64 */ +/** + * pvfs_openat64 + */ int pvfs_openat64(int dirfd, const char *path, int flags, ...) { va_list ap; int mode; PVFS_hint hints; - pvfs_descriptor *pd; + if (dirfd < 0) + { + errno = EBADF; + return -1; + } va_start(ap, flags); if (flags & O_CREAT) + { mode = va_arg(ap, int); + } else + { mode = 0777; + } if (flags & O_HINTS) + { hints = va_arg(ap, PVFS_hint); + } else + { hints = PVFS_HINT_NULL; + } va_end(ap); flags |= O_LARGEFILE; return pvfs_openat(dirfd, path, flags, mode); } +/** + * pvfs_creat wrapper + */ int pvfs_creat(const char *path, mode_t mode, ...) { + return pvfs_open(path, O_RDWR | O_CREAT | O_EXCL, mode); } +/** + * pvfs_creat64 wrapper + */ int pvfs_creat64(const char *path, mode_t mode, ...) { + return pvfs_open64(path, O_RDWR | O_CREAT | O_EXCL, mode); } -/* pvfs_unlink */ -int pvfs_unlink (const char *path) +/** + * pvfs_unlink + */ +int pvfs_unlink(const char *path) { - return iocommon_unlink(path); + int rc = 0; + char *newpath; + + newpath = pvfs_qualify_path(path); + if (!newpath) + { + return -1; + } + rc = iocommon_unlink(path, NULL); + if (newpath != path) + { + free(newpath); + } + return rc; } -int pvfs_unlinkat (int dirfd, const char *path) +/** + * pvfs_unlinkat + */ +int pvfs_unlinkat(int dirfd, const char *path, int flags) { - pvfs_descriptor *pd, *pd2; + int rc; + pvfs_descriptor *pd; + if (path[0] == '/' || dirfd == AT_FDCWD) - pvfs_unlink(path); + { + rc = iocommon_unlink(path, NULL); + } else { - int flags = O_RDONLY; + if (dirfd < 0) + { + errno = EBADF; + return -1; + } pd = pvfs_find_descriptor(dirfd); - /* not sure what to do with this ... */ - return -1; + if (!pd) + { + errno = EBADF; + return -1; + } + if (flags & AT_REMOVEDIR) + { + rc = iocommon_rmdir(path, &pd->pvfs_ref); + } + else + { + rc = iocommon_unlink(path, &pd->pvfs_ref); + } } + return rc; } +/** + * pvfs_rename + */ int pvfs_rename(const char *oldpath, const char *newpath) { int rc; char *absoldpath, *absnewpath; absoldpath = pvfs_qualify_path(oldpath); + if (!absoldpath) + { + return -1; + } absnewpath = pvfs_qualify_path(newpath); + if (!absnewpath) + { + free(absoldpath); + return -1; + } rc = iocommon_rename(NULL, absoldpath, NULL, absnewpath); if (oldpath != absoldpath) { @@ -153,34 +319,73 @@ int pvfs_rename(const char *oldpath, const char *newpath) return rc; } +/** + * pvfs_renameat + */ int pvfs_renameat(int olddirfd, const char *oldpath, int newdirfd, const char *newpath) { int rc; - pvfs_descriptor *olddes, *newdes; + pvfs_descriptor *pd; + PVFS_object_ref *olddirref, *newdirref; char *absoldpath, *absnewpath; - if (oldpath[0] != '/') + if (!oldpath || !newpath) { - olddes = pvfs_find_descriptor(olddirfd); - absoldpath = (char *)oldpath; + errno = EINVAL; + return -1; } - else + if (oldpath[0] == '/' || olddirfd == AT_FDCWD) { - olddes = NULL; + olddirref = NULL; absoldpath = pvfs_qualify_path(oldpath); + if (!absoldpath) + { + return -1; + } + } + else + { + if (olddirfd < 0) + { + errno = EBADF; + return -1; + } + pd = pvfs_find_descriptor(olddirfd); + if (!pd) + { + errno = EBADF; + return -1; + } + olddirref = &pd->pvfs_ref; + absoldpath = (char *)oldpath; } - if (oldpath[0] != '/') + if (oldpath[0] == '/' || newdirfd == AT_FDCWD) { - newdes = pvfs_find_descriptor(newdirfd); - absnewpath = (char *)newpath; + newdirref = NULL; + absnewpath = pvfs_qualify_path(newpath); + if (!absnewpath) + { + return -1; + } } else { - newdes = NULL; - absnewpath = pvfs_qualify_path(newpath); + if (newdirfd < 0) + { + errno = EBADF; + return -1; + } + pd = pvfs_find_descriptor(newdirfd); + if (!pd) + { + errno = EBADF; + return -1; + } + newdirref = &pd->pvfs_ref; + absnewpath = (char *)newpath; } - rc = iocommon_rename(olddes, absoldpath, newdes, absnewpath); + rc = iocommon_rename(olddirref, absoldpath, newdirref, absnewpath); if (oldpath != absoldpath) { free(absoldpath); @@ -192,126 +397,213 @@ int pvfs_renameat(int olddirfd, const char *oldpath, return rc; } -/* pvfs_read */ -ssize_t pvfs_read( int fd, void *buf, size_t count ) +/** + * pvfs_read wrapper + */ +ssize_t pvfs_read(int fd, void *buf, size_t count) { int rc; + + if (fd < 0) + { + errno = EBADF; + return -1; + } pvfs_descriptor *pd = pvfs_find_descriptor(fd); - rc = pvfs_pread64(fd, buf, count, pd->file_pointer); - if (rc > 0) - pd->file_pointer += rc; + if (!pd) + { + return -1; + } + rc = pvfs_prdwr64(fd, buf, count, pd->file_pointer, PVFS_IO_READ); + if (rc < 0) + { + return -1; + } + pd->file_pointer += rc; return rc; } -/* pvfs_pread */ -ssize_t pvfs_pread( int fd, void *buf, size_t count, off_t offset ) +/** + * pvfs_pread wrapper + */ +ssize_t pvfs_pread(int fd, void *buf, size_t count, off_t offset) { - return pvfs_pread_64(fd, buf, count, (off64_t) offset); + return pvfs_prdwr64(fd, buf, count, (off64_t) offset, PVFS_IO_READ); } +/** + * pvfs_readv wrapper + */ ssize_t pvfs_readv(int fd, const struct iovec *vector, int count) { + return pvfs_rdwrv(fd, vector, count, PVFS_IO_READ); } -/* pvfs_pread64 */ +/** + * pvfs_pread64 wrapper + */ ssize_t pvfs_pread64( int fd, void *buf, size_t count, off64_t offset ) { - int rc; - pvfs_descriptor* pd; - PVFS_Request freq; + return pvfs_prdwr64(fd, buf, count, offset, PVFS_IO_READ); +} - memset(&freq, 0, sizeof(freq)); +/** + * pvfs_write wrapper + */ +ssize_t pvfs_write(int fd, const void *buf, size_t count) +{ + int rc; - /* Find the descriptor */ - pd = pvfs_find_descriptor(fd); - if (pd == NULL) { + if (fd < 0) + { errno = EBADF; - return PVFS_FD_FAILURE; + return -1; } - - /* Ensure descriptor is available for read access */ - if (O_WRONLY & pd->flags) { - errno = EBADF; - return PVFS_FD_FAILURE; + pvfs_descriptor *pd = pvfs_find_descriptor(fd); + if (!pd) + { + return -1; } - - rc = PVFS_Request_contiguous(count, PVFS_BYTE, &freq); - - iocommon_readorwrite(PVFS_IO_READ, pd, offset, buf, PVFS_BYTE, freq, count); - - PVFS_Request_free(&freq); - - return count; + rc = pvfs_prdwr64(fd, (void *)buf, count, pd->file_pointer, PVFS_IO_WRITE); + if (rc < 0) + { + return -1; + } + pd->file_pointer += rc; + return rc; } -/* pvfs_write */ -ssize_t pvfs_write( int fd, void *buf, size_t count ) +/** + * pvfs_pwrite wrapper + */ +ssize_t pvfs_pwrite(int fd, const void *buf, size_t count, off_t offset) { - int rc; - pvfs_descriptor *pd = pvfs_find_descriptor(fd); - rc = pvfs_pwrite64(fd, buf, count, pd->file_pointer); - if (rc > 0) - pd->file_pointer += rc; - return rc; + return pvfs_prdwr64(fd, (void *)buf, count, (off64_t)offset, PVFS_IO_WRITE); } -/* pvfs_pwrite */ -ssize_t pvfs_pwrite( int fd, void *buf, size_t count, off_t offset ) +/** + * pvfs_writev wrapper + */ +ssize_t pvfs_writev(int fd, const struct iovec *vector, int count) { - return pvfs_pwrite64(fd, buf, count, (off64_t) offset); + return pvfs_rdwrv(fd, vector, count, PVFS_IO_WRITE); } -ssize_t pvfs_writev( int fd, const struct iovec *vector, int count ) +/** + * pvfs_pwrite64 wrapper + */ +ssize_t pvfs_pwrite64(int fd, const void *buf, size_t count, off64_t offset) { + return pvfs_prdwr64(fd, (void *)buf, count, offset, PVFS_IO_WRITE); } -/* pvfs_pwrite64 */ -ssize_t pvfs_write64( int fd, void *buf, size_t count, off64_t offset ) +/** + * implements pread and pwrite with 64-bit file pointers + */ +static ssize_t pvfs_prdwr64(int fd, + void *buf, + size_t count, + off64_t offset, + int which) { int rc; pvfs_descriptor* pd; - PVFS_Request freq; + PVFS_Request freq, mreq; memset(&freq, 0, sizeof(freq)); + memset(&mreq, 0, sizeof(mreq)); /* Find the descriptor */ pd = pvfs_find_descriptor(fd); - if (pd == NULL) { + if (!pd) + { errno = EBADF; - return PVFS_FD_FAILURE; + return -1; } - /* Ensure descriptor is available for read access */ - if (O_RDONLY & pd->flags) { - errno = EBADF; - return PVFS_FD_FAILURE; + rc = PVFS_Request_contiguous(count, PVFS_BYTE, &freq); + rc = PVFS_Request_contiguous(count, PVFS_BYTE, &mreq); + + /* place contiguous buff and count into an iovec array of length 1 */ + struct iovec vector[1]; + vector[0].iov_base = buf; + vector[0].iov_len = count; + + rc = iocommon_readorwrite(which, pd, offset, buf, mreq, freq, count, &vector[0]); + + PVFS_Request_free(&freq); + PVFS_Request_free(&mreq); + + return rc; +} + +/** + * implements readv and writev + */ +static ssize_t pvfs_rdwrv(int fd, + const struct iovec *vector, + size_t count, + int which) +{ + int rc; + pvfs_descriptor* pd; + PVFS_Request freq, mreq; + off64_t offset; + void *buf; + + memset(&freq, 0, sizeof(freq)); + memset(&mreq, 0, sizeof(mreq)); + + /* Find the descriptor */ + pd = pvfs_find_descriptor(fd); + if(!pd) + { + return -1; } + offset = pd->file_pointer; rc = PVFS_Request_contiguous(count, PVFS_BYTE, &freq); + rc = pvfs_convert_iovec(vector, count, &mreq, &buf); - iocommon_readorwrite(PVFS_IO_WRITE, pd, offset, buf, PVFS_BYTE, freq, count); + rc = iocommon_readorwrite(which, pd, offset, buf, mreq, freq, count, vector); + + if (rc >= 0) + { + pd->file_pointer += rc; + } PVFS_Request_free(&freq); + PVFS_Request_free(&mreq); - return count; + return rc; } -/* pvfs_lseek */ +/** + * pvfs_lseek wrapper + */ off_t pvfs_lseek(int fd, off_t offset, int whence) { return (off_t) pvfs_lseek64(fd, (off64_t)offset, whence); } -/* pvfs_lseek64 */ +/** + * pvfs_lseek64 + */ off64_t pvfs_lseek64(int fd, off64_t offset, int whence) { pvfs_descriptor* pd; + if (fd < 0) + { + errno = EBADF; + return -1; + } /* Find the descriptor */ pd = pvfs_find_descriptor(fd); - if (pd == 0) { + if (!pd) + { errno = EBADF; - return PVFS_FD_FAILURE; + return -1; } iocommon_lseek(pd, offset, 1, whence); @@ -319,342 +611,692 @@ off64_t pvfs_lseek64(int fd, off64_t offset, int whence) return pd->file_pointer; } +/** + * pvfs_truncate wrapper + */ int pvfs_truncate(const char *path, off_t length) { return pvfs_truncate64(path, (off64_t) length); } -int pvfs_truncate64 (const char *path, off64_t length) +/** + * pvfs_truncate64 + */ +int pvfs_truncate64(const char *path, off64_t length) { int rc; pvfs_descriptor *pd; + if (!path) + { + errno = EINVAL; + return -1; + } pd = iocommon_open(path, O_WRONLY, PVFS_HINT_NULL, 0 , NULL); + if (!pd) + { + return -1; + } rc = iocommon_truncate(pd->pvfs_ref, length); pvfs_close(pd->fd); return rc; } -int pvfs_ftruncate (int fd, off_t length) +/** + * pvfs_allocate wrapper + * + * This isn't right but we dont' have a syscall to match this. + * Best effort is to tuncate to thex size, which should guarantee + * spaceis available starting at beginning (let alone offset) + * extending to offset+length. + * + * Our truncate doesn't always allocate blocks either, since + * the underlying FS may have a sparse implementation. + */ +int pvfs_fallocate(int fd, off_t offset, off_t length) +{ + if (offset < 0 || length < 0) + { + errno = EINVAL; + return -1; + } + /* if (file_size < offset + length) + * { + */ + return pvfs_ftruncate64(fd, (off64_t)(offset) + (off64_t)(length)); +} + +/** + * pvfs_ftruncate wrapper + */ +int pvfs_ftruncate(int fd, off_t length) { return pvfs_ftruncate64(fd, (off64_t) length); } -int pvfs_ftruncate64 (int fd, off64_t length) +/** + * pvfs_ftruncate64 + */ +int pvfs_ftruncate64(int fd, off64_t length) { pvfs_descriptor *pd; + if (fd < 0) + { + errno = EBADF; + return -1; + } pd = pvfs_find_descriptor(fd); + if (!pd) + { + return -1; + } return iocommon_truncate(pd->pvfs_ref, length); } -/* pvfs_close */ -int pvfs_close( int fd ) +/** + * pvfs_close + * + * TODO: add open/close count to minimize metadata ops + * this may only work if we have multi-user caching + * which we don't for now + */ +int pvfs_close(int fd) { + int rc = 0; pvfs_descriptor* pd; + debug("pvfs_close: called with %d\n", fd); + if (fd < 0) + { + errno = EBADF; + return -1; + } pd = pvfs_find_descriptor(fd); - if (pd == 0) { + if (!pd) + { errno = EBADF; return PVFS_FD_FAILURE; } /* flush buffers */ - pvfs_flush(fd); - - /* free buffers */ - if (pd->buf) - free(pd->buf); + if (S_ISREG(pd->mode)) + { + rc = iocommon_fsync(pd); + if (rc < 0) + { + return -1; + } + } /* free descriptor */ - pvfs_free_descriptor(fd); + rc = pvfs_free_descriptor(pd->fd); + if (rc < 0) + { + return -1; + } - return PVFS_FD_SUCCESS; + debug("pvfs_close: returns %d\n", rc); + return rc; } +/** + * pvfs_flush + */ int pvfs_flush(int fd) { + int rc = 0; pvfs_descriptor* pd; - int rc; -#ifdef DEBUG - pvfs_debug("in pvfs_flush(%ld)\n", fd); -#endif + debug("pvfs_flush: called with %d\n", fd); - /* Find the descriptor */ - pd = pvfs_find_descriptor(fd); - if (pd == 0) { + if (fd < 0) + { errno = EBADF; - return PVFS_FD_FAILURE; + return -1; } - - /* write any buffered data to the server */ - if (pd->buf && pd->dirty) + /* Find the descriptor */ + pd = pvfs_find_descriptor(fd); + if (!pd) { - pd->file_pointer = pd->buf_off; - rc = pvfs_write(fd, pd->buf, - (pd->buftotal < pd->bufsize) ? pd->buftotal : pd->bufsize); - pd->dirty = 0; + errno = EBADF; + return -1; } /* tell the server to flush data to disk */ rc = iocommon_fsync(pd); - if (rc == 0) { - return PVFS_FD_SUCCESS; - } - else { - errno = EINVAL; - return PVFS_FD_FAILURE; - } + debug("pvfs_flush: returns %d\n", rc); + return rc; } /* various flavors of stat */ +/** + * pvfs_stat + */ int pvfs_stat(const char *path, struct stat *buf) { + return pvfs_stat_mask(path, buf, PVFS_ATTR_DEFAULT_MASK); +} + +int pvfs_stat_mask(const char *path, struct stat *buf, uint32_t mask) +{ + int rc; char *newpath; pvfs_descriptor *pd; newpath = pvfs_qualify_path(path); + if (!newpath) + { + return -1; + } pd = iocommon_open(newpath, O_RDONLY, PVFS_HINT_NULL, 0, NULL); + if (!pd) + { + rc = -1; + goto errorout; + } + mask &= PVFS_ATTR_DEFAULT_MASK; + rc = iocommon_stat(pd, buf, mask); + pvfs_close(pd->fd); + +errorout: if (newpath != path) { free(newpath); } - iocommon_stat(pd, buf); - pvfs_close(pd->fd); + return rc; } +/** + * pvfs_stat64 + */ int pvfs_stat64(const char *path, struct stat64 *buf) { + int rc; char *newpath; pvfs_descriptor *pd; newpath = pvfs_qualify_path(path); + if (!newpath) + { + return -1; + } pd = iocommon_open(newpath, O_RDONLY, PVFS_HINT_NULL, 0, NULL); + if (!pd) + { + rc = -1; + goto errorout; + } + rc = iocommon_stat64(pd, buf, PVFS_ATTR_DEFAULT_MASK); + pvfs_close(pd->fd); + +errorout: if (newpath != path) { free(newpath); } - iocommon_stat64(pd, buf); - pvfs_close(pd->fd); + return rc; } +/** + * pvfs_fstat + */ int pvfs_fstat(int fd, struct stat *buf) +{ + return pvfs_fstat_mask(fd, buf, PVFS_ATTR_DEFAULT_MASK); +} + +int pvfs_fstat_mask(int fd, struct stat *buf, uint32_t mask) { pvfs_descriptor *pd; + + if (fd < 0) + { + errno = EBADF; + return -1; + } pd = pvfs_find_descriptor(fd); - iocommon_stat(pd, buf); + if (!pd) + { + errno = EBADF; + return -1; + } + mask &= PVFS_ATTR_DEFAULT_MASK; + return iocommon_stat(pd, buf, mask); } +/** + * pvfs_fstat64 + */ int pvfs_fstat64(int fd, struct stat64 *buf) { pvfs_descriptor *pd; + + if (fd < 0) + { + errno = EBADF; + return -1; + } pd = pvfs_find_descriptor(fd); - iocommon_stat64(pd, buf); + if (!pd) + { + errno = EBADF; + return -1; + } + return iocommon_stat64(pd, buf, PVFS_ATTR_DEFAULT_MASK); } -int pvfs_fstatat(int fd, char *path, struct stat *buf, int flag) +/** + * pvfs_fstatat + */ +int pvfs_fstatat(int fd, const char *path, struct stat *buf, int flag) { + int rc; pvfs_descriptor *pd, *pd2; + if (path[0] == '/' || fd == AT_FDCWD) + { if (flag & AT_SYMLINK_NOFOLLOW) - pvfs_lstat(path, buf); + { + rc = pvfs_lstat(path, buf); + } else - pvfs_stat(path, buf); + { + rc = pvfs_stat(path, buf); + } + } else { int flags = O_RDONLY; if (flag & AT_SYMLINK_NOFOLLOW) + { flags |= O_NOFOLLOW; + } + if (fd < 0) + { + errno = EBADF; + return -1; + } pd = pvfs_find_descriptor(fd); - pd2 = iocommon_open(path, flags, PVFS_HINT_NULL, 0, &pd->pvfs_ref); - iocommon_stat(pd2, buf); + if (!pd) + { + return -1; + } + pd2 = iocommon_open(path, flags, PVFS_HINT_NULL, 0, pd); + if (!pd2) + { + return -1; + } + rc = iocommon_stat(pd2, buf, PVFS_ATTR_DEFAULT_MASK); pvfs_close(pd2->fd); } + return rc; } -int pvfs_fstatat64(int fd, char *path, struct stat64 *buf, int flag) +/** + * pvfs_fstatat64 + */ +int pvfs_fstatat64(int fd, const char *path, struct stat64 *buf, int flag) { + int rc; pvfs_descriptor *pd, *pd2; + if (path[0] == '/' || fd == AT_FDCWD) + { if (flag & AT_SYMLINK_NOFOLLOW) - pvfs_lstat64(path, buf); + { + rc = pvfs_lstat64(path, buf); + } else - pvfs_stat64(path, buf); + { + rc = pvfs_stat64(path, buf); + } + } else { int flags = O_RDONLY; if (flag & AT_SYMLINK_NOFOLLOW) + { flags |= O_NOFOLLOW; + } + if (fd < 0) + { + errno = EBADF; + return -1; + } pd = pvfs_find_descriptor(fd); - pd2 = iocommon_open(path, flags, PVFS_HINT_NULL, 0, &pd->pvfs_ref); - iocommon_stat64(pd2, buf); + if (!pd) + { + errno = EBADF; + return -1; + } + pd2 = iocommon_open(path, flags, PVFS_HINT_NULL, 0, pd); + if (!pd2) + { + return -1; + } + rc = iocommon_stat64(pd2, buf, PVFS_ATTR_DEFAULT_MASK); pvfs_close(pd2->fd); } + return rc; } +/** + * pvfs_lstat + */ int pvfs_lstat(const char *path, struct stat *buf) { + return pvfs_lstat_mask(path, buf, PVFS_ATTR_DEFAULT_MASK); +} + +int pvfs_lstat_mask(const char *path, struct stat *buf, uint32_t mask) +{ + int rc; char *newpath; pvfs_descriptor *pd; newpath = pvfs_qualify_path(path); + if (!newpath) + { + return -1; + } pd = iocommon_open(newpath, O_RDONLY|O_NOFOLLOW, PVFS_HINT_NULL, 0, NULL); + if (!pd) + { + rc = -1; + goto errorout; + } + mask &= PVFS_ATTR_DEFAULT_MASK; + rc = iocommon_stat(pd, buf, mask); + pvfs_close(pd->fd); + +errorout: if (newpath != path) { free(newpath); } - iocommon_stat(pd, buf); - pvfs_close(pd->fd); + return rc; } +/** + * pvfs_lstat64 + */ int pvfs_lstat64(const char *path, struct stat64 *buf) { + int rc; char *newpath; pvfs_descriptor *pd; newpath = pvfs_qualify_path(path); + if (!newpath) + { + return -1; + } pd = iocommon_open(newpath, O_RDONLY|O_NOFOLLOW, PVFS_HINT_NULL, 0, NULL); + if (!pd) + { + rc = -1; + goto errorout; + } + rc = iocommon_stat64(pd, buf, PVFS_ATTR_DEFAULT_MASK); + pvfs_close(pd->fd); + +errorout: if (newpath != path) { free(newpath); } - iocommon_stat64(pd, buf); - pvfs_close(pd->fd); + return rc; } +/** + * pvfs_dup + */ int pvfs_dup(int oldfd) { return pvfs_dup_descriptor(oldfd, -1); } +/** + * pvfs_dup2 + */ int pvfs_dup2(int oldfd, int newfd) { return pvfs_dup_descriptor(oldfd, newfd); } -int pvfs_chown (const char *path, uid_t owner, gid_t group) +/** + * pvfs_chown + */ +int pvfs_chown(const char *path, uid_t owner, gid_t group) { + int rc; char *newpath; pvfs_descriptor *pd; newpath = pvfs_qualify_path(path); + if (!newpath) + { + return -1; + } pd = iocommon_open(newpath, O_RDONLY, PVFS_HINT_NULL, 0, NULL); + if (!pd) + { + rc = -1; + goto errorout; + } + rc = iocommon_chown(pd, owner, group); + pvfs_close(pd->fd); + +errorout: if (newpath != path) { free(newpath); } - iocommon_chown(pd, owner, group); - pvfs_close(pd->fd); + return rc; } -int pvfs_fchown (int fd, uid_t owner, gid_t group) +/** + * pvfs_fchown + */ +int pvfs_fchown(int fd, uid_t owner, gid_t group) { pvfs_descriptor *pd; + + if (fd < 0) + { + errno = EBADF; + return -1; + } pd = pvfs_find_descriptor(fd); - iocommon_chown(pd, owner, group); + if (!pd) + { + errno = EBADF; + return -1; + } + return iocommon_chown(pd, owner, group); } -int pvfs_fchownat(int fd, char *path, uid_t owner, gid_t group, int flag) +/** + * pvfs_fchownat + */ +int pvfs_fchownat(int fd, const char *path, uid_t owner, gid_t group, int flag) { + int rc; pvfs_descriptor *pd, *pd2; + if (path[0] == '/' || fd == AT_FDCWD) + { if (flag & AT_SYMLINK_NOFOLLOW) - pvfs_lchown(path, owner, group); + { + rc = pvfs_lchown(path, owner, group); + } else - pvfs_chown(path, owner, group); + { + rc = pvfs_chown(path, owner, group); + } + } else { int flags = O_RDONLY; if (flag & AT_SYMLINK_NOFOLLOW) + { flags |= O_NOFOLLOW; + } + if (fd < 0) + { + errno = EBADF; + return -1; + } pd = pvfs_find_descriptor(fd); - pd2 = iocommon_open(path, flags, PVFS_HINT_NULL, 0, &pd->pvfs_ref); - iocommon_chown(pd2, owner, group); + if (!pd) + { + return -1; + } + pd2 = iocommon_open(path, flags, PVFS_HINT_NULL, 0, pd); + if (!pd) + { + return -1; + } + rc = iocommon_chown(pd2, owner, group); pvfs_close(pd2->fd); } + return rc; } -int pvfs_lchown (const char *path, uid_t owner, gid_t group) +/** + * pvfs_lchown + */ +int pvfs_lchown(const char *path, uid_t owner, gid_t group) { + int rc; char *newpath; pvfs_descriptor *pd; newpath = pvfs_qualify_path(path); + if (!newpath) + { + return -1; + } pd = iocommon_open(newpath, O_RDONLY|O_NOFOLLOW, PVFS_HINT_NULL, 0, NULL); + if (!pd) + { + rc = -1; + goto errorout; + } + rc = iocommon_chown(pd, owner, group); + pvfs_close(pd->fd); + +errorout: if (newpath != path) { free(newpath); } - iocommon_chown(pd, owner, group); - pvfs_close(pd->fd); + return rc; } -int pvfs_chmod (const char *path, mode_t mode) +/** + * pvfs_chmod + */ +int pvfs_chmod(const char *path, mode_t mode) { + int rc; char *newpath; pvfs_descriptor *pd; newpath = pvfs_qualify_path(path); + if (!newpath) + { + return -1; + } pd = iocommon_open(newpath, O_RDONLY, PVFS_HINT_NULL, 0, NULL); + if (!pd) + { + rc = -1; + goto errorout; + } + rc = iocommon_chmod(pd, mode); + pvfs_close(pd->fd); + +errorout: if (newpath != path) { free(newpath); } - iocommon_chmod(pd, mode); - pvfs_close(pd->fd); + return rc; } -int pvfs_fchmod (int fd, mode_t mode) +/** + * pvfs_fchmod + */ +int pvfs_fchmod(int fd, mode_t mode) { pvfs_descriptor *pd; + + if (fd < 0) + { + errno = EBADF; + return -1; + } pd = pvfs_find_descriptor(fd); - iocommon_chmod(pd, mode); + if (!pd) + { + errno = EBADF; + return -1; + } + return iocommon_chmod(pd, mode); } -int pvfs_fchmodat(int fd, char *path, mode_t mode, int flag) +/** + * pvfs_fchmodat + */ +int pvfs_fchmodat(int fd, const char *path, mode_t mode, int flag) { + int rc; pvfs_descriptor *pd, *pd2; + if (path[0] == '/' || fd == AT_FDCWD) - if (flag & AT_SYMLINK_NOFOLLOW) - pvfs_lchmod(path, mode); - else - pvfs_chmod(path, mode); + { + rc = pvfs_chmod(path, mode); + } else { int flags = O_RDONLY; - if (flag & AT_SYMLINK_NOFOLLOW) - flags |= O_NOFOLLOW; + if (fd < 0) + { + errno = EBADF; + return -1; + } pd = pvfs_find_descriptor(fd); - pd2 = iocommon_open(path, flags, PVFS_HINT_NULL, 0, &pd->pvfs_ref); - iocommon_chmod(pd2, mode); + if (!pd) + { + return -1; + } + pd2 = iocommon_open(path, flags, PVFS_HINT_NULL, 0, pd); + if (!pd2) + { + return -1; + } + rc = iocommon_chmod(pd2, mode); pvfs_close(pd2->fd); } + return rc; } -/* this is not a Linux syscall, but its useful above */ -int pvfs_lchmod (const char *path, mode_t mode) +/** + * pvfs_mkdir + */ +int pvfs_mkdir(const char *path, mode_t mode) { + int rc; char *newpath; - pvfs_descriptor *pd; newpath = pvfs_qualify_path(path); - pd = iocommon_open(newpath, O_RDONLY|O_NOFOLLOW, PVFS_HINT_NULL, 0, NULL); - if (newpath != path) + if (!newpath) { - free(newpath); + return -1; } - iocommon_chmod(pd, mode); - pvfs_close(pd->fd); -} - -int pvfs_mkdir (const char *path, mode_t mode) -{ - char *newpath; - int rc; - - newpath = pvfs_qualify_path(path); - rc = iocommon_make_directory(newpath, (mode & ~mask_val & 0777)); + rc = iocommon_make_directory(newpath, (mode & ~mask_val & 0777), NULL); if (newpath != path) { free(newpath); @@ -662,27 +1304,52 @@ int pvfs_mkdir (const char *path, mode_t mode) return rc; } -int pvfs_mkdirat (int dirfd, const char *path, mode_t mode) +/** + * pvfs_mkdirat + */ +int pvfs_mkdirat(int dirfd, const char *path, mode_t mode) { - pvfs_descriptor *pd, *pd2; + int rc; + pvfs_descriptor *pd; + if (path[0] == '/' || dirfd == AT_FDCWD) - pvfs_mkdir(path, mode); + { + rc = pvfs_mkdir(path, mode); + } else { - int flags = O_RDONLY; + if (dirfd < 0) + { + errno = EBADF; + return -1; + } pd = pvfs_find_descriptor(dirfd); - /* not sure what to do with this ... */ - return -1; + if (!pd) + { + errno = EBADF; + return -1; + } + rc = iocommon_make_directory(path, + (mode & ~mask_val & 0777), + &pd->pvfs_ref); } + return rc; } -int pvfs_rmdir (const char *path) +/** + * pvfs_rmdir + */ +int pvfs_rmdir(const char *path) { - char *newpath; int rc; + char *newpath; newpath = pvfs_qualify_path(path); - rc = iocommon_rmdir(newpath); + if (!newpath) + { + return -1; + } + rc = iocommon_rmdir(newpath, NULL); if (newpath != path) { free(newpath); @@ -690,87 +1357,788 @@ int pvfs_rmdir (const char *path) return rc; } -ssize_t pvfs_readlink (const char *path, char *buf, size_t bufsiz) +/** + * readlink fills buffer with contents of a symbolic link + * + */ +ssize_t pvfs_readlink(const char *path, char *buf, size_t bufsiz) { -} + int rc; + char *newpath; + pvfs_descriptor *pd; -int pvfs_readlinkat (int dirfd, const char *path, char *buf, size_t bufsiz) -{ -} + newpath = pvfs_qualify_path(path); + if (!newpath) + { + return -1; + } + pd = iocommon_open(newpath, O_RDONLY | O_NOFOLLOW, PVFS_HINT_NULL, 0, NULL); + if (!pd) + { + rc = -1; + goto errorout; + } + debug("pvfs_readlink mode is %o\n", pd->mode); + /* this checks that it is a valid symlink and sets errno if not */ + rc = iocommon_readlink(pd, buf, bufsiz); + /* need to close if readlink succeeds or not */ + pvfs_close(pd->fd); -ssize_t pvfs_symlink (const char *oldpath, const char *newpath) -{ +errorout: + if (newpath != path) + { + free(newpath); + } + return rc; } -int pvfs_symlinkat (const char *oldpath, int newdirfd, const char *newpath) +int pvfs_readlinkat(int fd, const char *path, char *buf, size_t bufsiz) { -} + int rc; + pvfs_descriptor *pd, *pd2; -/* PVFS does not have hard links */ -ssize_t pvfs_link (const char *oldpath, const char *newpath) -{ + if (path[0] == '/' || fd == AT_FDCWD) + { + rc = pvfs_readlink(path, buf, bufsiz); + } + else + { + int flags = O_RDONLY | O_NOFOLLOW; + if (fd < 0) + { + errno = EBADF; + return -1; + } + pd = pvfs_find_descriptor(fd); + if (!pd) + { + return -1; + } + pd2 = iocommon_open(path, flags, PVFS_HINT_NULL, 0, pd); + if(!pd2) + { + return -1; + } + rc = iocommon_readlink(pd2, buf, bufsiz); + pvfs_close(pd2->fd); + } + return rc; } -/* PVFS does not have hard links */ -int pvfs_linkat (const char *oldpath, int newdirfd, - const char *newpath, int flags) +int pvfs_symlink(const char *oldpath, const char *newpath) { + int rc = 0; + char *abspath; + abspath = pvfs_qualify_path(newpath); + if (!abspath) + { + return -1; + } + rc = iocommon_symlink(abspath, oldpath, NULL); + if (abspath != newpath) + { + free(abspath); + } + return rc; } -/* this reads exactly one dirent, count is ignored */ -int pvfs_readdir(unsigned int fd, struct dirent *dirp, unsigned int count) +int pvfs_symlinkat(const char *oldpath, int newdirfd, const char *newpath) { + pvfs_descriptor *pd; - return 1; /* success */ - return 0; /* end of file */ - return -1; /* error */ + if (newpath[0] == '/' || newdirfd == AT_FDCWD) + { + return pvfs_symlink(oldpath, newpath); + } + else + { + if (newdirfd < 0) + { + errno = EBADF; + return -1; + } + pd = pvfs_find_descriptor(newdirfd); + if (!pd) + { + errno = EBADF; + return -1; + } + } + return iocommon_symlink(newpath, oldpath, &pd->pvfs_ref); } -/* this reads multiple dirents, up to count */ -int pvfs_getdents(unsigned int fd, struct dirent *dirp, unsigned int count) +/** + * PVFS does not have hard links + */ +ssize_t pvfs_link(const char *oldpath, const char *newpath) { - int bytes; - return bytes; /* success */ - return 0; /* end of file */ - return -1; /* error */ + fprintf(stderr, "pvfs_link not implemented\n"); + errno = ENOSYS; + return -1; } -int pvfs_access (const char * path, int mode) +/** + * PVFS does not have hard links + */ +int pvfs_linkat(int olddirfd, const char *oldpath, + int newdirfd, const char *newpath, int flags) { + fprintf(stderr, "pvfs_linkat not implemented\n"); + errno = ENOSYS; + return -1; } -int pvfs_faccessat (int dirfd, const char * path, int mode, int flags) +/** + * this reads exactly one dirent, count is ignored + */ +int pvfs_readdir(unsigned int fd, struct dirent *dirp, unsigned int count) { + return pvfs_getdents(fd, dirp, 1); } -int pvfs_flock(int fd, int op) +/** + * this reads multiple dirents, man pages calls last arg count but + * is ambiguous if it is number of records or number of bytes. latter + * appears to be true so we renmame size. Returns bytes read. + */ +int pvfs_getdents(unsigned int fd, struct dirent *dirp, unsigned int size) { + pvfs_descriptor *pd; + + if (fd < 0) + { + errno = EBADF; + return -1; + } + pd = pvfs_find_descriptor(fd); + if (!pd) + { + errno = EBADF; + return -1; + } + return iocommon_getdents(pd, dirp, size); +} + +int pvfs_getdents64(unsigned int fd, struct dirent64 *dirp, unsigned int size) +{ + pvfs_descriptor *pd; + + if (fd < 0) + { + errno = EBADF; + return -1; + } + pd = pvfs_find_descriptor(fd); + if (!pd) + { + errno = EBADF; + return -1; + } + return iocommon_getdents64(pd, dirp, size); +} + +int pvfs_access(const char *path, int mode) +{ + int rc = 0; + char *newpath; + newpath = pvfs_qualify_path(path); + if (!newpath) + { + return -1; + } + rc = iocommon_access(path, mode, 0, NULL); + if (newpath != path) + { + free(newpath); + } + return rc; +} + +int pvfs_faccessat(int fd, const char *path, int mode, int flags) +{ + pvfs_descriptor *pd; + + if (path[0] == '/' || fd == AT_FDCWD) + { + return pvfs_access(path, mode); + } + else + { + if (fd < 0) + { + errno = EBADF; + return -1; + } + pd = pvfs_find_descriptor(fd); + if(!pd) + { + errno = EBADF; + return -1; + } + } + return iocommon_access(path, mode, flags, &pd->pvfs_ref); +} + +int pvfs_flock(int fd, int op) +{ + errno = ENOSYS; + fprintf(stderr, "pvfs_flock not implemented\n"); + return -1; } int pvfs_fcntl(int fd, int cmd, ...) { + int rc = 0; va_list ap; - long arg; + /* long arg; */ struct flock *lock; + pvfs_descriptor *pd; + + pd = pvfs_find_descriptor(fd); + if (!pd) + { + errno = EBADF; + rc = -1; + goto errorout; + } + va_start(ap, cmd); + switch (cmd) + { + case F_DUPFD : + case F_GETFD : + case F_SETFD : + errno = ENOSYS; + fprintf(stderr, "pvfs_fcntl not implemented\n"); + rc = -1; + break; + case F_GETFL : + rc = pd->flags; + break; + case F_SETFL : + pd->flags = va_arg(ap, int); + break; + case F_GETLK : + case F_SETLK : + case F_SETLKW : + lock = va_arg(ap, struct flock *); + case F_GETOWN : + case F_SETOWN : + case F_GETSIG : + case F_SETSIG : + case F_GETLEASE : + case F_SETLEASE : + case F_NOTIFY : + default : + errno = ENOSYS; + fprintf(stderr, "pvfs_fcntl not implemented\n"); + rc = -1; + break; + } + va_end(ap); + +errorout : + return rc; } /* sync all disk data */ void pvfs_sync(void ) { + return; } /* sync file, but not dir it is in */ int pvfs_fsync(int fd) { - return 0; /* success */ + int rc = 0; + + rc = pvfs_flush(fd); /* as close as we have for now */ + return rc; } /* does not sync file metadata */ int pvfs_fdatasync(int fd) { - return 0; /* success */ + int rc = 0; + + rc = pvfs_flush(fd); /* as close as we have for now */ + return rc; +} + +int pvfs_fadvise(int fd, off_t offset, off_t len, int advice) +{ + return pvfs_fadvise64(fd, (off64_t) offset, (off64_t)len, advice); +} + +/** fadvise implementation + * + * technically this is a hint, so doing nothing is still success + */ +int pvfs_fadvise64(int fd, off64_t offset, off64_t len, int advice) +{ + switch (advice) + { + case POSIX_FADV_NORMAL: + case POSIX_FADV_RANDOM: + case POSIX_FADV_SEQUENTIAL: + case POSIX_FADV_WILLNEED: + case POSIX_FADV_DONTNEED: + case POSIX_FADV_NOREUSE: + break; + default: + errno = EINVAL; + return -1; + } + return 0; +} + +int pvfs_statfs(const char *path, struct statfs *buf) +{ + int rc; + char *newpath; + pvfs_descriptor *pd; + + newpath = pvfs_qualify_path(path); + if (!newpath) + { + return -1; + } + pd = iocommon_open(newpath, O_RDONLY, PVFS_HINT_NULL, 0, NULL); + if (!pd) + { + rc = -1; + goto errorout; + } + rc = iocommon_statfs(pd, buf); + pvfs_close(pd->fd); + +errorout: + if (newpath != path) + { + free(newpath); + } + return rc; +} + +int pvfs_statfs64(const char *path, struct statfs64 *buf) +{ + int rc; + char *newpath; + pvfs_descriptor *pd; + + newpath = pvfs_qualify_path(path); + if (!newpath) + { + return -1; + } + pd = iocommon_open(newpath, O_RDONLY, PVFS_HINT_NULL, 0, NULL); + if (!pd) + { + rc = -1; + goto errorout; + } + rc = iocommon_statfs64(pd, buf); + pvfs_close(pd->fd); + +errorout: + if (newpath != path) + { + free(newpath); + } + return rc; +} + +int pvfs_fstatfs(int fd, struct statfs *buf) +{ + pvfs_descriptor *pd; + + if (fd < 0) + { + errno = EBADF; + return -1; + } + pd = pvfs_find_descriptor(fd); + if (!pd) + { + errno = EBADF; + return -1; + } + return iocommon_statfs(pd, buf); +} + +int pvfs_fstatfs64(int fd, struct statfs64 *buf) +{ + pvfs_descriptor *pd; + + if (fd < 0) + { + errno = EBADF; + return -1; + } + pd = pvfs_find_descriptor(fd); + if (!pd) + { + errno = EBADF; + return -1; + } + return iocommon_statfs64(pd, buf); +} + +int pvfs_mknod(const char *path, mode_t mode, dev_t dev) +{ + return pvfs_mknodat(AT_FDCWD, path, mode, dev); +} + +int pvfs_mknodat(int dirfd, const char *path, mode_t mode, dev_t dev) +{ + int fd; + /* int s_type = mode & S_IFMT; */ + + switch (dev) + { + case S_IFREG: + fd = pvfs_openat(dirfd, path, O_CREAT|O_EXCL|O_RDONLY, mode & 0x777); + if (fd < 0) + { + return -1; + } + pvfs_close(fd); + break; + case S_IFCHR: + case S_IFBLK: + case S_IFIFO: + case S_IFSOCK: + default: + errno = EINVAL; + return -1; + } + return 0; +} + +ssize_t pvfs_sendfile(int outfd, int infd, off_t *offset, size_t count) +{ + return pvfs_sendfile64(outfd, infd, (off64_t *)offset, count); +} + +ssize_t pvfs_sendfile64(int outfd, int infd, off64_t *offset, size_t count) +{ + pvfs_descriptor *inpd, *outpd; + + inpd = pvfs_find_descriptor(infd); + outpd = pvfs_find_descriptor(outfd); /* this should be a socket */ + if (!inpd || !outpd) + { + errno = EBADF; + return -1; + } + return iocommon_sendfile(outpd->true_fd, inpd, offset, count); +} + +int pvfs_setxattr(const char *path, + const char *name, + const void *value, + size_t size, + int flags) +{ + int fd, rc = 0; + + fd = pvfs_open(path, O_RDWR); + if (fd < 0) + { + return fd; + } + rc = pvfs_fsetxattr(fd, name, value, size, flags); + pvfs_close(fd); + return rc; +} + +int pvfs_lsetxattr(const char *path, + const char *name, + const void *value, + size_t size, + int flags) +{ + int fd, rc = 0; + + fd = pvfs_open(path, O_RDWR | O_NOFOLLOW); + if (fd < 0) + { + return fd; + } + rc = pvfs_fsetxattr(fd, name, value, size, flags); + pvfs_close(fd); + return rc; +} + +int pvfs_fsetxattr(int fd, + const char *name, + const void *value, + size_t size, + int flags) +{ + int rc = 0; + pvfs_descriptor *pd; + + pd = pvfs_find_descriptor(fd); + if (!pd) + { + errno = EBADF; + return -1; + } + rc = iocommon_seteattr(pd, name, value, size, flags); + return rc; +} + +int pvfs_getxattr(const char *path, + const char *name, + void *value, + size_t size) +{ + int fd, rc = 0; + + fd = pvfs_open(path, O_RDWR); + if (fd < 0) + { + return fd; + } + rc = pvfs_fgetxattr(fd, name, value, size); + pvfs_close(fd); + return rc; } +int pvfs_lgetxattr(const char *path, + const char *name, + void *value, + size_t size) +{ + int fd, rc = 0; + + fd = pvfs_open(path, O_RDWR | O_NOFOLLOW); + if (fd < 0) + { + return fd; + } + rc = pvfs_fgetxattr(fd, name, value, size); + pvfs_close(fd); + return rc; +} + +int pvfs_fgetxattr(int fd, + const char *name, + void *value, + size_t size) +{ + pvfs_descriptor *pd; + + pd = pvfs_find_descriptor(fd); + if (!pd) + { + errno = EBADF; + return -1; + } + return iocommon_geteattr(pd, name, value, size); +} + +int pvfs_listxattr(const char *path, + char *list, + size_t size) +{ + int fd, rc = 0; + + fd = pvfs_open(path, O_RDWR); + if (fd < 0) + { + return fd; + } + rc = pvfs_flistxattr(fd, list, size); + pvfs_close(fd); + return rc; +} + +int pvfs_llistxattr(const char *path, + char *list, + size_t size) +{ + int fd, rc = 0; + + fd = pvfs_open(path, O_RDWR | O_NOFOLLOW); + if (fd < 0) + { + return fd; + } + rc = pvfs_flistxattr(fd, list, size); + pvfs_close(fd); + return rc; +} + +int pvfs_flistxattr(int fd, + char *list, + size_t size) +{ + int numkeys, rc = 0; + pvfs_descriptor *pd; + + pd = pvfs_find_descriptor(fd); + if (!pd) + { + errno = EBADF; + return -1; + } + rc = iocommon_listeattr(pd, list, size, &numkeys); + if (rc < 0) + { + return -1; + } + return numkeys; +} + +int pvfs_removexattr(const char *path, + const char *name) +{ + int fd, rc = 0; + + fd = pvfs_open(path, O_RDWR); + if (fd < 0) + { + return fd; + } + rc = pvfs_fremovexattr(fd, name); + pvfs_close(fd); + return rc; +} + +int pvfs_lremovexattr(const char *path, + const char *name) +{ + int fd, rc = 0; + + fd = pvfs_open(path, O_RDWR | O_NOFOLLOW); + if (fd < 0) + { + return fd; + } + rc = pvfs_fremovexattr(fd, name); + pvfs_close(fd); + return rc; +} + +int pvfs_fremovexattr(int fd, + const char *name) +{ + pvfs_descriptor *pd; + + pd = pvfs_find_descriptor(fd); + if (!pd) + { + errno = EBADF; + return -1; + } + return iocommon_deleattr(pd, name); +} + +/** + * pvfs chdir + */ +int pvfs_chdir(const char *path) +{ + int plen; + + if (!path) + { + errno = EINVAL; + return -1; + } + plen = strlen(path); + if (plen > PVFS_PATH_MAX) + { + errno = ENAMETOOLONG; + return -1; + } + strcpy(pvfs_cwd, path); + return 0; +} + +int pvfs_fchdir(int fd) +{ + int plen; + pvfs_descriptor *pd; + + pd = pvfs_find_descriptor(fd); + if (!pd || !pd->dpath) + { + errno = EBADF; + return -1; + } + plen = strlen(pd->dpath); + if (plen > PVFS_PATH_MAX) + { + errno = ENAMETOOLONG; + return -1; + } + strcpy(pvfs_cwd, pd->dpath); + return 0; +} + +char *pvfs_getcwd(char *buf, size_t size) +{ + int plen; + plen = strnlen(pvfs_cwd, PVFS_PATH_MAX); + if (!buf) + { + /* malloc space */ + buf = (char *)malloc(plen + 1); + if (!buf) + { + errno = ENOMEM; + return NULL; + } + } + else + { + if (size == 0) + { + errno = EINVAL; + return NULL; + } + if (size < plen + 1) + { + errno = ERANGE; + return NULL; + } + } + strcpy(buf, pvfs_cwd); + return buf; +} + +char *pvfs_get_current_dir_name(void) +{ + int plen; + char *buf; + plen = strnlen(pvfs_cwd, PVFS_PATH_MAX); + buf = (char *)malloc(plen + 1); + if (!buf) + { + errno = ENOMEM; + return NULL; + } + strcpy(buf, pvfs_cwd); + return buf; +} + +char *pvfs_getwd(char *buf) +{ + if (!buf) + { + errno = EINVAL; + return NULL; + } + strncpy(buf, pvfs_cwd, PVFS_PATH_MAX); + return buf; +} + + +/** + * pvfs_umask + */ mode_t pvfs_umask(mode_t mask) { mode_t old_mask = mask_val; @@ -790,7 +2158,6 @@ int pvfs_getdtablesize(void) posix_ops pvfs_ops = { - .statfs = statfs, .open = pvfs_open, .open64 = pvfs_open64, .openat = pvfs_openat, @@ -808,13 +2175,14 @@ posix_ops pvfs_ops = .write = pvfs_write, .pwrite = pvfs_pwrite, .writev = pvfs_writev, - .write64 = pvfs_write64, + .pwrite64 = pvfs_pwrite64, .lseek = pvfs_lseek, .lseek64 = pvfs_lseek64, .truncate = pvfs_truncate, .truncate64 = pvfs_truncate64, .ftruncate = pvfs_ftruncate, .ftruncate64 = pvfs_ftruncate64, + .fallocate = pvfs_fallocate, .close = pvfs_close, .flush = pvfs_flush, .stat = pvfs_stat, @@ -834,7 +2202,6 @@ posix_ops pvfs_ops = .chmod = pvfs_chmod, .fchmod = pvfs_fchmod, .fchmodat = pvfs_fchmodat, - .lchmod = pvfs_lchmod, .mkdir = pvfs_mkdir, .mkdirat = pvfs_mkdirat, .rmdir = pvfs_rmdir, @@ -846,6 +2213,7 @@ posix_ops pvfs_ops = .linkat = pvfs_linkat, .readdir = pvfs_readdir, .getdents = pvfs_getdents, + .getdents64 = pvfs_getdents64, .access = pvfs_access, .faccessat = pvfs_faccessat, .flock = pvfs_flock, @@ -853,9 +2221,31 @@ posix_ops pvfs_ops = .sync = pvfs_sync, .fsync = pvfs_fsync, .fdatasync = pvfs_fdatasync, + .fadvise = pvfs_fadvise, + .fadvise64 = pvfs_fadvise64, + .statfs = statfs, /* this one is probably special */ + .statfs64 = pvfs_statfs64, + .fstatfs = pvfs_fstatfs, + .fstatfs64 = pvfs_fstatfs64, + .mknod = pvfs_mknod, + .mknodat = pvfs_mknodat, + .sendfile = pvfs_sendfile, + .sendfile64 = pvfs_sendfile64, + .setxattr = pvfs_setxattr, + .lsetxattr = pvfs_lsetxattr, + .fsetxattr = pvfs_fsetxattr, + .getxattr = pvfs_getxattr, + .lgetxattr = pvfs_lgetxattr, + .fgetxattr = pvfs_fgetxattr, + .listxattr = pvfs_listxattr, + .llistxattr = pvfs_llistxattr, + .flistxattr = pvfs_flistxattr, + .removexattr = pvfs_removexattr, + .lremovexattr = pvfs_lremovexattr, + .fremovexattr = pvfs_fremovexattr, .umask = pvfs_umask, .getumask = pvfs_getumask, - .getdtablesize = pvfs_getdtablesize + .getdtablesize = pvfs_getdtablesize, }; /* diff --git a/src/client/usrint/posix-pvfs.h b/src/client/usrint/posix-pvfs.h index 72a5c87..c95ed2b 100644 --- a/src/client/usrint/posix-pvfs.h +++ b/src/client/usrint/posix-pvfs.h @@ -1,3 +1,14 @@ +/* + * (C) 2011 Clemson University and The University of Chicago + * + * See COPYING in top-level directory. + */ + +/** \file + * \ingroup usrint + * + * PVFS2 user interface routines + */ #ifndef POSIX_PVFS_H #define POSIX_PVFS_H 1 @@ -21,7 +32,7 @@ int pvfs_creat64(const char *path, mode_t mode, ...); /* pvfs_unlink */ int pvfs_unlink (const char *path); -int pvfs_unlinkat (int dirfd, const char *path); +int pvfs_unlinkat (int dirfd, const char *path, int flags); int pvfs_rename(const char *oldpath, const char *newpath); @@ -40,15 +51,15 @@ ssize_t pvfs_readv(int fd, const struct iovec *vector, int count); ssize_t pvfs_pread64( int fd, void *buf, size_t count, off64_t offset ); /* pvfs_write */ -ssize_t pvfs_write( int fd, void *buf, size_t count ); +ssize_t pvfs_write( int fd, const void *buf, size_t count ); /* pvfs_pwrite */ -ssize_t pvfs_pwrite( int fd, void *buf, size_t count, off_t offset ); +ssize_t pvfs_pwrite( int fd, const void *buf, size_t count, off_t offset ); ssize_t pvfs_writev( int fd, const struct iovec *vector, int count ); /* pvfs_pwrite64 */ -ssize_t pvfs_write64( int fd, void *buf, size_t count, off64_t offset ); +ssize_t pvfs_pwrite64( int fd, const void *buf, size_t count, off64_t offset ); /* pvfs_lseek */ off_t pvfs_lseek(int fd, off_t offset, int whence); @@ -60,6 +71,8 @@ int pvfs_truncate(const char *path, off_t length); int pvfs_truncate64 (const char *path, off64_t length); +int pvfs_fallocate(int fd, off_t offset, off_t length); + int pvfs_ftruncate (int fd, off_t length); int pvfs_ftruncate64 (int fd, off64_t length); @@ -74,18 +87,24 @@ int pvfs_stat(const char *path, struct stat *buf); int pvfs_stat64(const char *path, struct stat64 *buf); +int pvfs_stat_mask(const char *path, struct stat *buf, uint32_t mask); + int pvfs_fstat(int fd, struct stat *buf); int pvfs_fstat64(int fd, struct stat64 *buf); -int pvfs_fstatat(int fd, char *path, struct stat *buf, int flag); +int pvfs_fstatat(int fd, const char *path, struct stat *buf, int flag); + +int pvfs_fstatat64(int fd, const char *path, struct stat64 *buf, int flag); -int pvfs_fstatat64(int fd, char *path, struct stat64 *buf, int flag); +int pvfs_fstat_mask(int fd, struct stat *buf, uint32_t mask); int pvfs_lstat(const char *path, struct stat *buf); int pvfs_lstat64(const char *path, struct stat64 *buf); +int pvfs_lstat_mask(const char *path, struct stat *buf, uint32_t mask); + int pvfs_dup(int oldfd); int pvfs_dup2(int oldfd, int newfd); @@ -94,7 +113,7 @@ int pvfs_chown (const char *path, uid_t owner, gid_t group); int pvfs_fchown (int fd, uid_t owner, gid_t group); -int pvfs_fchownat(int fd, char *path, uid_t owner, gid_t group, int flag); +int pvfs_fchownat(int fd, const char *path, uid_t owner, gid_t group, int flag); int pvfs_lchown (const char *path, uid_t owner, gid_t group); @@ -102,10 +121,7 @@ int pvfs_chmod (const char *path, mode_t mode); int pvfs_fchmod (int fd, mode_t mode); -int pvfs_fchmodat(int fd, char *path, mode_t mode, int flag); - -/* this is not a Linux syscall, but its useful above */ -int pvfs_lchmod (const char *path, mode_t mode); +int pvfs_fchmodat(int fd, const char *path, mode_t mode, int flag); int pvfs_mkdir (const char *path, mode_t mode); @@ -117,7 +133,7 @@ ssize_t pvfs_readlink (const char *path, char *buf, size_t bufsiz); int pvfs_readlinkat (int dirfd, const char *path, char *buf, size_t bufsiz); -ssize_t pvfs_symlink (const char *oldpath, const char *newpath); +int pvfs_symlink (const char *oldpath, const char *newpath); int pvfs_symlinkat (const char *oldpath, int newdirfd, const char *newpath); @@ -125,8 +141,8 @@ int pvfs_symlinkat (const char *oldpath, int newdirfd, const char *newpath); ssize_t pvfs_link (const char *oldpath, const char *newpath); /* PVFS does not have hard links */ -int pvfs_linkat (const char *oldpath, int newdirfd, - const char *newpath, int flags); +int pvfs_linkat (int olddirfd, const char *oldpath, + int newdirfd, const char *newpath, int flags); /* this reads exactly one dirent, count is ignored */ int pvfs_readdir(unsigned int fd, struct dirent *dirp, unsigned int count); @@ -134,6 +150,8 @@ int pvfs_readdir(unsigned int fd, struct dirent *dirp, unsigned int count); /* this reads multiple dirents, up to count */ int pvfs_getdents(unsigned int fd, struct dirent *dirp, unsigned int count); +int pvfs_getdents64(unsigned int fd, struct dirent64 *dirp, unsigned int count); + int pvfs_access (const char * path, int mode); int pvfs_faccessat (int dirfd, const char * path, int mode, int flags); @@ -151,6 +169,66 @@ int pvfs_fsync(int fd); /* does not sync file metadata */ int pvfs_fdatasync(int fd); +int pvfs_fadvise(int fd, off_t offset, off_t len, int advice); + +int pvfs_fadvise64(int fd, off64_t offset, off64_t len, int advice); + +int pvfs_statfs(const char *path, struct statfs *buf); + +int pvfs_statfs64(const char *path, struct statfs64 *buf); + +int pvfs_fstatfs(int fd, struct statfs *buf); + +int pvfs_fstatfs64(int fd, struct statfs64 *buf); + +int pvfs_mknod(const char *path, mode_t mode, dev_t dev); + +int pvfs_mknodat(int dirfd, const char *path, mode_t mode, dev_t dev); + +ssize_t pvfs_sendfile(int outfd, int infd, off_t *offset, size_t count); + +ssize_t pvfs_sendfile64(int outfd, int infd, off64_t *offset, size_t count); + +int pvfs_setxattr(const char *path, const char *name, + const void *value, size_t size, int flags); + +int pvfs_lsetxattr(const char *path, const char *name, + const void *value, size_t size, int flags); + +int pvfs_fsetxattr(int fd, const char *name, + const void *value, size_t size, int flags); + +int pvfs_getxattr(const char *path, const char *name, + void *value, size_t size); + +int pvfs_lgetxattr(const char *path, const char *name, + void *value, size_t size); + +int pvfs_fgetxattr(int fd, const char *name, + void *value, size_t size); + +int pvfs_listxattr(const char *path, char *list, size_t size); + +int pvfs_llistxattr(const char *path, char *list, size_t size); + +int pvfs_flistxattr(int fd, char *list, size_t size); + +int pvfs_removexattr(const char *path, const char *name); + +int pvfs_lremovexattr(const char *path, const char *name); + +int pvfs_fremovexattr(int fd, const char *name); + +int pvfs_chdir(const char *path); + +int pvfs_fchdir(int fd); + +char *pvfs_getcwd(char *buf, size_t size); + +char *pvfs_get_current_dir_name(void); + +char *pvfs_getwd(char *buf); + mode_t pvfs_umask(mode_t mask); mode_t pvfs_getumask(void); diff --git a/src/client/usrint/posix.c b/src/client/usrint/posix.c index 9e775b9..e1a9f19 100644 --- a/src/client/usrint/posix.c +++ b/src/client/usrint/posix.c @@ -1,28 +1,22 @@ -#include +/* + * (C) 2011 Clemson University and The University of Chicago + * + * See COPYING in top-level directory. + */ -static int pvfs_lib_init = 0; +/** \file + * \ingroup usrint + * + * PVFS2 user interface routines - wrappers for posix system calls + */ -posix_ops glibc_ops = -{ - .statfs = statfs -}; +/* this prevents headers from using inlines for 64 bit calls */ -void load_glibc(void) -{ - pvfs_lib_init = 1; - glibc_ops.open = dlsym(RTLD_NEXT, "open"); - glibc_ops.open64 = dlsym(RTLD_NEXT, "open64"); - glibc_ops.unlink = dlsym(RTLD_NEXT, "unlink"); - glibc_ops.close = dlsym(RTLD_NEXT, "close"); - glibc_ops.read = dlsym(RTLD_NEXT, "read"); - glibc_ops.write = dlsym(RTLD_NEXT, "write"); - glibc_ops.lseek = dlsym(RTLD_NEXT, "lseek"); - glibc_ops.lseek64 = dlsym(RTLD_NEXT, "lseek64"); - glibc_ops.pread = dlsym(RTLD_NEXT, "pread"); - glibc_ops.pwrite = dlsym(RTLD_NEXT, "pwrite"); - glibc_ops.readv = dlsym(RTLD_NEXT, "readv"); - glibc_ops.writev = dlsym(RTLD_NEXT, "writev"); -} +#define USERINT_SOURCE 1 +#include "usrint.h" +#include "posix-ops.h" +#include "posix-pvfs.h" +#include "openfile-util.h" /* * SYSTEM CALLS @@ -38,10 +32,6 @@ int open(const char *path, int flags, ...) PVFS_hint hints; /* need to figure out how to set default */ pvfs_descriptor *pd; - if(!pvfs_lib_init) { - load_glibc(); - } - va_start(ap, flags); if (flags & O_CREAT) mode = va_arg(ap, mode_t); @@ -53,20 +43,37 @@ int open(const char *path, int flags, ...) hints = PVFS_HINT_NULL; va_end(ap); - if(is_pvfs_path(path)) { -#ifdef DEBUG - printf("PVFS_OPEN\n"); -#endif + if (!path) + { + errno = EFAULT; + return -1; + } + if (is_pvfs_path(path)) + { + /* this handles setup of the descriptor */ + flags |= O_NOTPVFS; /* try to open non-pvfs files too */ return pvfs_open(path, flags, mode, hints); } - else { -#ifdef DEBUG - printf("GLIBC_OPEN\n"); -#endif - pd = pvfs_alloc_descriptor(&glibc_ops); - pd->posix_fd = pd->fsops->open(path, flags, mode); + else + { + int rc; + struct stat sbuf; + /* path unknown to FS so open with glibc */ + rc = glibc_ops.open(path, flags & 01777777, mode); + if (rc < 0) + { + return rc; + } + /* set up the descriptor manually */ + pd = pvfs_alloc_descriptor(&glibc_ops, rc, NULL); + if (!pd) + { + return -1; + } + pd->is_in_use = PVFS_FS; pd->flags = flags; - pd->is_in_use = 1; + glibc_ops.fstat(rc, &sbuf); + pd->mode = sbuf.st_mode; return pd->fd; } } @@ -76,30 +83,70 @@ int open(const char *path, int flags, ...) */ int open64(const char *path, int flags, ...) { - va_list ap; - mode_t mode = 0; - PVFS_hint hints; /* need to figure out how to set default */ - - if(!pvfs_lib_init) { - load_glibc(); + int fd; + int mode = 0; + va_list ap; + va_start(ap, flags); + if (flags & O_CREAT) + { + mode = va_arg(ap, int); } - - va_start(ap, flags); - if (flags & O_HINTS) - hints = va_arg(ap, PVFS_hint); - else - hints = PVFS_HINT_NULL; - va_end(ap); - - return open(path, flags|O_LARGEFILE, mode, hints); + fd = open(path, flags|O_LARGEFILE, mode); + va_end(ap); + return fd; } int openat(int dirfd, const char *path, int flags, ...) { + int fd; + int mode = 0; + pvfs_descriptor *pd; + va_list ap; + + if (!path) + { + errno = EFAULT; + return -1; + } + va_start(ap, flags); + if (flags & O_CREAT) + { + mode = va_arg(ap, int); + } + if (dirfd == AT_FDCWD || path[0] == '/') + { + fd = open(path, flags, mode); + } + else + { + pd = pvfs_find_descriptor(dirfd); + if (pd) + { + fd = pd->fsops->openat(pd->true_fd, path, flags, mode); + } + else + { + errno = EBADF; + fd = -1; + } + } + va_end(ap); + return fd; } int openat64(int dirfd, const char *path, int flags, ...) { + int fd; + int mode; + va_list ap; + va_start(ap, flags); + if (flags & O_CREAT) + { + mode = va_arg(ap, int); + } + fd = openat(dirfd, path, flags|O_LARGEFILE, mode); + va_end(ap); + return fd; } /* @@ -107,10 +154,6 @@ int openat64(int dirfd, const char *path, int flags, ...) */ int creat(const char *path, mode_t mode) { - if(!pvfs_lib_init) { - load_glibc(); - } - return open(path, O_CREAT|O_WRONLY|O_TRUNC, mode); } @@ -119,10 +162,6 @@ int creat(const char *path, mode_t mode) */ int creat64(const char *path, mode_t mode) { - if(!pvfs_lib_init) { - load_glibc(); - } - return open64(path, O_CREAT|O_WRONLY|O_TRUNC, mode); } @@ -131,25 +170,49 @@ int creat64(const char *path, mode_t mode) */ int unlink(const char *path) { - if (!pvfs_lib_init) { - load_glibc(); + if (!path) + { + errno = EFAULT; + return -1; } - if (is_pvfs_path(path)) { -#ifdef DEBUG - pvfs_debug("unlink: calling pvfs_unlink\n"); -#endif + if (is_pvfs_path(path)) + { return pvfs_ops.unlink(path); } - else { -#ifdef DEBUG - pvfs_debug("unlink: calling glibc_ops.unlink\n"); -#endif + else + { return glibc_ops.unlink(path); } } -int unlinkat(int dirfd, const char *path) +int unlinkat(int dirfd, const char *path, int flag) { + int rc = 0; + pvfs_descriptor *pd; + + if (!path) + { + errno = EFAULT; + return -1; + } + if (dirfd == AT_FDCWD || path[0] == '/') + { + unlink(path); + } + else + { + pd = pvfs_find_descriptor(dirfd); + if (pd) + { + rc = pd->fsops->unlinkat(pd->true_fd, path, flag); + } + else + { + errno = EBADF; + rc = -1; + } + } + return rc; } /* @@ -157,6 +220,53 @@ int unlinkat(int dirfd, const char *path) */ int rename (const char *old, const char *new) { + int oldp, newp; + if (!old || !new) + { + errno = EFAULT; + return -1; + } + oldp = is_pvfs_path(old); + newp = is_pvfs_path(new); + if(oldp && newp) + { + return pvfs_rename(old, new); + } + else if (!oldp && !newp) + { + return glibc_ops.rename(old, new); + } + else + { + errno = EXDEV; + return -1; + } +} + +int renameat (int oldfd, const char *old, int newfd, const char *new) +{ + pvfs_descriptor *oldpd, *newpd; + oldpd = pvfs_find_descriptor(oldfd); + newpd = pvfs_find_descriptor(newfd); + if (!old || !new) + { + errno = EFAULT; + return -1; + } + if (!oldpd || !newpd) + { + errno = EBADF; + return -1; + } + if (oldpd->fsops == newpd->fsops) + { + return oldpd->fsops->renameat(oldpd->true_fd, old, newpd->true_fd, new); + } + else + { + errno = EXDEV; + return -1; + } } /* READING and WRITING SYSTEM CALL */ @@ -166,111 +276,122 @@ int rename (const char *old, const char *new) */ ssize_t read(int fd, void *buf, size_t count) { - ssize_t rc; + ssize_t rc = 0; pvfs_descriptor *pd; pd = pvfs_find_descriptor(fd); if (pd) { - rc = pd->fsops->read(fd, buf, count); - if (rc > 0) - pd->file_pointer += rc; + rc = pd->fsops->read(pd->true_fd, buf, count); } else { - errno = EINVAL; + errno = EBADF; rc = -1; } return rc; } /* - * write wrapper + * pread wrapper */ -ssize_t write(int fd, const void *buf, size_t count) +ssize_t pread(int fd, void *buf, size_t nbytes, off_t offset) { - ssize_t rc; + ssize_t rc = 0; pvfs_descriptor *pd; - pd = pvfs_find_descriptor(fd); + pd = pvfs_find_descriptor(fd); if (pd) { - rc = pd->fsops->write(fd, (void *)buf, count); - if (rc > 0) - pd->file_pointer += rc; + rc = pd->fsops->pread(pd->true_fd, (void *)buf, nbytes, offset); + } + else + { + errno = EBADF; + rc = -1; + } + return rc; +} + +/* + * readv wrapper + */ +ssize_t readv(int fd, const struct iovec *iov, int iovcnt) +{ + ssize_t rc = 0; + pvfs_descriptor *pd; + + pd = pvfs_find_descriptor(fd); + if (pd) + { + rc = pd->fsops->readv(pd->true_fd, iov, iovcnt); } else { - errno = EINVAL; + errno = EBADF; rc = -1; } return rc; } /* - * write wrapper + * pread64 wrapper */ -ssize_t pread(int fd, void *buf, size_t nbytes, off_t offset) +ssize_t pread64(int fd, void *buf, size_t nbytes, off64_t offset) { - ssize_t rc; + ssize_t rc = 0; pvfs_descriptor *pd; pd = pvfs_find_descriptor(fd); if (pd) { - rc = pd->fsops->pread(fd, (void *)buf, nbytes, offset); - if (rc > 0) - pd->file_pointer += rc; + rc = pd->fsops->pread64(pd->true_fd, (void *)buf, nbytes, offset); } else { - errno = EINVAL; + errno = EBADF; rc = -1; } return rc; -} +} /* * write wrapper */ -ssize_t pwrite(int fd, const void *buf, size_t nbytes, off_t offset) +ssize_t write(int fd, const void *buf, size_t count) { - ssize_t rc; - pvfs_descriptor *pd; + ssize_t rc = 0; + pvfs_descriptor *pd; pd = pvfs_find_descriptor(fd); if (pd) { - rc = pd->fsops->pwrite(fd, buf, nbytes, offset); - if (rc > 0) - pd->file_pointer += rc; + rc = pd->fsops->write(pd->true_fd, (void *)buf, count); } else { - errno = EINVAL; + errno = EBADF; rc = -1; } return rc; } /* - * write wrapper + * pwrite wrapper */ -ssize_t readv(int fd, const struct iovec *iov, int iovcnt) -{ - ssize_t rc; - pvfs_descriptor *pd; +ssize_t pwrite(int fd, const void *buf, size_t nbytes, off_t offset) +{ + ssize_t rc = 0; + pvfs_descriptor *pd; - pd = pvfs_find_descriptor(fd); + pd = pvfs_find_descriptor(fd); if (pd) { - rc = pd->fsops->readv(fd, iov, iovcnt); - if (rc > 0) - pd->file_pointer += rc; + rc = pd->fsops->pwrite(pd->true_fd, buf, nbytes, offset); } else { - errno = EINVAL; + errno = EBADF; rc = -1; } return rc; @@ -281,7 +402,7 @@ ssize_t readv(int fd, const struct iovec *iov, int iovcnt) */ ssize_t writev(int fd, const struct iovec *iov, int iovcnt) { - ssize_t rc; + ssize_t rc = 0; pvfs_descriptor *pd; pd = pvfs_find_descriptor(fd); @@ -293,7 +414,28 @@ ssize_t writev(int fd, const struct iovec *iov, int iovcnt) } else { - errno = EINVAL; + errno = EBADF; + rc = -1; + } + return rc; +} + +/* + * pwrite64 wrapper + */ +ssize_t pwrite64(int fd, const void *buf, size_t nbytes, off64_t offset) +{ + ssize_t rc = 0; + pvfs_descriptor *pd; + + pd = pvfs_find_descriptor(fd); + if (pd) + { + rc = pd->fsops->pwrite64(pd->true_fd, buf, nbytes, offset); + } + else + { + errno = EBADF; rc = -1; } return rc; @@ -307,9 +449,9 @@ ssize_t writev(int fd, const struct iovec *iov, int iovcnt) off_t lseek(int fd, off_t offset, int whence) { off64_t rc = lseek64(fd, (off64_t)offset, whence); - if (rc & 0xffffffff00000000) + if (rc & 0xffffffff00000000LLU) { - errno = EINVAL; + errno = EFAULT; rc = -1; } return (off_t)rc; @@ -320,15 +462,13 @@ off_t lseek(int fd, off_t offset, int whence) */ off64_t lseek64(int fd, off64_t offset, int whence) { - off64_t rc; + off64_t rc = 0; pvfs_descriptor *pd; pd = pvfs_find_descriptor(fd); if (pd) { - rc = pd->fsops->lseek64(fd, offset, whence); - if (rc != -1) - pd->file_pointer = rc; + rc = pd->fsops->lseek64(pd->true_fd, offset, whence); } else { @@ -340,49 +480,131 @@ off64_t lseek64(int fd, off64_t offset, int whence) int truncate(const char *path, off_t length) { + if (!path) + { + errno = EFAULT; + return -1; + } + if(is_pvfs_path(path)) + { + return pvfs_truncate(path, length); + } + else + { + return glibc_ops.truncate(path, length); + } } int truncate64(const char *path, off64_t length) { + if (!path) + { + errno = EFAULT; + return -1; + } + if(is_pvfs_path(path)) + { + return pvfs_truncate64(path, length); + } + else + { + return glibc_ops.truncate64(path, length); + } } int ftruncate(int fd, off_t length) { + int rc = 0; + pvfs_descriptor *pd; + + pd = pvfs_find_descriptor(fd); + if (pd) + { + rc = pd->fsops->ftruncate(pd->true_fd, length); + } + else + { + errno = EBADF; + rc = (off64_t)-1; + } + return rc; } int ftruncate64(int fd, off64_t length) { + int rc = 0; + pvfs_descriptor *pd; + + pd = pvfs_find_descriptor(fd); + if (pd) + { + rc = pd->fsops->ftruncate64(pd->true_fd, length); + } + else + { + errno = EBADF; + rc = (off64_t)-1; + } + return rc; } -/* - * close wrapper - */ -int close(int fd) +#ifdef _XOPEN_SOURCE +int posix_fallocate(int fd, off_t offset, off_t length) { + int rc = 0; pvfs_descriptor *pd; pd = pvfs_find_descriptor(fd); if (pd) { - pd->fsops->flush(pd->posix_fd); - pd->fsops->close(pd->posix_fd); - pvfs_free_descriptor(pd); - return 0; + rc = pd->fsops->fallocate(pd->true_fd, offset, length); } else { errno = EBADF; - return -1; + rc = (off64_t)-1; } + return rc; +} +#endif + +/* + * close wrapper + */ +int close(int fd) +{ + int rc = 0; + + rc = pvfs_free_descriptor(fd); + return rc; } int flush(int fd) { + int rc = 0; + pvfs_descriptor *pd; + + pd = pvfs_find_descriptor(fd); + if (pd) + { + rc = pd->fsops->flush(pd->true_fd); + } + else + { + errno = EBADF; + rc = (off64_t)-1; + } + return rc; } /* various flavors of stat */ int stat(const char *path, struct stat *buf) { + if (!path || !buf) + { + errno = EFAULT; + return -1; + } if(is_pvfs_path(path)) { return pvfs_stat(path, buf); @@ -400,6 +622,11 @@ int __xstat(int ver, const char *path, struct stat *buf) int stat64(const char *path, struct stat64 *buf) { + if (!path || !buf) + { + errno = EFAULT; + return -1; + } if(is_pvfs_path(path)) { return pvfs_stat64(path, buf); @@ -417,17 +644,17 @@ int __xstat64(int ver, const char *path, struct stat64 *buf) int fstat(int fd, struct stat *buf) { - int rc; + int rc = 0; pvfs_descriptor *pd; pd = pvfs_find_descriptor(fd); if (pd) { - rc = pd->fsops->fstat(pd->posix_fd, buf); + rc = pd->fsops->fstat(pd->true_fd, buf); } else { - errno = EINVAL; + errno = EBADF; rc = -1; } return rc; @@ -440,17 +667,17 @@ int __fxstat(int ver, int fd, struct stat *buf) int fstat64(int fd, struct stat64 *buf) { - int rc; + int rc = 0; pvfs_descriptor *pd; pd = pvfs_find_descriptor(fd); if (pd) { - rc = pd->fsops->fstat64(pd->posix_fd, buf); + rc = pd->fsops->fstat64(pd->true_fd, buf); } else { - errno = EINVAL; + errno = EBADF; rc = -1; } return rc; @@ -461,168 +688,1286 @@ int __fxstat64(int ver, int fd, struct stat64 *buf) return fstat64(fd, buf); } -int lstat(const char *path, struct stat *buf) +int fstatat(int fd, const char *path, struct stat *buf, int flag) { - if(is_pvfs_path(path)) - { - return pvfs_lstat(path, buf); - } - else + int rc = 0; + pvfs_descriptor *pd; + + if (fd == AT_FDCWD || path[0] == '/') + { + if (flag & AT_SYMLINK_NOFOLLOW) + { + lstat(path, buf); + } + else + { + stat(path, buf); + } + } + else + { + pd = pvfs_find_descriptor(fd); + if (pd) + { + rc = pd->fsops->fstatat(pd->true_fd, path, buf, flag); + } + else + { + errno = EBADF; + rc = -1; + } + } + return rc; +} + +int __fxstatat(int ver, int fd, const char *path, struct stat *buf, int flag) +{ + return fstatat(fd, path, buf, flag); +} + +int fstatat64(int fd, const char *path, struct stat64 *buf, int flag) +{ + int rc = 0; + pvfs_descriptor *pd; + + if (fd == AT_FDCWD || path[0] == '/') + { + if (flag & AT_SYMLINK_NOFOLLOW) + { + lstat64(path, buf); + } + else + { + stat64(path, buf); + } + } + else + { + pd = pvfs_find_descriptor(fd); + if (pd) + { + rc = pd->fsops->fstatat64(pd->true_fd, path, buf, flag); + } + else + { + errno = EBADF; + rc = -1; + } + } + return rc; +} + +int __fxstatat64(int ver, int fd, const char *path, struct stat64 *buf, int flag) +{ + return fstatat64(fd, path, buf, flag); +} + +int lstat(const char *path, struct stat *buf) +{ + if (!path || !buf) + { + errno = EFAULT; + return -1; + } + if(is_pvfs_path(path)) + { + return pvfs_lstat(path, buf); + } + else + { + return glibc_ops.lstat(path, buf); + } +} + +int __lxstat(int ver, const char *path, struct stat *buf) +{ + return lstat(path, buf); +} + +int lstat64(const char *path, struct stat64 *buf) +{ + if (!path || !buf) + { + errno = EFAULT; + return -1; + } + if(is_pvfs_path(path)) + { + return pvfs_lstat64(path, buf); + } + else + { + return glibc_ops.lstat64(path, buf); + } +} + +int __lxstat64(int ver, const char *path, struct stat64 *buf) +{ + return lstat64(path, buf); +} + +int dup(int oldfd) +{ + int rc = 0; + pvfs_descriptor *pd; + + pd = pvfs_find_descriptor(oldfd); + if (pd) + { + rc = pd->fsops->dup(pd->true_fd); + } + else + { + errno = EBADF; + rc = -1; + } + return rc; +} + +int dup2(int oldfd, int newfd) +{ + int rc = 0; + pvfs_descriptor *pd; + + pd = pvfs_find_descriptor(oldfd); + if (pd) + { + rc = pd->fsops->dup2(pd->true_fd, newfd); + } + else + { + errno = EBADF; + rc = -1; + } + return rc; +} + +int chown(const char *path, uid_t owner, gid_t group) +{ + if (!path) + { + errno = EFAULT; + return -1; + } + if(is_pvfs_path(path)) + { + return pvfs_chown(path, owner, group); + } + else + { + return glibc_ops.chown(path, owner, group); + } +} + +int fchown(int fd, uid_t owner, gid_t group) +{ + int rc = 0; + pvfs_descriptor *pd; + + pd = pvfs_find_descriptor(fd); + if (pd) + { + rc = pd->fsops->fchown(pd->true_fd, owner, group); + } + else + { + errno = EBADF; + rc = -1; + } + return rc; +} + +int fchownat(int dirfd, const char *path, uid_t owner, gid_t group, int flag) +{ + int rc = 0; + pvfs_descriptor *pd; + + if (dirfd == AT_FDCWD || path[0] == '/') + { + chown(path, owner, group); + } + else + { + pd = pvfs_find_descriptor(dirfd); + if (pd) + { + rc = pd->fsops->fchownat(pd->true_fd, path, owner, group, flag); + } + else + { + errno = EBADF; + rc = -1; + } + } + return rc; +} + +int lchown(const char *path, uid_t owner, gid_t group) +{ + if (!path) + { + errno = EFAULT; + return -1; + } + if(is_pvfs_path(path)) + { + return pvfs_lchown(path, owner, group); + } + else + { + return glibc_ops.lchown(path, owner, group); + } +} + +int chmod(const char *path, mode_t mode) +{ + if (!path) + { + errno = EFAULT; + return -1; + } + if(is_pvfs_path(path)) + { + return pvfs_chmod(path, mode); + } + else + { + return glibc_ops.chmod(path, mode); + } +} + +int fchmod(int fd, mode_t mode) +{ + int rc = 0; + pvfs_descriptor *pd; + + pd = pvfs_find_descriptor(fd); + if (pd) + { + rc = pd->fsops->fchmod(pd->true_fd, mode); + } + else + { + errno = EBADF; + rc = -1; + } + return rc; +} + +int fchmodat(int dirfd, const char *path, mode_t mode, int flag) +{ + int rc = 0; + pvfs_descriptor *pd; + + if (!path) + { + errno = EFAULT; + return -1; + } + if (dirfd == AT_FDCWD || path[0] == '/') + { + chmod(path, mode); + } + else + { + pd = pvfs_find_descriptor(dirfd); + if (pd) + { + rc = pd->fsops->fchmodat(pd->true_fd, path, mode, flag); + } + else + { + errno = EBADF; + rc = -1; + } + } + return rc; +} + +int mkdir(const char *path, mode_t mode) +{ + if (!path) + { + errno = EFAULT; + return -1; + } + if(is_pvfs_path(path)) + { + return pvfs_mkdir(path, mode); + } + else + { + return glibc_ops.mkdir(path, mode); + } +} + +int mkdirat(int dirfd, const char *path, mode_t mode) +{ + int rc = 0; + pvfs_descriptor *pd; + + if (!path) + { + errno = EFAULT; + return -1; + } + if (dirfd == AT_FDCWD || path[0] == '/') + { + mkdir(path, mode); + } + else + { + pd = pvfs_find_descriptor(dirfd); + if (pd) + { + rc = pd->fsops->mkdirat(pd->true_fd, path, mode); + } + else + { + errno = EBADF; + rc = -1; + } + } + return rc; +} + +int rmdir(const char *path) +{ + if (!path) + { + errno = EFAULT; + return -1; + } + if(is_pvfs_path(path)) + { + return pvfs_rmdir(path); + } + else + { + return glibc_ops.rmdir(path); + } +} + +ssize_t readlink(const char *path, char *buf, size_t bufsiz) +{ + if (!path || !buf) + { + errno = EFAULT; + return -1; + } + if(is_pvfs_path(path)) + { + return pvfs_readlink(path, buf, bufsiz); + } + else + { + return glibc_ops.readlink(path, buf, bufsiz); + } +} + +int readlinkat(int dirfd, const char *path, char *buf, size_t bufsiz) +{ + int rc = 0; + pvfs_descriptor *pd; + + if (!path || !buf) + { + errno = EFAULT; + return -1; + } + if (dirfd == AT_FDCWD || path[0] == '/') + { + readlink(path, buf, bufsiz); + } + else + { + pd = pvfs_find_descriptor(dirfd); + if (pd) + { + rc = pd->fsops->readlinkat(pd->true_fd, path, buf, bufsiz); + } + else + { + errno = EBADF; + rc = -1; + } + } + return rc; +} + +int symlink(const char *oldpath, const char *newpath) +{ + if (!oldpath || !newpath) + { + errno = EFAULT; + return -1; + } + if(is_pvfs_path(newpath)) + { + return pvfs_symlink(oldpath, newpath); + } + else + { + return glibc_ops.symlink(oldpath, newpath); + } +} + +int symlinkat(const char *oldpath, int newdirfd, const char *newpath) +{ + int rc = 0; + pvfs_descriptor *pd; + + if (!oldpath || !newpath) + { + errno = EFAULT; + return -1; + } + if (newdirfd == AT_FDCWD || newpath[0] == '/') + { + symlink(oldpath, newpath); + } + else + { + pd = pvfs_find_descriptor(newdirfd); + if (pd) + { + rc = pd->fsops->symlinkat(oldpath, pd->true_fd, newpath); + } + else + { + errno = EBADF; + rc = -1; + } + } + return rc; +} + +ssize_t link(const char *oldpath, const char *newpath) +{ + if (!oldpath || !newpath) + { + errno = EFAULT; + return -1; + } + if(is_pvfs_path(oldpath)) + { + return pvfs_link(oldpath, newpath); + } + else + { + return glibc_ops.link(oldpath, newpath); + } + return -1; +} + +int linkat(int olddirfd, const char *old, + int newdirfd, const char *new, int flags) +{ + pvfs_descriptor *oldpd, *newpd; + oldpd = pvfs_find_descriptor(olddirfd); + newpd = pvfs_find_descriptor(newdirfd); + if (!old || !new) + { + errno = EFAULT; + return -1; + } + if (!oldpd || !newpd) + { + errno = EBADF; + return -1; + } + if (oldpd->fsops == newpd->fsops) + { + return oldpd->fsops->linkat(oldpd->true_fd, old, + newpd->true_fd, new, flags); + } + else + { + errno = EXDEV; + return -1; + } +} + +/** + * According to man page count is isgnored + */ +int posix_readdir(unsigned int fd, struct dirent *dirp, unsigned int count) +{ + int rc; + pvfs_descriptor *pd; + + if (!dirp) + { + errno = EFAULT; + return -1; + } + pd = pvfs_find_descriptor(fd); + if (pd) + { + rc = pd->fsops->readdir(pd->true_fd, dirp, count); + } + else + { + errno = EBADF; + rc = -1; + } + return rc; +} + +/** + * man page calls last arg count but is ambiguous if it is number + * of bytes or number of records to read. The former appears to be + * true thus we rename the argument + */ +int getdents(unsigned int fd, struct dirent *dirp, unsigned int size) +{ + int rc = 0; + pvfs_descriptor *pd; + + if (!dirp) + { + errno = EFAULT; + return -1; + } + pd = pvfs_find_descriptor(fd); + if (pd) + { + rc = pd->fsops->getdents(pd->true_fd, dirp, size); + } + else + { + errno = EBADF; + rc = -1; + } + return rc; +} + +int getdents64(unsigned int fd, struct dirent64 *dirp, unsigned int size) +{ + int rc = 0; + pvfs_descriptor *pd; + + if (!dirp) + { + errno = EFAULT; + return -1; + } + pd = pvfs_find_descriptor(fd); + if (pd) + { + rc = pd->fsops->getdents64(pd->true_fd, dirp, size); + } + else + { + errno = EBADF; + rc = -1; + } + return rc; +} + +/* linux discourages using readdir system calls, so for now + * we will leave them out - there are stdio calls that can + * be used + */ + +int access(const char *path, int mode) +{ + if (!path) + { + errno = EFAULT; + return -1; + } + if(is_pvfs_path(path)) + { + return pvfs_access(path, mode); + } + else + { + return glibc_ops.access(path, mode); + } +} + +int faccessat(int dirfd, const char *path, int mode, int flags) +{ + int rc = 0; + pvfs_descriptor *pd; + + if (!path) + { + errno = EFAULT; + return -1; + } + if (dirfd == AT_FDCWD || path[0] == '/') + { + access(path, mode); + } + else + { + pd = pvfs_find_descriptor(dirfd); + if (pd) + { + rc = pd->fsops->faccessat(pd->true_fd, path, mode, flags); + } + else + { + errno = EBADF; + rc = -1; + } + } + return rc; +} + +int flock(int fd, int op) +{ + int rc = 0; + pvfs_descriptor *pd; + + pd = pvfs_find_descriptor(fd); + if (pd) + { + rc = pd->fsops->flock(pd->true_fd, op); + } + else + { + errno = EBADF; + rc = -1; + } + return rc; +} + +int fcntl(int fd, int cmd, ...) +{ + int rc = 0; + long arg; + struct flock *lock; + pvfs_descriptor *pd; + va_list ap; + + va_start(ap, cmd); + pd = pvfs_find_descriptor(fd); + if (pd) + { + switch (cmd) + { + case F_GETLK: + case F_SETLK: + case F_SETLKW: + lock = va_arg(ap, struct flock *); + rc = pd->fsops->fcntl(pd->true_fd, cmd, lock); + break; + default: + arg = va_arg(ap, long); + rc = pd->fsops->fcntl(pd->true_fd, cmd, arg); + break; + } + } + else + { + errno = EBADF; + rc = -1; + } + va_end(ap); + return rc; +} + +void sync(void) +{ + pvfs_sync(); + glibc_ops.sync(); +} + +int fsync(int fd) +{ + int rc = 0; + pvfs_descriptor *pd; + + pd = pvfs_find_descriptor(fd); + if (pd) + { + rc = pd->fsops->fsync(pd->true_fd); + } + else + { + errno = EBADF; + rc = -1; + } + return rc; +} + +int fdatasync(int fd) +{ + int rc = 0; + pvfs_descriptor *pd; + + pd = pvfs_find_descriptor(fd); + if (pd) + { + rc = pd->fsops->fdatasync(pd->true_fd); + } + else { - return glibc_ops.lstat(path, buf); + errno = EBADF; + rc = -1; } + return rc; } -int __lxstat(int ver, const char *path, struct stat *buf) -{ - return lstat(path, buf); -} - -int lstat64(const char *path, struct stat64 *buf) +int posix_fadvise(int fd, off_t offset, off_t length, int advice) { - if(is_pvfs_path(path)) - { - return pvfs_lstat64(path, buf); + int rc = 0; + pvfs_descriptor *pd; + + pd = pvfs_find_descriptor(fd); + if (pd) + { + rc = pd->fsops->fadvise(pd->true_fd, offset, length, advice); } else { - return glibc_ops.lstat64(path, buf); + errno = EBADF; + rc = -1; } + return rc; } -int __lxstat64(int ver, const char *path, struct stat64 *buf) +int fadvise(int fd, off_t offset, off_t len, int advice) { - return lstat64(path, buf); + int rc = 0; + pvfs_descriptor *pd; + + pd = pvfs_find_descriptor(fd); + if (pd) + { + rc = pd->fsops->fadvise(pd->true_fd, offset, len, advice); + } + else + { + errno = EBADF; + rc = -1; + } + return rc; } -#if 0 -int dup() +int fadvise64(int fd, off64_t offset, off64_t len, int advice) { + int rc = 0; + pvfs_descriptor *pd; + + pd = pvfs_find_descriptor(fd); + if (pd) + { + rc = pd->fsops->fadvise64(pd->true_fd, offset, len, advice); + } + else + { + errno = EBADF; + rc = -1; + } + return rc; } -int dup2() +int statfs(const char *path, struct statfs *buf) { + if (!path || !buf) + { + errno = EFAULT; + return -1; + } + if(is_pvfs_path(path)) + { + return pvfs_statfs(path, buf); + } + else + { + return glibc_ops.statfs(path, buf); + } } -int chown() +int statfs64(const char *path, struct statfs64 *buf) { + if (!path || !buf) + { + errno = EFAULT; + return -1; + } + if(is_pvfs_path(path)) + { + return pvfs_statfs64(path, buf); + } + else + { + return glibc_ops.statfs64(path, buf); + } } -int fchown() +int fstatfs(int fd, struct statfs *buf) { + int rc = 0; + pvfs_descriptor *pd; + + if (!buf) + { + errno = EFAULT; + return -1; + } + pd = pvfs_find_descriptor(fd); + if (pd) + { + rc = pd->fsops->fstatfs(pd->true_fd, buf); + } + else + { + errno = EBADF; + rc = -1; + } + return rc; } -int fchownat() +int fstatfs64(int fd, struct statfs64 *buf) { + int rc = 0; + pvfs_descriptor *pd; + + if (!buf) + { + errno = EFAULT; + return -1; + } + pd = pvfs_find_descriptor(fd); + if (pd) + { + rc = pd->fsops->fstatfs64(pd->true_fd, buf); + } + else + { + errno = EBADF; + rc = -1; + } + return rc; } -int lchown() +int mknod(const char *path, mode_t mode, dev_t dev) { + if (!path) + { + errno = EFAULT; + return -1; + } + if(is_pvfs_path(path)) + { + return pvfs_mknod(path, mode, dev); + } + else + { + return glibc_ops.mknod(path, mode, dev); + } } -int chmod() -{ +int mknodat(int dirfd, const char *path, mode_t mode, dev_t dev) +{ + int rc = 0; + pvfs_descriptor *pd; + + if (!path) + { + errno = EFAULT; + return -1; + } + if (dirfd == AT_FDCWD || path[0] == '/') + { + mknod(path, mode, dev); + } + else + { + pd = pvfs_find_descriptor(dirfd); + if (pd) + { + rc = pd->fsops->mknodat(pd->true_fd, path, mode, dev); + } + else + { + errno = EBADF; + rc = -1; + } + } + return rc; } -int fchmod() +ssize_t sendfile(int outfd, int infd, off_t *offset, size_t count) { + return sendfile64(outfd, infd, (off64_t *)offset, count); } -int fchmodat() +ssize_t sendfile64(int outfd, int infd, off64_t *offset, size_t count) { + int rc = 0; + pvfs_descriptor *inpd, *outpd; + + inpd = pvfs_find_descriptor(infd); + outpd = pvfs_find_descriptor(outfd); + if (inpd && outpd) + { + rc = inpd->fsops->sendfile64(outpd->true_fd, inpd->true_fd, + offset, count); + } + else + { + errno = EBADF; + rc = -1; + } + return rc; } -int lchmod() +int setxattr(const char *path, const char *name, + const void *value, size_t size, int flags) { + if (!path) + { + errno = EFAULT; + return -1; + } + if(is_pvfs_path(path)) + { + return pvfs_setxattr(path, name, value, size, flags); + } + else + { + if (glibc_ops.setxattr) + { + return glibc_ops.setxattr(path, name, value, size, flags); + } + else + { + errno = ENOPKG; + return -1; + } + } } -int mkdir() +int lsetxattr(const char *path, const char *name, + const void *value, size_t size, int flags) { + if (!path) + { + errno = EFAULT; + return -1; + } + if(is_pvfs_path(path)) + { + return pvfs_lsetxattr(path, name, value, size, flags); + } + else + { + if (glibc_ops.lsetxattr) + { + return glibc_ops.lsetxattr(path, name, value, size, flags); + } + else + { + errno = ENOPKG; + return -1; + } + } } -int mdirat() +int fsetxattr(int fd, const char *name, + const void *value, size_t size, int flags) { + int rc = 0; + pvfs_descriptor *pd; + + pd = pvfs_find_descriptor(fd); + if (pd) + { + if (pd->fsops->fsetxattr) + { + rc = pd->fsops->fsetxattr(pd->true_fd, name, value, size, flags); + } + else + { + errno = ENOPKG; + rc = -1; + } + } + else + { + errno = EBADF; + rc = -1; + } + return rc; } -int rmdir() +int getxattr(const char *path, const char *name, + void *value, size_t size) { + if (!path) + { + errno = EFAULT; + return -1; + } + if(is_pvfs_path(path)) + { + return pvfs_getxattr(path, name, value, size); + } + else + { + if (glibc_ops.getxattr) + { + return glibc_ops.getxattr(path, name, value, size); + } + else + { + errno = ENOPKG; + return -1; + } + } } -ssize_t readlink() +int lgetxattr(const char *path, const char *name, + void *value, size_t size) { + if (!path) + { + errno = EFAULT; + return -1; + } + if(is_pvfs_path(path)) + { + return pvfs_lgetxattr(path, name, value, size); + } + else + { + if (glibc_ops.lgetxattr) + { + return glibc_ops.lgetxattr(path, name, value, size); + } + else + { + errno = ENOPKG; + return -1; + } + } } -int readlinkat() +int fgetxattr(int fd, const char *name, void *value, + size_t size) { + int rc = 0; + pvfs_descriptor *pd; + + pd = pvfs_find_descriptor(fd); + if (pd) + { + if (pd->fsops->fgetxattr) + { + rc = pd->fsops->fgetxattr(pd->true_fd, name, value, size); + } + else + { + errno = ENOPKG; + rc = -1; + } + } + else + { + errno = EBADF; + rc = -1; + } + return rc; } -ssize_t symlink() +int listxattr(const char *path, char *list, size_t size) { + if (!path) + { + errno = EFAULT; + return -1; + } + if(is_pvfs_path(path)) + { + return pvfs_listxattr(path, list, size); + } + else + { + if (glibc_ops.listxattr) + { + return glibc_ops.listxattr(path, list, size); + } + else + { + errno = ENOPKG; + return -1; + } + } } -int symlinkat() +int llistxattr(const char *path, char *list, size_t size) { + if (!path) + { + errno = EFAULT; + return -1; + } + if(is_pvfs_path(path)) + { + return pvfs_llistxattr(path, list, size); + } + else + { + if (glibc_ops.llistxattr) + { + return glibc_ops.llistxattr(path, list, size); + } + else + { + errno = ENOPKG; + return -1; + } + } } -ssize_t link() +int flistxattr(int fd, char *list, size_t size) { + int rc = 0; + pvfs_descriptor *pd; + + pd = pvfs_find_descriptor(fd); + if (pd) + { + if (pd->fsops->flistxattr) + { + rc = pd->fsops->flistxattr(pd->true_fd, list, size); + } + else + { + errno = ENOPKG; + rc = -1; + } + } + else + { + errno = EBADF; + rc = -1; + } + return rc; } -int linkat() +int removexattr(const char *path, const char *name) { + if (!path) + { + errno = EFAULT; + return -1; + } + if(is_pvfs_path(path)) + { + return pvfs_removexattr(path, name); + } + else + { + if (glibc_ops.removexattr) + { + return glibc_ops.removexattr(path, name); + } + else + { + errno = ENOPKG; + return -1; + } + } } -#endif - -/* linux discourages using readdir system calls, so for now - * we will leave them out - there are stdio calls that can - * be used - */ - -#if 0 - -int access (int fd, int op) +int lremovexattr(const char *path, const char *name) { + if (!path) + { + errno = EFAULT; + return -1; + } + if(is_pvfs_path(path)) + { + return pvfs_lremovexattr(path, name); + } + else + { + if (glibc_ops.lremovexattr) + { + return glibc_ops.lremovexattr(path, name); + } + else + { + errno = ENOPKG; + return -1; + } + } } -int faccessat (int fd, int op) +int fremovexattr(int fd, const char *name) { + int rc = 0; + pvfs_descriptor *pd; + + pd = pvfs_find_descriptor(fd); + if (pd) + { + if (pd->fsops->fremovexattr) + { + rc = pd->fsops->fremovexattr(pd->true_fd, name); + } + else + { + errno = ENOPKG; + rc = -1; + } + } + else + { + errno = EBADF; + rc = -1; + } + return rc; } -int flock (int fd, int op) +int chdir(const char *path) { + return pvfs_chdir(path); } -int fcntl (int fd, int op) +int fchdir(int fd) { + return pvfs_fchdir(fd); } -int sync (int fd, int op) +char *getcwd(char *buf, size_t size) { + return pvfs_getcwd(buf, size); } -int fsync (int fd, int op) +char *get_current_dir_name(void) { + return pvfs_get_current_dir_name(); } -int fdatasync (int fd, int op) +char *getwd(char *buf) { + return pvfs_getwd(buf); } -int umask (int fd, int op) +mode_t umask(mode_t mask) { + return pvfs_umask(mask); } -int getumask (int fd, int op) +mode_t getumask(void) { + return pvfs_getumask(); } -int getdtablesize (int fd, int op) +int getdtablesize(void) { + return pvfs_getdtablesize(); } -#endif - /* * Local variables: * c-indent-level: 4 diff --git a/src/client/usrint/stdio.c b/src/client/usrint/stdio.c index a77cdef..770aeaf 100644 --- a/src/client/usrint/stdio.c +++ b/src/client/usrint/stdio.c @@ -1,40 +1,159 @@ -#include -#include +/* + * (C) 2011 Clemson University and The University of Chicago + * + * See COPYING in top-level directory. + */ + +/** \file + * \ingroup usrint + * + * PVFS2 user interface routines - implementation of stdio for pvfs + */ +/* this prevents headers from using inlines for 64 bit calls */ +#define USRINT_SOURCE 1 +#include "usrint.h" +#include "openfile-util.h" +#include "stdio-ops.h" + +#define STDIO_DEBUG 0 + +static void init_stdio(void); +static struct stdio_ops_s stdio_ops; +static FILE open_files = {._chain = NULL}; + +#define _P_IO_MAGIC 0xF0BD0000 +#define SETMAGIC(s,m) do{(s)->_flags = (m) & _IO_MAGIC_MASK;}while(0) +#define ISMAGICSET(s,m) (((s)->_flags & _IO_MAGIC_MASK) == (m)) +#define SETFLAG(s,f) do{(s)->_flags |= ((f) & ~_IO_MAGIC_MASK);}while(0) +#define CLEARFLAG(s,f) do{(s)->_flags &= ~((f) & ~_IO_MAGIC_MASK);}while(0) +#define ISFLAGSET(s,f) (((s)->_flags & (f)) == (f)) /* STDIO implementation - this gives users something to link to * that will call back to the PVFS lib - also lets us optimize * in a few spots like buffer sizes and stuff */ +/** struct representing a directory stream for buffered dir io + * + * this struct type is undefined in /usr/include as it is opaque + * it is defined in this file only. This design is based loosely + * on the buffered IO scheme used in Linux for files. + */ +struct __dirstream { + int _flags; /**< general flags field */ + int fileno; /**< file dscriptor of open dir */ + struct dirent de; /**< pointer to dirent read by readdir */ + char *buf_base; /**< pointer to beginning of buffer */ + char *buf_end; /**< pointer to end of buffer */ + char *buf_act; /**< pointer to end of active portion of buffer */ + char *buf_ptr; /**< pointer to current position in buffer */ +}; + +#define DIRSTREAM_MAGIC 0xFD100000 +#define PVFS_RLDC PVFS_REQ_LIMIT_DIRENT_COUNT +#define MAXDIRENT (PVFS_RLDC < 512 ? PVFS_RLDC : 512) +#define MAXBUFSIZE (MAXDIRENT * sizeof(struct dirent64)) +#define DIRBUFSIZE ((MAXBUFSIZE / 1024) * 1024) +#define ASIZE 256 +#define MAXTRIES 16 /* arbitrary - how many tries to get a unique file name */ + +/** These functions lock and unlock the stream structure + * + * These are only called within our library, so we assume that the + * stream is good, that it is our stream (and not glibc's) and we + * check for the flag to see if the lock is being used. + */ -/* - *fopen wrapper - */ +static inline void lock_init_stream(FILE *stream) +{ +#ifdef _IO_MTSAFE_IO + if (ISFLAGSET(stream, _IO_USER_LOCK)) + { + _IO_lock_init(stream->_lock); + } +#endif +} -FILE *fopen(const char * path, const char * mode) -{ - int flags = 0, fd = 0; - mode_t perm = 0; - pvfs_descriptor *pd = NULL; - const char *p = NULL; +static inline void lock_stream(FILE *stream) +{ +#ifdef _IO_MTSAFE_IO + if (ISFLAGSET(stream, _IO_USER_LOCK)) + { + _IO_lock_lock(stream->_lock); + } +#endif +} + +static inline int trylock_stream(FILE *stream) +{ +#ifdef _IO_MTSAFE_IO + if (ISFLAGSET(stream, _IO_USER_LOCK)) + { + return _IO_lock_try(stream->_lock); + } +#else + return 0; +#endif +} + +static inline void unlock_stream(FILE *stream) +{ +#ifdef _IO_MTSAFE_IO + if (ISFLAGSET(stream, _IO_USER_LOCK)) + { + _IO_lock_unlock(stream->_lock); + } +#endif +} + +static inline void lock_fini_stream(FILE *stream) +{ +#ifdef _IO_MTSAFE_IO + if (ISFLAGSET(stream, _IO_USER_LOCK)) + { + _IO_lock_fini(stream->_lock); + } +#endif +} + +/** POSIX interface for user level locking of streams *. + * + */ +void flockfile(FILE *stream) +{ + lock_stream(stream); +} + +int ftrylockfile(FILE *stream) +{ + return trylock_stream(stream); +} + +void funlockfile(FILE *stream) +{ + unlock_stream(stream); +} + +/** This function coverts from stream style mode to ssycall style flags + * + */ +static int mode2flags(const char *mode) +{ + int i = 0; + int flags = 0; int append = false, read = false, write = false, update = false; int exclusive = false; - if(!pvfs_lib_init) - { - load_glibc(); - } - /* look for fopen modes */ - for(p = mode; *p; p++) + for(i = 0; mode[i]; i++) { - switch(*p) { + switch(mode[i]) { case 'a': append = true; if (read || write) { errno = EINVAL; - return NULL; + return -1; } break; case 'r': @@ -42,7 +161,7 @@ FILE *fopen(const char * path, const char * mode) if (append || write) { errno = EINVAL; - return NULL; + return -1; } break; case 'w': @@ -50,7 +169,7 @@ FILE *fopen(const char * path, const char * mode) if (read || append) { errno = EINVAL; - return NULL; + return -1; } break; case '+': @@ -58,7 +177,7 @@ FILE *fopen(const char * path, const char * mode) if (!(read || write || append)) { errno = EINVAL; - return NULL; + return -1; } break; case 'b': /* this is ignored in POSIX */ @@ -70,12 +189,12 @@ FILE *fopen(const char * path, const char * mode) if (!(read || write || append)) { errno = EINVAL; - return NULL; + return -1; } break; default: errno = EINVAL; - return NULL; + return -1; break; } } @@ -83,779 +202,2096 @@ FILE *fopen(const char * path, const char * mode) if (!(read || write || append)) { errno = EINVAL; - return NULL; - } - if (read) - { - flags = O_RDONLY; + return -1; } - else if(read && update) + if (read && update) { flags = O_RDWR; } - else if(write) + else if(read) { - flags = O_WRONLY | O_CREAT | O_TRUNC; - } + flags = O_RDONLY; + } else if(write && update) { flags = O_RDWR | O_CREAT | O_TRUNC; + } + else if(write) + { + flags = O_WRONLY | O_CREAT | O_TRUNC; } - else if(append) + else if(append && update) { - flags = O_WRONLY | O_APPEND | O_CREAT; + flags = O_RDWR | O_APPEND | O_CREAT; } - else if (append && update) + else if (append) { - flags = O_RDWR | O_APPEND | O_CREAT; + flags = O_WRONLY | O_APPEND | O_CREAT; } if (exclusive) /* check this regardless of the above */ { flags |= O_EXCL; } - - /* this is our version of open */ - fd = open(path, flags, 0666); + return flags; +} + +/** + * fopen opens a file, then adds a stream to it + */ +FILE *fopen(const char * path, const char * mode) +{ + int fd = 0; + int flags = 0; + FILE *newfile = NULL; - if(fd) - { - pd = pvfs_find_descriptor(fd); - /* set up buffering here */ - pd->bufsize = pd->fsops->buffsize(); - pd->buf = malloc(pd->bufsize); - pd->buftotal = 0; - pd->buf_off = 0; - pd->bufptr = 0; - return PFILE2FILE(pd); + flags = mode2flags(mode); + if (flags == -1) + { + return NULL; } - else - { - pvfs_debug("pvfs call to open failed\n"); - return NULL; + + fd = open(path, flags, 0666); + if (fd == -1) + { + return NULL; } -} -FILE *fdopen(int fd, const char *mode) -{ - pvfs_descriptor *pd; - pd = pvfs_find_descriptor(fd); - /* check for valid mode here */ - /* set up buffering here */ - return PFILE2FILE(pd); + newfile = fdopen(fd, mode); + + return newfile; } -FILE *freopen(const char *path, const char *mode, FILE *stream) +/** this function sets up a new stream's buffer area + * + */ +static int init_stream (FILE *stream, int flags, int bufsize) { - pvfs_descriptor *pd = FILE2PFILE(stream) - /* see if stream is in use - if so close the file */ - /* open the file and put its info in the given descriptor */ - return PFILE2FILE(pd); + /* set up stream here */ + SETMAGIC(stream, _P_IO_MAGIC); + if (!(flags & O_WRONLY)) + SETFLAG(stream, _IO_NO_READS); + if (!(flags & O_RDONLY)) + SETFLAG(stream, _IO_NO_WRITES); + /* set up default buffering here */ + stream->_IO_buf_base = (char *)malloc(bufsize); + if (!stream->_IO_buf_base) + { + return -1; + } + stream->_IO_buf_end = stream->_IO_buf_base + bufsize; + stream->_IO_read_base = stream->_IO_buf_base; + stream->_IO_read_ptr = stream->_IO_buf_base; + stream->_IO_read_end = stream->_IO_buf_base; + stream->_IO_write_base = stream->_IO_buf_base; + stream->_IO_write_ptr = stream->_IO_buf_base; + stream->_IO_write_end = stream->_IO_buf_end; + lock_stream(&open_files); + stream->_chain = open_files._chain; + open_files._chain = stream; + unlock_stream(&open_files); + return 0; } -/* - * fwrite wrapper +/** + * fdopen adds a stream to an existing open file */ -size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream) +FILE *fdopen(int fd, const char *mode) { - off64_t rsz, rstart, rend; - off64_t firstblk, firstoff, firstsize; - off64_t lastblk, lastoff, lastsize; - off64_t curblk, numblk; + int rc = 0; + FILE *newfile = NULL; + int flags; - if (!stream || !stream->is_in_use || !ptr) { - errno = EBADF; - return 0; - } - /* rsz: request size in bytes */ - rsz = size * nmemb; - /* rstart: first byte of request */ - rstart = stream->file_pointer; - /* rend: last byte of request */ - rend = rstart + rsz - 1; + /* need to check for valid mode here */ + /* it must be compatible with the existing mode */ + flags = mode2flags(mode); - /* file is divided into blocks from 0..N-1 */ - /* curblk: block number of current buffer */ - if (stream->buf_off == -1) + newfile = (FILE *)malloc(sizeof(FILE)); + if (!newfile) { - curblk = -1; - stream->dirty = 0; + errno = ENOMEM; + return NULL; } - else - { - curblk = stream->buff_off/stream->bufsize; - } - /* firstblk: block number with first byte of request */ - firstblk = rstart/stream->bufsize; - /* firstoff: offset from start of first block */ - /* firstoff is in 0..blocksize */ - firstoff = rstart%stream->bufsize; - /* lastblk: block number with last byte of request */ - lastblk = rend/stream->bufsize; - /* lastoff: offset from start of last block */ - /* lastoff is in 0..blocksize */ - lastoff = rend%stream->bufsize; - /* numblk: number of blocks involved in request */ - numblk = (lastblk - firstblk) + 1; - /* firstsize: number of bytes on first block of request */ - /* firstsize is in 1..blocksize */ - firstsize = (firstblk==lastblk) ? lastoff-firstoff+1 : - stream->bufsize-firstoff; - /* lastsize: number of bytes on last block of request */ - /* lastsize is in 0..blocksize */ - lastsize = (firstblk == lastblk) ? 0 : lastoff+1; - + memset(newfile, 0, sizeof(FILE)); - /* if the current buffer is not involved, flush it */ - if (curblk < firstblk || curblk > lastblk) - { - if (stream->dirty) - write(stream->fd, stream->buffer, stream->bufsize); - stream->dirty = 0; - stream->buf_off = -1; - curblk = -1; - /* write completes below - file pointer already in position */ - } - /* if current buffer is completely overwritten, ignore it */ - else if ((curblk > firstblk && curblk < lastblk) || - (curblk == firstblk && firstsize == stream->bufsize) || - (curblk == lastblk && lastsize = stream->bufsize)) + /* initize lock for this stream */ + SETFLAG(newfile, _IO_USER_LOCK); + lock_init_stream(newfile); + + newfile->_fileno = fd; + rc = init_stream(newfile, flags, PVFS_BUFSIZE); + if(rc) { - stream->dirty = 0; - stream->buf_off = -1; - curblk = -1; - /* write completes below - file pointer already in position */ + free(newfile); + return NULL; } - /* if current buffer is first, copy bytes */ - else if (curblk == firstblk && firstsize < stream->bufsize) + return newfile; +} + +/** + * freopen closes the file and opens another one for the stream + */ +FILE *freopen(const char *path, const char *mode, FILE *stream) +{ + int fd = 0; + int flags = 0; + if (!stream || !ISMAGICSET(stream, _P_IO_MAGIC)) { - memcopy(stream->buf+firstoff, ptr, firstsize); - if (numblk > 1) + if (stream && ISMAGICSET(stream, _IO_MAGIC)) { - lseek(stream->fd, stream->buf_off, SEEK_SET); - write(stream->fd, stream->buf, stream->bufsize); - stream->dirty = 0; - stream->buf_off = -1; + init_stdio(); + return stdio_ops.freopen(path, mode, stream); } - ptr += firstsize; - rsz -= firstsize; - /* write completes below - file pointer left in position */ + errno = EINVAL; + return NULL; } - /* now write the data */ - if (lastsize > 0) /* write to the middle of a block */ + lock_stream(stream); + /* see if stream is in use - if so close the file */ + if (stream->_fileno > -1) { - /* should already be in position to write request data */ - write(stream->fd, ptr, rsz-lastsize); - /* see if the last block is not the one already loaded */ - if (curblk != lastblk) + int rc; + rc = close(stream->_fileno); + if (rc == -1) { - /* cannot have a valid block in the buffer */ - if (curblk != -1) - { - errno = 100; - return -1; - } - /* locate new buffer block */ - stream->buf_off = lastblock * stream->bufsize; - /* load a new buffer - file pointer should be in position */ - stream->buftotal = read(stream->fd, stream->buf, stream->bufsize); + unlock_stream(stream); + return NULL; } - /* move last of request data to buffer */ - memcopy(stream->buf, ptr+(rsz-lastsize), lastsize); - /* move file pointer back to end of request */ - stream->file_pointer = stream->buf_off+lastsize; - /* see of we extended the file */ - if (lastsize > stream->buftotal) - stream->buftotal = lastsize; } - else /* writes to the end of a block */ + + /* translate mode to flags */ + flags = mode2flags(mode); + + /* open the file */ + fd = open(path, flags, 0666); + if (fd == -1) { - /* should already be in position */ - write(stream->fd, ptr, rsz); + unlock_stream(stream); + return NULL; } - /* file pointer should be in right place */ - return rsz; + stream->_fileno = fd; + + /* reset buffering here */ + if (stream->_IO_buf_base) + free (stream->_IO_buf_base); + init_stream(stream, flags, PVFS_BUFSIZE); + + unlock_stream(stream); + return stream; } -/* - * fread wrapper +/** + * These functions do not need PVFS versions and thus + * are not implemented here + */ +#if 0 +FILE *fopencookie(void *cookie, const char *modes, + _IO_cookie_io_function_t funcs); +FILE *fmemopen(void *buf, size_t size, const char *mode); +FILE *open_memstream(char **ptr, size_t *sizeloc); +#endif + +/** Implements buffered write using Linux pointer model + * + * Two sets of pointers, one for reading one for writing + * flag determins which mode we are in. start always + * points to beginning of buffer, end points to end + * In read, end points to end of actual data read and + * coincides with the file pointer. In write the start + * coincides with file pointer. In either case ptr is + * where user stream pointer is. + * + * The FILE struct is struct _IO_FILE defined in /usr/include/libio.h */ -size_t fread(const void *ptr, size_t size, size_t nmemb, FILE *stream) +size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream) { - off64_t rsz, rstart, rend; - off64_t firstblk, firstoff, firstsize; - off64_t lastblk, lastoff, lastsize; - off64_t curblk, numblk; + int rc = 0; - if (!stream || !stream->is_in_use || !ptr) { - errno = EBADF; - return 0; + if (!stream || !ISMAGICSET(stream, _P_IO_MAGIC)) + { + if (stream && ISMAGICSET(stream, _IO_MAGIC)) + { + init_stdio(); + return stdio_ops.fwrite(ptr, size, nmemb, stream); + } + errno = EINVAL; + return -1; } - /* rsz: request size in bytes */ - rsz = size * nmemb; - /* rstart: first byte of request */ - rstart = stream->file_pointer; - /* rend: last byte of request */ - rend = rstart + rsz - 1; + lock_stream(stream); + rc = fwrite_unlocked(ptr, size, nmemb, stream); + unlock_stream(stream); + return rc; +} + +size_t fwrite_unlocked(const void *ptr, size_t size, size_t nmemb, FILE *stream) +{ + off64_t rsz, rsz_buf, rsz_extra; + int rc; - /* file is divided into blocks from 0..N-1 */ - /* curblk: block number of current buffer */ - if (stream->buf_off == -1) + if (!stream || !ISMAGICSET(stream, _P_IO_MAGIC)) { - curblk = -1; - stream->dirty = 0; + if (stream && ISMAGICSET(stream, _IO_MAGIC)) + { + init_stdio(); + return stdio_ops.fwrite(ptr, size, nmemb, stream); + } + errno = EINVAL; + return -1; } - else + if (!ptr || size <= 0 || nmemb <= 0) { - curblk = stream->buff_off/stream->bufsize; - } - /* firstblk: block number with first byte of request */ - firstblk = rstart/stream->bufsize; - /* firstoff: offset from start of first block */ - /* firstoff is in 0..blocksize */ - firstoff = rstart%stream->bufsize; - /* lastblk: block number with last byte of request */ - lastblk = rend/stream->bufsize; - /* lastoff: offset from start of last block */ - /* lastoff is in 0..blocksize */ - lastoff = rend%stream->bufsize; - /* numblk: number of blocks involved in request */ - numblk = (lastblk - firstblk) + 1; - /* firstsize: number of bytes on first block of request */ - /* firstsize is in 1..blocksize */ - firstsize = (firstblk==lastblk) ? lastoff-firstoff+1 : - stream->bufsize-firstoff; - /* lastsize: number of bytes on last block of request */ - /* lastsize is in 0..blocksize */ - lastsize = (firstblk == lastblk) ? 0 : lastoff+1; - + errno = EINVAL; + return -1; + } - /* if the current buffer is not involved, flush it */ - if (curblk < firstblk || curblk > lastblk) + /* Check to see if switching from read to write */ + if (!ISFLAGSET(stream, _IO_CURRENTLY_PUTTING)) { - if (stream->dirty) - write(stream->fd, stream->buffer, stream->bufsize); - stream->dirty = 0; - stream->buf_off = -1; - curblk = -1; - /* write completes below - file pointer already in position */ + /* reset read pointer */ + stream->_IO_read_ptr = stream->_IO_read_end; + /* set flag */ + SETFLAG(stream, _IO_CURRENTLY_PUTTING); + /* indicate read buffer empty */ + stream->_IO_read_end = stream->_IO_read_base; + stream->_IO_read_ptr = stream->_IO_read_end; + /* indicate write buffer empty */ + stream->_IO_write_end = stream->_IO_buf_end; + stream->_IO_write_ptr = stream->_IO_write_base; } - /* if current buffer is completely read, break into two reads */ - else if ((curblk > firstblk && curblk < lastblk) || - (curblk == firstblk && firstsize == stream->bufsize) || - (curblk == lastblk && lastsize = stream->bufsize)) + + rsz = size * nmemb; + rsz_buf = PVFS_util_min(rsz, stream->_IO_write_end - stream->_IO_write_ptr); + rsz_extra = rsz - rsz_buf; + + if (rsz_buf) /* is only zero if buffer is full */ { - /* read from start up to buffer */ - /* copy buffer */ - /* if buffer dirty, flush */ - if (stream->dirty) - { - lseek(stream->fd, stream->buf_off, SEEK_SET); - write(stream->fd, stream->buf, stream->bufsize); - stream->dirty = 0; - stream->buf_off = -1; - curblk = -1; - } - /* read completes below - file pointer already in position */ + memcpy(stream->_IO_write_ptr, ptr, rsz_buf); + stream->_IO_write_ptr += rsz_buf; } - /* if current buffer is first, copy bytes */ - else if (curblk == firstblk && firstsize < stream->bufsize) + + /* if there is more to write */ + if (rsz_extra) { - memcopy(ptr, stream->buf+firstoff, firstsize); - /* if buffer dirty, flush */ - if (stream->dirty) + /* buffer is full - write the current buffer */ +#if STDIO_DEBUG + fprintf(stderr,"fwrite writing %d bytes to offset %d\n", + (int)(stream->_IO_write_ptr - stream->_IO_write_base), + (int)lseek(stream->_fileno, 0, SEEK_CUR)); +#endif + rc = write(stream->_fileno, stream->_IO_write_base, + stream->_IO_write_ptr - stream->_IO_write_base); + if (rc == -1) { - lseek(stream->fd, stream->buf_off, SEEK_SET); - write(stream->fd, stream->buf, stream->bufsize); - stream->dirty = 0; - stream->buf_off = -1; + SETFLAG(stream, _IO_ERR_SEEN); + return -1; } - ptr += firstsize; - rsz -= firstsize; - /* read completes below - file pointer left in position */ - } - /* now read the data */ - if (lastsize > 0) /* read to the middle of a block */ - { - /* should already be in position to read request data */ - read(stream->fd, ptr, rsz-lastsize); - /* see if the last block is not the one already loaded */ - if (curblk != lastblk) + /* reset buffer */ + stream->_IO_write_ptr = stream->_IO_write_base; + /* if there more data left in request than fits in a buffer */ + if(rsz_extra > stream->_IO_buf_end - stream->_IO_buf_base) { - /* cannot have a valid block in the buffer */ - if (curblk != -1) +#if STDIO_DEBUG + fprintf(stderr,"fwrite writing %d bytes to offset %d\n", + (int)rsz_extra, + (int)lseek(stream->_fileno, 0, SEEK_CUR)); +#endif + /* write data directly */ + rc = write(stream->_fileno, ptr + rsz_buf, rsz_extra); + if (rc == -1) { - errno = 100; + SETFLAG(stream, _IO_ERR_SEEN); return -1; } - /* locate new buffer block */ - stream->buf_off = lastblock * stream->bufsize; - /* load a new buffer - file pointer should be in position */ - stream->buftotal = read(stream->fd, stream->buf, stream->bufsize); } - /* move last of request data to buffer */ - memcopy(ptr+(rsz-lastsize), stream->buf, lastsize); - /* move file pointer back to end of request */ - stream->file_pointer = stream->buf_off+lastsize; - } - else /* writes to the end of a block */ - { - /* should already be in position */ - read(stream->fd, ptr, rsz); + else + { + memcpy(stream->_IO_write_ptr, ptr + rsz_buf, rsz_extra); + stream->_IO_write_ptr += rsz_extra; + } } - /* file pointer should be in right place */ + return rsz; } /* - * fclose wrapper - */ -int fclose(FILE *stream) -{ - return close(stream->fd); -} - -/* - * fseek wrapper - */ -off_t fseek(FILE *stream, off_t offset, int whence) -{ - return (off_t)lseek64(stream->fd, (off64_t)offset, whence); -} - -/* - * fseek64 wrapper - */ -off64_t fseek64(FILE *stream, off64_t offset, int whence) -{ - return lseek64(stream->fd, offset, whence); -} - -/* - * fsetpos wrapper - */ -int fsetpos(FILE *stream, fpos_t *pos) -{ - return lseek(stream->fd, *pos, SEEK_SET); -} - -/* - * rewind wrapper - */ -void rewind(FILE *stream) -{ - lseek(stream->fd, 0, SEEK_SET); -} - -/* - * ftell wrapper - */ -long ftell(FILE *stream) -{ - return (long)stream->file_pointer; -} - -/* - * fgetpos wrapper - */ -int fgetpos(FILE *stream, fpos_t *pos) -{ - *pos = stream->file_pointer; - return 0; -} - -/* - * fflush wrapper + * fread implements the same buffer scheme as in fwrite */ -int fflush(FILE *stream) +size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream) { int rc = 0; - if (stream) + + if (!stream || !ISMAGICSET(stream, _P_IO_MAGIC)) { - if (stream->buf && stream->dirty) + if (stream && ISMAGICSET(stream, _IO_MAGIC)) { - lseek64(stream->fd, stream->buf_off, SEEK_SET); - /* buftotal should equal bufsize unless the buffer */ - /* is at the end of the file and the buffer is too */ - /* big - then buftotal is smaleer */ - write(stream->fd, stream->buf, stream->buftotal); - stream->dirty = 0; + init_stdio(); + return stdio_ops.fwrite(ptr, size, nmemb, stream); } - } - else - { errno = EINVAL; - rc = -1; + return -1; } + lock_stream(stream); + rc = fread_unlocked(ptr, size, nmemb, stream); + unlock_stream(stream); return rc; } -/* - * fputc wrapper - */ -int fputc(int c, FILE *stream) +size_t fread_unlocked(void *ptr, size_t size, size_t nmemb, FILE *stream) { - size_t len; + int rsz, rsz_buf, rsz_extra; + int bytes_read; int rc; - if (!stream || !stream->is_in_use || !s) + + if (!stream || !ISMAGICSET(stream, _P_IO_MAGIC)) { - errno = EBADF; - return 0; + if (stream && ISMAGICSET(stream, _IO_MAGIC)) + { + init_stdio(); + return stdio_ops.fread(ptr, size, nmemb, stream); + } + errno = EINVAL; + return -1; } - rc = fwrite (&c, 1, 1, stream); - if (rc != 1) - rc = -1; - else - rc = c; - return rc; -} - -/* - * fputs wrapper - */ -int fputs(const char *s, FILE *stream) -{ - size_t len; - int rc; - if (!stream || !stream->is_in_use || !s) + if (!ptr || size < 0 || nmemb < 0) { - errno = EBADF; - return 0; + errno = EINVAL; + return -1; } - len = strlen(s); - return fwrite (s, len, 1, stream); -} + /* Check to see if switching from write to read */ + if (ISFLAGSET(stream, _IO_CURRENTLY_PUTTING)) + { + /* write buffer back */ +#if STDIO_DEBUG + fprintf(stderr,"fread writing %d bytes to offset %d\n", + (int)(stream->_IO_write_ptr - stream->_IO_write_base), + (int)lseek(stream->_fileno, 0, SEEK_CUR)); +#endif + rc = write(stream->_fileno, stream->_IO_write_base, + stream->_IO_write_ptr - stream->_IO_write_base); + if (rc == -1) + { + SETFLAG(stream, _IO_ERR_SEEN); + return -1; + } + /* reset write pointer */ + stream->_IO_write_ptr = stream->_IO_write_base; + /* clear flag */ + CLEARFLAG(stream, _IO_CURRENTLY_PUTTING); + /* indicate read buffer empty */ + stream->_IO_read_end = stream->_IO_read_base; + stream->_IO_read_ptr = stream->_IO_read_end; + } + + /* see if anything is in read buffer */ + if (stream->_IO_read_end == stream->_IO_read_base || + stream->_IO_read_ptr == stream->_IO_read_end) + { + /* buffer empty so read new buffer */ + bytes_read = read(stream->_fileno, stream->_IO_read_base, + stream->_IO_buf_end - stream->_IO_buf_base); + if (bytes_read == -1) + { + SETFLAG(stream, _IO_ERR_SEEN); + return -1; + } + /* indicate end of read area */ + stream->_IO_read_end = stream->_IO_read_base + bytes_read; + /* reset read pointer */ + stream->_IO_read_ptr = stream->_IO_read_base; + } + + /* + * we assume there is a block in the buffer now + * and that the current file pointer corresponds + * to the end of the read buffer. The user has + * only up to the read pointer. + */ + rsz = size * nmemb; /* total bytes requested */ + rsz_buf = PVFS_util_min(rsz, stream->_IO_read_end - stream->_IO_read_ptr); + rsz_extra = rsz - rsz_buf; /* bytes beyond the buffer */ + + /* copy rz_buf bytes from buffer */ + if (rsz_buf) /* zero if at EOF */ + { + memcpy(ptr, stream->_IO_read_ptr, rsz_buf); + stream->_IO_read_ptr += rsz_buf; + } + + /* if more bytes requested */ + if (rsz_extra) + { + /* if current buffer not at EOF */ + if (stream->_IO_read_end == stream->_IO_buf_end) + { + /* if more data requested than fits in buffer */ + if (rsz_extra > (stream->_IO_buf_end - stream->_IO_buf_base)) + { + /* read directly from file for remainder of request */ + bytes_read = read(stream->_fileno, ptr+rsz_buf, rsz_extra); + if (bytes_read == -1) + { + SETFLAG(stream, _IO_ERR_SEEN); + return -1; + } + if (bytes_read == rsz_extra) + { + /* then read next buffer */ + bytes_read = read(stream->_fileno, stream->_IO_buf_base, + stream->_IO_buf_end - stream->_IO_buf_base); + if (bytes_read == -1) + { + SETFLAG(stream, _IO_ERR_SEEN); + return -1; + } + stream->_IO_read_end = stream->_IO_read_base + bytes_read; + stream->_IO_read_ptr = stream->_IO_read_base; + return rsz; + } + /* have read to EOF */ + SETFLAG(stream, _IO_EOF_SEEN); + return rsz_buf + bytes_read; + } + /* rest of request fits in a buffer - read next buffer */ + bytes_read = read(stream->_fileno, stream->_IO_buf_base, + stream->_IO_buf_end - stream->_IO_buf_base); + if (bytes_read == -1) + { + SETFLAG(stream, _IO_ERR_SEEN); + return -1; + } + stream->_IO_read_end = stream->_IO_read_base + bytes_read; + stream->_IO_read_ptr = stream->_IO_read_base; + /* transfer remainder */ + rsz_extra = PVFS_util_min(rsz_extra, + stream->_IO_read_end - stream->_IO_read_ptr); + if (rsz_extra) /* zero if at EOF */ + { + memcpy(ptr, stream->_IO_read_ptr, rsz_extra); + stream->_IO_read_ptr += rsz_extra; + } + if (rsz_buf + rsz_extra < rsz) + { + SETFLAG(stream, _IO_EOF_SEEN); + } + return rsz_buf + rsz_extra; + } + else + { + /* at EOF so return bytes read */ + SETFLAG(stream, _IO_EOF_SEEN); + return rsz_buf; + } + } + /* request totally within current buffer */ + return rsz; +} + +/** + * fcloseall closes all open streams + */ +int fcloseall(void) +{ + int rc = 0; + while (open_files._chain) + { + rc = fclose(open_files._chain); + } + return rc; +} + +/** + * fclose first writes any dirty data in the buffer + */ +int fclose(FILE *stream) +{ + int rc = 0; + FILE *f; + if (!stream || !ISMAGICSET(stream, _P_IO_MAGIC)) + { + if (stream && ISMAGICSET(stream, _IO_MAGIC)) + { + init_stdio(); + return stdio_ops.fclose(stream); + } + errno = EINVAL; + return -1; + } + lock_stream(stream); + /* write any pending data */ + if (ISFLAGSET(stream, _IO_CURRENTLY_PUTTING)) + { + if (stream->_IO_write_ptr > stream->_IO_write_base) + { +#if STDIO_DEBUG + fprintf(stderr,"fclose writing %d bytes to offset %d\n", + (int)(stream->_IO_write_ptr - stream->_IO_write_base), + (int)lseek(stream->_fileno, 0, SEEK_CUR)); +#endif + rc = write(stream->_fileno, stream->_IO_write_base, + stream->_IO_write_ptr - stream->_IO_write_base); + if (rc == -1) + { + SETFLAG(stream, _IO_ERR_SEEN); + return -1; + } + } + } + if (!ISFLAGSET(stream, _IO_USER_BUF)) + { + /* free the buffer */ + free(stream->_IO_buf_base); + } + if (!ISFLAGSET(stream, _IO_DELETE_DONT_CLOSE)) + { + rc = close(stream->_fileno); + } + /* remove from chain */ + lock_stream(&open_files); + if (open_files._chain == stream) + { + open_files._chain = stream->_chain; + } + else + { + for (f = open_files._chain; f && f->_chain != stream; f = f->_chain) + if (f && f->_chain) + { + f->_chain = f->_chain->_chain; + } + /* was not on chain */ + } + unlock_stream(&open_files); + stream->_flags = 0; + /* can stream be locked here ? */ + lock_fini_stream(stream); + free(stream); + return rc; +} + +/** + * fseek wrapper + */ +int fseek(FILE *stream, long offset, int whence) +{ + return fseek64(stream, (off64_t)offset, whence); +} + +int fseeko(FILE *stream, off_t offset, int whence) +{ + return fseek64(stream, (off64_t)offset, whence); +} + +int fseeko64(FILE *stream, off64_t offset, int whence) +{ + return fseek64(stream, (off64_t)offset, whence); +} + +/** This is the main code for seeking on a stream + * + * If we seek a short distance within the current buffer + * we can just move the stream pointer. Otherwise we + * have to clear the buffer, seek, and start fresh + */ +int fseek64(FILE *stream, const off64_t offset, int whence) +{ + int rc = 0; + if (!stream || !ISMAGICSET(stream, _P_IO_MAGIC)) + { + if (stream && ISMAGICSET(stream, _IO_MAGIC)) + { + init_stdio(); + return stdio_ops.fseek64(stream, offset, whence); + } + errno = EINVAL; + return -1; + } + lock_stream(stream); + /* if actually changing the position */ + if ((offset != 0L) || (whence != SEEK_CUR)) + { + int64_t filepos, fileend; + struct stat64 sbuf; + filepos = lseek64(stream->_fileno, 0, SEEK_CUR); + /* should fileend include stuff in write buffer ??? */ + rc = fstat64(stream->_fileno, &sbuf); + if (rc < 0) + { + SETFLAG(stream, _IO_ERR_SEEN); + rc = -1; + goto exitout; + } + fileend = sbuf.st_size; + /* figure out if we are only seeking within the */ + /* bounds of the current buffer to minimize */ + /* unneccessary reads/writes */ + if (whence == SEEK_CUR && ISFLAGSET(stream, _IO_CURRENTLY_PUTTING) && + (offset < stream->_IO_write_end - stream->_IO_write_ptr) && + (offset > stream->_IO_write_base - stream->_IO_write_ptr)) + { + stream->_IO_write_ptr += offset; + /* should we zero out buffer if past eof ??? */ + rc = 0; + goto exitout; + } + if (whence == SEEK_CUR && !ISFLAGSET(stream, _IO_CURRENTLY_PUTTING) && + (offset < stream->_IO_read_end - stream->_IO_read_ptr) && + (offset > stream->_IO_read_base - stream->_IO_read_ptr)) + { + stream->_IO_read_ptr += offset; + rc = 0; + goto exitout; + } + if (whence == SEEK_SET && ISFLAGSET(stream, _IO_CURRENTLY_PUTTING) && + (offset > filepos) && (offset < filepos + + (stream->_IO_write_end - stream->_IO_write_base))) + { + stream->_IO_write_ptr += offset - filepos; + /* should we zero out buffer if past eof ??? */ + rc = 0; + goto exitout; + } + if (whence == SEEK_SET && !ISFLAGSET(stream, _IO_CURRENTLY_PUTTING) && + (offset < filepos) && (offset > filepos - + (stream->_IO_read_end - stream->_IO_read_base))) + { + stream->_IO_read_ptr += offset - filepos; + rc = 0; + goto exitout; + } + if (whence == SEEK_END && ISFLAGSET(stream, _IO_CURRENTLY_PUTTING) && + ((fileend - offset) > filepos) && + ((fileend - offset) < filepos + + (stream->_IO_write_end - stream->_IO_write_base))) + { + stream->_IO_write_ptr += (fileend - offset) - filepos; + /* should we zero out buffer if past eof ??? */ + rc = 0; + goto exitout; + } + if (whence == SEEK_END && !ISFLAGSET(stream, _IO_CURRENTLY_PUTTING) && + ((fileend - offset) < filepos) && + ((fileend - offset) > filepos - + (stream->_IO_read_end - stream->_IO_read_base))) + { + stream->_IO_read_ptr += (fileend - offset) - filepos; + rc = 0; + goto exitout; + } + /* at this point the seek is beyond the current buffer */ + /* if we are in write mode write back the buffer */ + if (ISFLAGSET(stream, _IO_CURRENTLY_PUTTING) && + stream->_IO_write_ptr > stream->_IO_write_base) + { + /* write buffer back */ +#if STDIO_DEBUG + fprintf(stderr,"fseek writing %d bytes to offset %d\n", + (int)(stream->_IO_write_ptr - stream->_IO_write_base), + (int)lseek(stream->_fileno, 0, SEEK_CUR)); +#endif + rc = write(stream->_fileno, stream->_IO_write_base, + stream->_IO_write_ptr - stream->_IO_write_base); + if (rc < 0) + { + SETFLAG(stream, _IO_ERR_SEEN); + goto exitout; + } + /* reset write pointer */ + stream->_IO_write_ptr = stream->_IO_write_base; + } + else + { + /* in read mode simply clear the buffer */ + /* will force a read at next fread call */ + stream->_IO_read_end = stream->_IO_read_base; + stream->_IO_read_ptr = stream->_IO_read_end; + } + rc = lseek64(stream->_fileno, offset, whence); +#if STDIO_DEBUG + fprintf(stderr,"fseek seeks to offset %d\n", + (int)lseek(stream->_fileno, 0, SEEK_CUR)); +#endif + if (rc < 0) + { + SETFLAG(stream, _IO_ERR_SEEN); + goto exitout; + } + } +exitout: + /* successful call */ + lock_stream(stream); + CLEARFLAG(stream, _IO_EOF_SEEN); + return rc; +} + +/** + * fsetpos wrapper + */ +int fsetpos(FILE *stream, const fpos_t *pos) +{ + fseek64(stream, (off64_t)(pos->__pos), SEEK_SET); + return 0; +} + +int fsetpos64(FILE *stream, const fpos64_t *pos) +{ + fseek64(stream, (off64_t)(pos->__pos), SEEK_SET); + return 0; +} + +/** + * rewind wrapper + */ +void rewind(FILE *stream) +{ + fseek64(stream, 0L, SEEK_SET); + CLEARFLAG(stream, _IO_ERR_SEEN); +} + +/** + * ftell wrapper + */ +long int ftell(FILE *stream) +{ + return (long)ftell64(stream); +} + +off_t ftello(FILE *stream) +{ + return (off_t)ftell64(stream); +} + +off64_t ftello64(FILE *stream) +{ + return (off64_t)ftell64(stream); +} + +off64_t ftell64(FILE* stream) +{ + int64_t filepos; + if (!stream || !ISMAGICSET(stream, _P_IO_MAGIC)) + { + if (stream && ISMAGICSET(stream, _IO_MAGIC)) + { + init_stdio(); + return stdio_ops.ftell64(stream); + } + errno = EINVAL; + return -1; + } + filepos = lseek64(stream->_fileno, 0, SEEK_CUR); + if (ISFLAGSET(stream, _IO_CURRENTLY_PUTTING)) + { + return filepos + (stream->_IO_write_ptr - stream->_IO_write_base); + } + else + { + return filepos - (stream->_IO_read_end - stream->_IO_read_ptr); + } +} + +/** + * fgetpos wrapper + */ +int fgetpos(FILE *stream, fpos_t *pos) +{ + pos->__pos = ftell64(stream); + return 0; +} + +int fgetpos64(FILE *stream, fpos64_t *pos) +{ + pos->__pos = ftell64(stream); + return 0; +} + +/** forces a write back of potentially dirty buffer + * + * we don't have a dirty flag, so if user seeks + * ahead within the buffer then does a flush + * we will do an uncessary write + */ +int fflush(FILE *stream) +{ + int rc = 0; + + if (!stream || !ISMAGICSET(stream, _P_IO_MAGIC)) + { + if (stream && ISMAGICSET(stream, _IO_MAGIC)) + { + init_stdio(); + return stdio_ops.fflush(stream); + } + errno = EINVAL; + return -1; + } + lock_stream(stream); + rc = fflush_unlocked(stream); + unlock_stream(stream); + return rc; +} + +int fflush_unlocked(FILE *stream) +{ + int rc; + if (!stream || !ISMAGICSET(stream, _P_IO_MAGIC)) + { + if (stream && ISMAGICSET(stream, _IO_MAGIC)) + { + init_stdio(); + return stdio_ops.fflush(stream); + } + errno = EINVAL; + return -1; + } + /* if we are in write mode write back the buffer */ + if (ISFLAGSET(stream, _IO_CURRENTLY_PUTTING) && + stream->_IO_write_ptr > stream->_IO_write_base) + { + /* write buffer back */ +#if STDIO_DEBUG + fprintf(stderr,"fflush writing %d bytes to offset %d\n", + (int)(stream->_IO_write_ptr - stream->_IO_write_base), + (int)lseek(stream->_fileno, 0, SEEK_CUR)); +#endif + rc = write(stream->_fileno, stream->_IO_write_base, + stream->_IO_write_ptr - stream->_IO_write_base); + if (rc < 0) + { + SETFLAG(stream, _IO_ERR_SEEN); + return rc; + } + /* reset write pointer */ + stream->_IO_write_ptr = stream->_IO_write_base; + } + return 0; +} + +/* + * fputc wrapper + */ +int fputc(int c, FILE *stream) +{ + int rc = 0; + + if (!stream || !ISMAGICSET(stream, _P_IO_MAGIC)) + { + if (stream && ISMAGICSET(stream, _IO_MAGIC)) + { + init_stdio(); + return stdio_ops.fputc(c, stream); + } + errno = EINVAL; + return -1; + } + lock_stream(stream); + rc = fputc_unlocked(c, stream); + unlock_stream(stream); + return rc; +} + +int fputc_unlocked(int c, FILE *stream) +{ + int rc; + rc = fwrite_unlocked(&c, 1, 1, stream); + if (ferror(stream)) + { + return EOF; + } + return c; +} + +/** + * fputs writes up to a null char + */ +int fputs(const char *s, FILE *stream) +{ + int rc = 0; + + if (!stream || !ISMAGICSET(stream, _P_IO_MAGIC)) + { + if (stream && ISMAGICSET(stream, _IO_MAGIC)) + { + init_stdio(); + return stdio_ops.fputs(s, stream); + } + errno = EINVAL; + return -1; + } + lock_stream(stream); + rc = fputs_unlocked(s, stream); + unlock_stream(stream); + return rc; +} + +int fputs_unlocked(const char *s, FILE *stream) +{ + size_t len; + int rc; + if (!s) + { + errno = EINVAL; + return EOF; + } + len = strlen(s); + rc = fwrite_unlocked(s, len, 1, stream); + if (ferror(stream)) + { + return EOF; + } + return rc; +} + +/** + * putc wrapper + */ int putc(int c, FILE *stream) { - return fputc(c, stream); + return fputc(c, stream); +} + +int putc_unlocked(int c, FILE *stream) +{ + return fputc_unlocked(c, stream); +} + +/** + * putchar wrapper + */ +int putchar(int c) +{ + return fputc(c, stdout); +} + +int putchar_unlocked(int c) +{ + return fputc_unlocked(c, stdout); +} + +/** + * puts wrapper + */ +int puts(const char *s) +{ + int rc; + rc = fputs(s, stdout); + if (rc == EOF) + { + return EOF; + } + return fputs("\n", stdout); +} + +/** + * putw wrapper + */ +int putw(int wd, FILE *stream) +{ + int rc; + rc = fwrite(&wd, sizeof(int), 1, stream); + if (ferror(stream)) + { + return EOF; + } + return rc; +} + +/** + * fgets reads up to size or a newline + */ +char *fgets(char *s, int size, FILE *stream) +{ + char *rc = NULL; + + if (!stream || !ISMAGICSET(stream, _P_IO_MAGIC)) + { + if (stream && ISMAGICSET(stream, _IO_MAGIC)) + { + init_stdio(); + return stdio_ops.fgets(s, size, stream); + } + errno = EINVAL; + return NULL; + } + lock_stream(stream); + rc = fgets_unlocked(s, size, stream); + unlock_stream(stream); + return rc; } -int putchar(int c) +char *fgets_unlocked(char *s, int size, FILE *stream) { - return fputc(c, stdout); + char c, *p; + + if (!stream || !s || size < 1) + { + errno = EINVAL; + return NULL; + } + if (size == 1) + { + *s = '\0'; + return s; + } + p = s; + size--; + do { + *p++ = c = fgetc_unlocked(stream); + } while (--size && c != '\n' && !feof_unlocked(stream) + && !ferror_unlocked(stream)); + if (ferror_unlocked(stream)) + { + return NULL; + } + *p = '\0'; + return s; +} + +/** + * fgetc wrapper + */ +int fgetc(FILE *stream) +{ + int rc, ch; + + rc = fread(&ch, 1, 1, stream); + if (ferror(stream)) + { + return EOF; + } + return ch; } -int puts(const char *s, FILE *stream) +int fgetc_unlocked(FILE *stream) { - fputs(s, stream); - return fputs("\n", stream); + int rc, ch; + + rc = fread_unlocked(&ch, 1, 1, stream); + if (ferror(stream)) + { + return EOF; + } + return ch; } /** - * - * fgets wrapper + * getc wrapper */ -char *fgets(char *s, int size, FILE *stream) +int getc(FILE *stream) { - char *p; - long pos, current; - int rc; + return fgetc(stream); +} + +int getc_unlocked(FILE *stream) +{ + return fgetc_unlocked(stream); +} - if (!pvfs_lib_init) { - load_glibc(); +/** + * getchar wrapper + */ +int getchar(void) +{ + return fgetc(stdin); +} + +int getchar_unlocked(void) +{ + return fgetc_unlocked(stdin); +} + +/** + * getw wrapper + */ +int getw(FILE *stream) +{ + int rc, wd; + + rc = fread(&wd, sizeof(int), 1, stream); + if (ferror(stream)) + { + return EOF; } - if (!stream || stream->_fileno < 0) { - errno = EBADF; - return 0; + return wd; +} + +/** + * gets + */ +char *gets(char * s) +{ + char c, *p; + + if (!s) + { + errno = EINVAL; + return NULL; } - if (pvfs_find_descriptor(stream->_fileno)) { - pos = ftell(stream); -#ifdef DEBUG - pvfs_debug("fgets: pos=%ld\n", pos); -#endif - rc = pvfs_read(stream->_fileno, s, size); - if (rc > 0) { - p = strchr(s, '\n'); - if (p) { - ++p; - *p = '\0'; - pos += strlen(s); - current = ftell(stream); -#ifdef DEBUG - pvfs_debug("fgets: s=%s (len=%d)", s, strlen(s)); -#endif - if (pos != current) { -#ifdef DEBUG - pvfs_debug("fgets: new pos=%ld, current=%ld\n", pos, current); -#endif - pvfs_lseek(stream->_fileno, pos, SEEK_SET); -#ifdef DEBUG - pvfs_debug("fgets: set pos=%ld\n", ftell(stream)); -#endif - } - return s; + p = s; + do { + *p++ = c = fgetc(stdin); + } while (c != '\n' && !feof(stdin) && !ferror(stdin)); + if (ferror(stdin) || ((p = s + 1) && feof(stdin))) + { + return NULL; + } + if (!feof(stdin)) + { + *(p-1) = 0; /* replace terminating char with null */ + } + return s; +} + +/** + * getline + */ +ssize_t getline(char **lnptr, size_t *n, FILE *stream) +{ + return __getdelim(lnptr, n, '\n', stream); +} + +ssize_t getdelim(char **lnptr, size_t *n, int delim, FILE *stream) +{ + return __getdelim(lnptr, n, delim, stream); +} + +ssize_t __getdelim(char **lnptr, size_t *n, int delim, FILE *stream) +{ + int i = 0; + char c, *p; + + if (!stream || !n) + { + errno = EINVAL; + return -1; + } + if (!*lnptr) + { + if (*n <= 0) + { + *n = 256; + } + *lnptr = (char *)malloc(*n); + } + p = *lnptr; + do { + if (i + 1 >= *n) /* need space for next char and null terminator */ + { + *n += 256; /* spec gives no guidance on fit of allocated space */ + *lnptr = realloc(*lnptr, *n); + if (!*lnptr) + { + return -1; } + p = *lnptr + i; } - return NULL; + *p++ = c = fgetc(stream); + i++; + } while (c != delim && !feof(stream) && !ferror(stream)); + if (ferror(stream) || feof(stream)) + { + return -1; + } + *p = 0; /* null termintor */ + return i; +} + +/** + * ungetc wrapper + * + * TODO: at the moment this will not unget beyond the current + * buffer - needs a better implementation using the backup + * buffer area _IO_save_base, _IO_save_end, _IO_backup_base + */ +int ungetc(int c, FILE *stream) +{ + int64_t rc; + + rc = fseek64(stream, -1L, SEEK_CUR); + if (rc < 0) + { + return EOF; + } + return c; +} + +/** + * We don't need any flavor of sprintf or sscanf + * they don't do IO on a stream + */ +#if 0 +sprintf, snprintf, vsprintf, vsnprintf, asprintf, vasprintfm +sscanf, vsscanf +#endif + +/** + * dprintf wrapper + */ +int dprintf(int fd, const char *format, ...) +{ + size_t len; + va_list ap; + + va_start(ap, format); + len = vdprintf(fd, format, ap); + va_end(ap); + return len; +} + +/** + * vdprintf + */ +int vdprintf(int fd, const char *format, va_list ap) +{ + char *buf; + int len, rc; + + len = vasprintf(&buf, format, ap); + if (len < 0) + { + return len; + } + if (len > 0 && buf) + { + rc = write(fd, buf, len); + } + if (buf) + { + free(buf); + } + return rc; +} + +/** + * vfprintf using a var arg list + */ +int vfprintf(FILE *stream, const char *format, va_list ap) +{ + char *buf; + int len, rc; + + len = vasprintf(&buf, format, ap); + if (len < 0) + { + return len; + } + if (len > 0 && buf) + { + rc = fwrite(buf, len, 1, stream); + } + if (buf) + { + free(buf); + } + return rc; +} + +/** + * fprintf wrapper + */ +int vprintf(const char *format, va_list ap) +{ + return vfprintf(stdout, format, ap); +} + +/** + * fprintf wrapper + */ +int fprintf(FILE *stream, const char *format, ...) +{ + size_t len; + va_list ap; + + va_start(ap, format); + len = vfprintf(stream, format, ap); + va_end(ap); + return len; +} + +/** + * printf wrapper + */ +int printf(const char *format, ...) +{ + size_t len; + va_list ap; + + va_start(ap, format); + len = vfprintf(stdout, format, ap); + va_end(ap); + return len; +} + +/** + * perror + */ +void perror(const char *s) +{ + char *msg; + if (s && *s) + { + fwrite(s, strlen(s), 1, stderr); } - else { -#ifdef DEBUG - pvfs_debug("fgets: calling glibc_ops.fgets, s=%p, size=%ld, fd=%d\n", - s, size, fileno(stream)); + msg = strerror(errno); + fwrite(msg, strlen(msg), 1, stderr); + fwrite("\n", 1, 1, stderr); +} + +#if 0 +/* TODO: These are not implemented yet */ + +scanf() +{ +} + +fscanf() +{ +} + +vfscanf() +{ +} + #endif - return glibc_ops.fgets(s, size, stream); + +/** + * Stdio utilitie to clear error and eof for a stream + */ +void clearerr (FILE *stream) +{ + if (!stream || !ISMAGICSET(stream, _P_IO_MAGIC)) + { + if (stream && ISMAGICSET(stream, _IO_MAGIC)) + { + init_stdio(); + stdio_ops.clearerr(stream); + return; + } + return; + } + lock_stream(stream); + CLEARFLAG(stream, _IO_ERR_SEEN); + CLEARFLAG(stream, _IO_EOF_SEEN); + unlock_stream(stream); +} + +void clearerr_unlocked (FILE *stream) +{ + if (!stream || !ISMAGICSET(stream, _P_IO_MAGIC)) + { + if (stream && ISMAGICSET(stream, _IO_MAGIC)) + { + init_stdio(); + stdio_ops.clearerr(stream); + return; + } + return; + } + CLEARFLAG(stream, _IO_ERR_SEEN); + CLEARFLAG(stream, _IO_EOF_SEEN); +} + +/** + * Stdio utilitie to check if a stream is at EOF + */ +int feof (FILE *stream) +{ + int rc = 0; + + if (!stream || !ISMAGICSET(stream, _P_IO_MAGIC)) + { + if (stream && ISMAGICSET(stream, _IO_MAGIC)) + { + init_stdio(); + return stdio_ops.feof(stream); + } + errno = EINVAL; + return -1; + } + lock_stream(stream); + rc = ISFLAGSET(stream, _IO_EOF_SEEN); + unlock_stream(stream); + return rc; +} + +int feof_unlocked (FILE *stream) +{ + if (!stream || !ISMAGICSET(stream, _P_IO_MAGIC)) + { + if (stream && ISMAGICSET(stream, _IO_MAGIC)) + { + init_stdio(); + return stdio_ops.feof(stream); + } + errno = EBADF; + return -1; + } + return ISFLAGSET(stream, _IO_EOF_SEEN); +} + +/** + * Stdio utilitie to check for error on a stream + */ +int ferror (FILE *stream) +{ + int rc = 0; + + if (!stream || !ISMAGICSET(stream, _P_IO_MAGIC)) + { + if (stream && ISMAGICSET(stream, _IO_MAGIC)) + { + init_stdio(); + return stdio_ops.ferror(stream); + } + errno = EINVAL; + return -1; + } + lock_stream(stream); + rc = ISFLAGSET(stream, _IO_ERR_SEEN); + unlock_stream(stream); + return rc; +} + +int ferror_unlocked (FILE *stream) +{ + if (!stream || !ISMAGICSET(stream, _P_IO_MAGIC)) + { + if (stream && ISMAGICSET(stream, _IO_MAGIC)) + { + init_stdio(); + return stdio_ops.ferror(stream); + } + errno = EBADF; + return -1; } + return ISFLAGSET(stream, _IO_ERR_SEEN); } /** - * - * fgetc wrapper + * Stdio utilitie to get file descriptor from a stream */ -int fgetc(FILE *stream) +int fileno (FILE *stream) { - int rc, ch; + int rc = 0; - if (!pvfs_lib_init) { - load_glibc(); - } - if (!stream || stream->_fileno < 0) { - errno = EBADF; - return 0; - } - if (pvfs_find_descriptor(stream->_fileno)) { -#ifdef DEBUG - pvfs_debug("fgetc: calling pvfs_read\n"); -#endif - rc = pvfs_read(stream->_fileno, &ch, 1); - if (rc > 0) { - return ch; - } - else { - errno = EBADF; - return EOF; + if (!stream || !ISMAGICSET(stream, _P_IO_MAGIC)) + { + if (stream && ISMAGICSET(stream, _IO_MAGIC)) + { + init_stdio(); + return stdio_ops.fileno(stream); } + errno = EINVAL; + return -1; } - else { -#ifdef DEBUG - pvfs_debug("fgetc: calling glibc_ops.fgetc\n"); -#endif - return glibc_ops.fgetc(stream); + lock_stream(stream); + rc = stream->_fileno; + unlock_stream(stream); + return rc; +} + +int fileno_unlocked (FILE *stream) +{ + if (!stream || !ISMAGICSET(stream, _P_IO_MAGIC)) + { + if (stream && ISMAGICSET(stream, _IO_MAGIC)) + { + init_stdio(); + return stdio_ops.fileno(stream); + } + errno = EBADF; + return -1; } + return stream->_fileno; } -/** +/** stdio function to delete a file * - * getc wrapper */ -int getc(FILE *stream) +int remove (const char *path) { - return fgetc(stream); + int rc; + struct stat buf; + + rc = stat(path, &buf); + if (S_ISDIR(buf.st_mode)) + return rmdir (path); + return unlink (path); } -int getchar(void) +/** + * setbuf wrapper + */ +void setbuf (FILE *stream, char *buf) { - return fgetc(stream); + setvbuf(stream, buf, buf ? _IOFBF : _IONBF, BUFSIZ); } -char *gets(char * s) +/** + * setbuffer wrapper + */ +void setbuffer (FILE *stream, char *buf, size_t size) { + setvbuf(stream, buf, buf ? _IOFBF : _IONBF, size); } /** - * - * ungetc wrapper + * setlinbuf wrapper */ -int ungetc(int c, FILE *stream) +void setlinebuf (FILE *stream) { - long pos; + setvbuf(stream, (char *)NULL, _IOLBF, 0); +} - if (!pvfs_lib_init) { - load_glibc(); +/** + * + * This should only be called on a stream that has been opened + * but not used so we can assume any exiting buff is not dirty + */ +int setvbuf (FILE *stream, char *buf, int mode, size_t size) +{ + if (!stream || !ISMAGICSET(stream, _P_IO_MAGIC)) + { + if (stream && ISMAGICSET(stream, _IO_MAGIC)) + { + init_stdio(); + return stdio_ops.setvbuf(stream, buf, mode, size); + } + errno = EINVAL; + return -1; } - if (!stream || stream->_fileno < 0) { - errno = EBADF; - return 0; + if ((stream->_IO_read_end != stream->_IO_buf_base) || + (stream->_IO_write_ptr != stream->_IO_buf_base)) + { + /* fread or fwrite has been called */ + errno = EINVAL; + return -1; } - if (pvfs_find_descriptor(stream->_fileno)) { -#ifdef DEBUG - pvfs_debug("ungetc: current pos=%ld\n", ftell(stream)); -#endif - pos = ftell(stream) - 1; - pvfs_lseek(stream->_fileno, pos, SEEK_SET); -#ifdef DEBUG - pvfs_debug("ungetc: set pos=%ld\n", ftell(stream)); -#endif - return c; + lock_stream(stream); + switch (mode) + { + case _IOFBF : /* full buffered */ + /* this is the default */ + break; + case _IOLBF : /* line buffered */ + SETFLAG(stream, _IO_LINE_BUF); /* TODO: This is not implemented */ + break; + case _IONBF : /* not buffered */ + SETFLAG(stream, _IO_UNBUFFERED); /* TODO: This is not implemented */ + break; + default : + errno = EINVAL; + unlock_stream(stream); + return -1; } - else { -#ifdef DEBUG - pvfs_debug("ungetc: calling glibc_ops.ungetc\n"); -#endif - return glibc_ops.ungetc(c, stream); + if (buf && size > 0) + { + SETFLAG(stream, _IO_USER_BUF); + free(stream->_IO_buf_base); + stream->_IO_buf_base = buf; + stream->_IO_buf_end = stream->_IO_buf_base + size; + stream->_IO_read_base = stream->_IO_buf_base; + stream->_IO_read_ptr = stream->_IO_buf_base; + stream->_IO_read_end = stream->_IO_buf_base; + stream->_IO_write_base = stream->_IO_buf_base; + stream->_IO_write_ptr = stream->_IO_buf_base; + stream->_IO_write_end = stream->_IO_buf_end; } + unlock_stream(stream); + return 0; } /** - * - * fprintf wrapper + * mkdtemp makes a temp dir and returns an fd */ -int fprintf(FILE *stream, const char *format, ...) +char *mkdtemp(char *template) { - char *buf = NULL; - size_t len; - va_list ap; - int rc; + int fd; + int len; + int rnum; + int try; - if (!pvfs_lib_init) { - load_glibc(); + if (!template) + { + errno = EINVAL; + return NULL; } - if (!stream || stream->_fileno < 0) { - errno = EBADF; - return 0; - } - if (pvfs_find_descriptor(stream->_fileno)) { - va_start(ap, format); - len = vasprintf(&buf, format, ap); - va_end(ap); - if (len > 0 && buf) { - rc = pvfs_write(stream->_fileno, buf, len); - } - else { -#ifdef DEBUG - pvfs_debug("fprintf: vasprintf error\n", buf); -#endif - errno = EIO; - rc = -1; - } - if (buf) { - free(buf); - } - return rc; + len = strlen(template); + if (!strncmp(&template[len-6],"XXXXXX",6)) + { + errno = EINVAL; + return NULL; } - else { -#ifdef DEBUG - pvfs_debug("fprintf: calling glibc_ops.fprintf for %d\n", stream->_fileno ); -#endif - return glibc_ops.fprintf(stream, format, ap); + for(try = 0; try < MAXTRIES; try++) + { + rnum = PINT_random() % 1000000; + sprintf(&template[len-6],"%06d", rnum); + fd = mkdir(template, 0700); + if (fd < 0) + { + if (errno == EEXIST) + { + continue; + } + return NULL; + } } + return template; } -#if 0 -printf() -{ -} - -fscanf() +/** + * mkstemp makes a temp file and returns an fd + */ +int mkstemp(char *template) { -} + int fd; + int len; + int rnum; + int try; -scanf() -{ + if (!template) + { + errno = EINVAL; + return -1; + } + len = strlen(template); + if (!strncmp(&template[len-6],"XXXXXX",6)) + { + errno = EINVAL; + return -1; + } + for(try = 0; try < MAXTRIES; try++) + { + rnum = PINT_random() % 1000000; + sprintf(&template[len-6],"%06d", rnum); + fd = open(template, O_RDWR|O_EXCL|O_CREAT, 0600); + if (fd < 0) + { + if (errno == EEXIST) + { + continue; + } + return -1; + } + } + return fd; } -#endif -/* - * Stdio utilities for EOF, error, etc +/** + * tmpfile makes a temp file and returns a stream */ -void clearerr (FILE *pf) +FILE *tmpfile(void) { - if (pf && pf->is_in_use) + char *template = "/tmp/tmpfileXXXXXX"; + int fd; + fd = mkstemp(template); + if (fd < 0) { - pf->eof = 0; - pf->error = 0; + return NULL; } + return fdopen(fd, "r+"); } -int feof (FILE *pf) +/** + * opendir opens a directory as a stream + */ +DIR *opendir (const char *name) { - if (pf && pf->is_in_use) + int fd; + if(!name) { - if (pf->eof) - return -1; - return 0; + errno = EINVAL; + return NULL; } - return 0; -} - -int ferror (FILE *pf) -{ - if (pf && pf->is_in_use) + fd = open(name, O_RDONLY|O_DIRECTORY); + if (fd < 0) { - if (pf->error) - return -1; - return 0; + return NULL; } - return 0; + return fdopendir(fd); } -int fileno (FILE *pf) +/** + * creates a stream for an already open directory + */ +DIR *fdopendir (int fd) { - if (pf && pf->is_in_use) - return pf->fd; - errno = EBADF; - return -1; + DIR *dstr; + dstr = (DIR *)malloc(sizeof(DIR)); + if (dstr == NULL) + { + return NULL; + } + memset(dstr, 0, sizeof(DIR)); + SETMAGIC(dstr, DIRSTREAM_MAGIC); + dstr->fileno = fd; + dstr->buf_base = (char *)malloc(DIRBUFSIZE); + if (dstr->buf_base == NULL) + { + dstr->_flags = 0; + free(dstr); + return NULL; + } + dstr->buf_end = dstr->buf_base + DIRBUFSIZE; + dstr->buf_act = dstr->buf_base; + dstr->buf_ptr = dstr->buf_base; + return dstr; } -int remove (const char *path) +/** + * returns the file descriptor for a directory stream + */ +int dirfd (DIR *dir) { - int rc; - struct stat buf; - - rc = stat(path, &buf); - if (S_ISDIR(buf.st_mode)) - return rmdir (path); - return unlink (path); + if (!dir || !ISMAGICSET(dir, DIRSTREAM_MAGIC)) + { + errno = EBADF; + return -1; + } + return dir->fileno; } -void setbuf (FILE *pf, char *buf) +/** + * readdir wrapper + */ +struct dirent *readdir (DIR *dir) { - setvbuf(pd, buf, buf ? _IOFBF : _IONBF, BUFSIZ); -} + struct dirent64 *de64; -void setbuffer (FILE *pf, char *buf, size_t size) -{ - setvbuf(pd, buf, buf ? _IOFBF : _IONBF, size); + de64 = readdir64(dir); + if (de64 == NULL) + { + return NULL; + } + /* linux hard defines d_name to 256 bytes */ + /* if others don't should replace with a define */ + memcpy(dir->de.d_name, de64->d_name, 256); + dir->de.d_ino = de64->d_ino; + /* these are system specific fields from the dirent */ +#ifdef _DIRENT_HAVE_D_NAMELEN + dir->de.d_namelen = strnlen(de64->d_name, 256); +#endif +#ifdef _DIRENT_HAVE_D_OFF + dir->de.d_off = de64->d_off; +#endif +#ifdef _DIRENT_HAVE_D_RECLEN + dir->de.d_reclen = de64->d_reclen; +#endif +#ifdef _DIRENT_HAVE_D_TYPE + dir->de.d_type = de64->d_type; +#endif + return &dir->de; } -void setlinbuf (FILE *pf) -{ - setvbuf(pd, (chat *)NULL, buf ? _IOLBF : 0); -} +/** + * reads a single dirent64 in buffered mode from a stream + * + * getdents is not defined in libc, though it is a linux + * system call and we define it in the usr lib + */ -int setvbuf (FILE *pf, char *buf, int mode, size_t size) -{ -} +int getdents(int fd, struct dirent *buf, size_t size); +int getdents64(int fd, struct dirent64 *buf, size_t size); -FILE *tmpfile(void) +struct dirent64 *readdir64 (DIR *dir) { + struct dirent64 *rval; + if (!dir || !ISMAGICSET(dir, DIRSTREAM_MAGIC)) + { + errno = EBADF; + return NULL; + } + if (dir->buf_ptr >= dir->buf_act) + { + int bytes_read; + /* read a block of dirent64s into the buffer */ + bytes_read = getdents64(dir->fileno, (struct dirent64 *)dir->buf_base, + (dir->buf_end - dir->buf_base)); + dir->buf_act = dir->buf_base + bytes_read; + dir->buf_ptr = dir->buf_base; + } + rval = (struct dirent64 *)dir->buf_ptr; +#ifdef _DIRENT_HAVE_D_RECLEN + dir->buf_ptr += rval->d_reclen; +#else + dir->buf_ptr += sizeof(struct dirent64); +#endif + return rval; } -DIR *opendir (const char *name) +/** + * rewinds a directory stream + */ +void rewinddir (DIR *dir) { + off64_t filepos; + if (!dir || !ISMAGICSET(dir, DIRSTREAM_MAGIC)) + { + errno = EBADF; + return; + } + filepos = lseek64(dir->fileno, 0, SEEK_CUR); + if ((filepos - (dir->buf_act - dir->buf_base)) == 0) + { + dir->buf_ptr = dir->buf_base; + } + else + { + dir->buf_act = dir->buf_base; + dir->buf_ptr = dir->buf_base; + lseek64(dir->fileno, 0, SEEK_SET); + } } -int dirfd (DIR *dir) +/** + * seeks in a directory stream + */ +void seekdir (DIR *dir, off_t offset) { + off64_t filepos; + if (!dir || !ISMAGICSET(dir, DIRSTREAM_MAGIC)) + { + errno = EBADF; + return; + } + filepos = lseek64(dir->fileno, 0, SEEK_CUR); + if ((filepos - (dir->buf_act - dir->buf_base)) <= offset && + filepos >= offset) + { + dir->buf_ptr = dir->buf_act - (filepos - offset); + } + else + { + dir->buf_act = dir->buf_base; + dir->buf_ptr = dir->buf_base; + lseek64(dir->fileno, offset, SEEK_SET); + } } -int readdir (unsigned in fd, sruct dirent *dirp, unsigned in count) +/** + * returns current position in a direcotry stream + */ +off_t telldir (DIR *dir) { + off64_t filepos; + if (!dir || !ISMAGICSET(dir, DIRSTREAM_MAGIC)) + { + errno = EBADF; + return -1; + } + filepos = lseek64(dir->fileno, 0, SEEK_CUR); + if (filepos == -1) + { + return -1; + } + return filepos - (dir->buf_act - dir->buf_ptr); } -void rewinddir (DIR *dir) +/** + * closes a direcotry stream + */ +int closedir (DIR *dir) { + if (!dir || !ISMAGICSET(dir, DIRSTREAM_MAGIC)) + { + errno = EBADF; + return -1; + } + free(dir->buf_base); + dir->_flags = 0; + free(dir); + return 0; } -int scandir (const char *dir, struct dirent ***namelist, +int scandir (const char *dir, + struct dirent ***namelist, int(*filter)(const struct dirent *), - int(*compar)(const struct dirent **,cost struct dirent **)) -{ -} - -void seekdir (DIR *dir, off_t offset) + int(*compar)(const void *, const void *)) { + struct dirent *de; + DIR *dp; + int len, i, rc; + int asz = ASIZE; + + /* open directory */ + dp = opendir(dir); + /* allocate namelist */ + *namelist = (struct dirent **)malloc(asz * sizeof(struct dirent *)); + if (!*namelist) + { + return -1; + } + /* loop through the dirents */ + for(i = 0, de = readdir(dp); de; i++, de = readdir(dp)) + { + if (!filter || filter(de)) + { + if (i >= asz) + { + struct dirent **darray; + /* ran out of space, realloc */ + darray = (struct dirent **)realloc(*namelist, asz + ASIZE); + if (!rc) + { + int j; + for (j = 0; j < i; j++) + { + free(*namelist[j]); + } + free(*namelist); + return -1; + } + *namelist = darray; + asz += ASIZE; + } + /* find the size of this entry */ + len = strnlen((*namelist)[i]->d_name, NAME_MAX + 1) + + sizeof(struct dirent); + /* add to namelist */ + *namelist[i] = (struct dirent *)malloc(len); + memcpy((*namelist)[i], de, len); + } + } + /* now sort entries */ + qsort(*namelist, i, sizeof(struct dirent *), compar); + rc = closedir(dp); + if (rc == -1) + { + return -1; + } + return i; } -off_t telldir (DIR *dir) +/** + * 64 bit version of scandir + * + * TODO: Would prefer not to copy code - modify to a generic version + * and then call from two wrapper versions would be beter + * pass in a flag to control the copy of the dirent into the array + */ +int scandir64 (const char *dir, + struct dirent64 ***namelist, + int(*filter)(const struct dirent64 *), + int(*compar)(const void *, const void *)) { + struct dirent64 *de; + DIR *dp; + int len, i, rc; + int asz = ASIZE; + + /* open directory */ + dp = opendir(dir); + /* allocate namelist */ + *namelist = (struct dirent64 **)malloc(asz * sizeof(struct dirent64 *)); + if (!*namelist) + { + return -1; + } + /* loop through the dirents */ + for(i = 0, de = readdir64(dp); de; i++, de = readdir64(dp)) + { + if (!filter || filter(de)) + { + if (i >= asz) + { + struct dirent64 **darray; + /* ran out of space, realloc */ + darray = (struct dirent64 **)realloc(*namelist, asz + ASIZE); + if (!rc) + { + int j; + for (j = 0; j < i; j++) + { + free(*namelist[j]); + } + free(*namelist); + return -1; + } + *namelist = darray; + asz += ASIZE; + } + /* find the size of this entry */ + len = strnlen((*namelist)[i]->d_name, NAME_MAX + 1) + + sizeof(struct dirent64); + /* add to namelist */ + (*namelist)[i] = (struct dirent64 *)malloc(len); + memcpy((*namelist)[i], de, len); + } + } + /* now sort entries */ + qsort(*namelist, i, sizeof(struct dirent64 *), compar); + rc = closedir(dp); + if (rc == -1) + { + return -1; + } + return i; } -int closedir (DIR *dir) +static void init_stdio(void) { -} - - -/* tmpname ??? */ + static int init_flag = 0; + if (init_flag) + { + return; + } + init_flag = 1; + /* init open file chain */ + lock_init_stream(&open_files); + /* init pointers to glibc stdio calls */ + stdio_ops.fopen = dlsym(RTLD_NEXT, "fopen" ); + stdio_ops.fdopen = dlsym(RTLD_NEXT, "fdopen" ); + stdio_ops.freopen = dlsym(RTLD_NEXT, "freopen" ); + stdio_ops.fwrite = dlsym(RTLD_NEXT, "fwrite" ); + stdio_ops.fread = dlsym(RTLD_NEXT, "fread" ); + stdio_ops.fclose = dlsym(RTLD_NEXT, "fclose" ); + stdio_ops.fseek = dlsym(RTLD_NEXT, "fseek" ); + stdio_ops.fseek64 = dlsym(RTLD_NEXT, "fseek64" ); + stdio_ops.fsetpos = dlsym(RTLD_NEXT, "fsetpos" ); + stdio_ops.rewind = dlsym(RTLD_NEXT, "rewind" ); + stdio_ops.ftell = dlsym(RTLD_NEXT, "ftell" ); + stdio_ops.ftell64 = dlsym(RTLD_NEXT, "ftell64" ); + stdio_ops.fgetpos = dlsym(RTLD_NEXT, "fgetpos" ); + stdio_ops.fflush = dlsym(RTLD_NEXT, "fflush" ); + stdio_ops.fputc = dlsym(RTLD_NEXT, "fputc" ); + stdio_ops.fputs = dlsym(RTLD_NEXT, "fputs" ); + stdio_ops.putc = dlsym(RTLD_NEXT, "putc" ); + stdio_ops.putchar = dlsym(RTLD_NEXT, "putchar" ); + stdio_ops.puts = dlsym(RTLD_NEXT, "puts" ); + stdio_ops.fgets = dlsym(RTLD_NEXT, "fgets" ); + stdio_ops.fgetc = dlsym(RTLD_NEXT, "fgetc" ); + stdio_ops.getc = dlsym(RTLD_NEXT, "getc" ); + stdio_ops.getchar = dlsym(RTLD_NEXT, "getchar" ); + stdio_ops.gets = dlsym(RTLD_NEXT, "gets" ); + stdio_ops.ungetc = dlsym(RTLD_NEXT, "ungetc" ); + stdio_ops.vfprintf = dlsym(RTLD_NEXT, "vfprintf" ); + stdio_ops.vprintf = dlsym(RTLD_NEXT, "vprintf" ); + stdio_ops.fprintf = dlsym(RTLD_NEXT, "fprintf" ); + stdio_ops.printf = dlsym(RTLD_NEXT, "printf" ); + stdio_ops.fscanf = dlsym(RTLD_NEXT, "fscanf" ); + stdio_ops.scanf = dlsym(RTLD_NEXT, "scanf" ); + stdio_ops.clearerr = dlsym(RTLD_NEXT, "clearerr" ); + stdio_ops.feof = dlsym(RTLD_NEXT, "feof" ); + stdio_ops.ferror = dlsym(RTLD_NEXT, "ferror" ); + stdio_ops.fileno = dlsym(RTLD_NEXT, "fileno" ); + stdio_ops.remove = dlsym(RTLD_NEXT, "remove" ); + stdio_ops.setbuf = dlsym(RTLD_NEXT, "setbuf" ); + stdio_ops.setbuffer = dlsym(RTLD_NEXT, "setbuffer" ); + stdio_ops.setlinebuf = dlsym(RTLD_NEXT, "setlinebuf" ); + stdio_ops.setvbuf = dlsym(RTLD_NEXT, "setvbuf" ); + stdio_ops.mkdtemp = dlsym(RTLD_NEXT, "mkdtemp" ); + stdio_ops.mkstemp = dlsym(RTLD_NEXT, "mkstemp" ); + stdio_ops.tmpfile = dlsym(RTLD_NEXT, "tmpfile" ); + stdio_ops.opendir = dlsym(RTLD_NEXT, "opendir" ); + stdio_ops.fdopendir = dlsym(RTLD_NEXT, "fdopendir" ); + stdio_ops.dirfd = dlsym(RTLD_NEXT, "dirfd" ); + stdio_ops.readdir = dlsym(RTLD_NEXT, "readdir" ); + stdio_ops.readdir64 = dlsym(RTLD_NEXT, "readdir64" ); + stdio_ops.rewinddir = dlsym(RTLD_NEXT, "rewinddir" ); + stdio_ops.seekdir = dlsym(RTLD_NEXT, "seekdir" ); + stdio_ops.telldir = dlsym(RTLD_NEXT, "telldir" ); + stdio_ops.closedir = dlsym(RTLD_NEXT, "closedir" ); + stdio_ops.scandir = dlsym(RTLD_NEXT, "scandir" ); + stdio_ops.scandir64 = dlsym(RTLD_NEXT, "scandir64" ); +}; /* * Local variables: diff --git a/src/client/usrint/usrint.h b/src/client/usrint/usrint.h index c1489ce..6042db8 100644 --- a/src/client/usrint/usrint.h +++ b/src/client/usrint/usrint.h @@ -1,38 +1,115 @@ - +/* + * (C) 2011 Clemson University and The University of Chicago + * + * See COPYING in top-level directory. + */ + +/** \file + * \ingroup usrint + * + * PVFS2 user interface routines + */ #ifndef USRINT_H #define USRINT_H 1 -#define _LARGEFILE64_SOURCE 1 +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif +#ifndef _LARGEFILE64_SOURCE +#define _LARGEFILE64_SOURCE +#endif + +#ifdef USRINT_SOURCE +#ifdef _FILE_OFFSET_BITS +#undef _FILE_OFFSET_BITS +#endif +#else +#ifndef _FILE_OFFSET_BITS +#define _FILE_OFFSET_BITS 64 +#endif +#endif + +#define __USE_MISC 1 +#define __USE_ATFILE 1 +#define __USE_GNU 1 + +#include + +#include +#include #include +#ifdef HAVE_UNISTD_H +#include +#endif +#ifdef HAVE_STDLIB_H #include +#endif #include #include +#include #include +#ifdef HAVE_STDARG_H #include +#endif #include #include -#include +#ifdef HAVE_SYS_TYPES_H #include +#endif +#include +#ifdef HAVE_SYS_SOCKET_H +#include +#endif #include -/* #include /* struct statfs on OS X */ +#include +/* #include */ /* struct statfs on OS X */ +#ifdef HAVE_SYS_VFS_H #include /* struct statfs on Linux */ +#endif +#ifdef HAVE_SYS_STAT_H #include +#endif +#include + #include -#include -#define __USE_ATFILE 1 -#include +#ifdef HAVE_ATTR_XATTR_H +#include +#else +#ifdef HAVE_SYS_ATTR_H +#include +#else +#define XATTR_CREATE 0x1 +#define XATTR_REPLACE 0x2 +extern int (*setxattr)(const char *path, const char *name, + const void *value, size_t size, int flags); +extern int (*lsetxattr)(const char *path, const char *name, + const void *value, size_t size, int flags); +extern int (*fsetxattr)(int fd, const char *name, + const void *value, size_t size, int flags); +extern int (*getxattr)(const char *path, const char *name, + void *value, size_t size); +extern int (*lgetxattr)(const char *path, const char *name, + void *value, size_t size); +extern int (*fgetxattr)(int fd, const char *name, void *value, size_t size); +extern int (*listxattr)(const char *path, char *list, size_t size); +extern int (*llistxattr)(const char *path, char *list, size_t size); +extern int (*flistxattr)(int fd, char *list, size_t size); +extern int (*removexattr)(const char *path, const char *name); +extern int (*lremovexattr)(const char *path, const char *name); +extern int (*fremovexattr)(int fd, const char *name); +#endif +#endif + +/* #include diff source need diff versions */ #include -#include -#define __USE_GNU 1 #include //#include + +/* PVFS specific includes */ #include #include - -#include - -#define _GNU_SOURCE +#include /* magic numbers for PVFS filesystem */ #define PVFS_FS 537068840 @@ -45,150 +122,94 @@ #ifndef O_NOFOLLOW #define O_NOFOLLOW 0 #endif -#define max(x, y) (((x) > (y)) ? (x) : (y)) #define true 1 #define false 0 -#define O_HINTS 02000000 - -/* POSIX functions */ - -typedef struct posix_ops_s -{ - int (*statfs)(const char *path, struct statfs *buf); - int (*open)(const char *path, int flags, ...); - int (*open64)(const char *path, int flags, ...); - int (*openat)(int dirfd, const char *path, int flags, ...); - int (*openat64)(int dirfd, const char *path, int flags, ...); - int (*creat)(const char *path, mode_t mode, ...); - int (*creat64)(const char *path, mode_t mode, ...); - int (*unlink)(const char *path); - int (*unlinkat)(int dirfd, const char *path); - int (*rename)(const char *oldpath, const char *newpath); - int (*renameat)(int olddirfd, const char *oldpath, - int newdirfd, const char *newpath); - ssize_t (*read)( int fd, void *buf, size_t count); - ssize_t (*pread)( int fd, void *buf, size_t count, off_t offset); - ssize_t (*readv)(int fd, const struct iovec *vector, int count); - ssize_t (*pread64)( int fd, void *buf, size_t count, off64_t offset); - ssize_t (*write)( int fd, void *buf, size_t count); - ssize_t (*pwrite)( int fd, void *buf, size_t count, off_t offset); - ssize_t (*writev)( int fd, const struct iovec *vector, int count); - ssize_t (*write64)( int fd, void *buf, size_t count, off64_t offset); - off_t (*lseek)(int fd, off_t offset, int whence); - off64_t (*lseek64)(int fd, off64_t offset, int whence); - int (*truncate)(const char *path, off_t length); - int (*truncate64)(const char *path, off64_t length); - int (*ftruncate)(int fd, off_t length); - int (*ftruncate64)(int fd, off64_t length); - int (*close)( int fd); - int (*flush)(int fd); - int (*stat)(const char *path, struct stat *buf); - int (*stat64)(const char *path, struct stat64 *buf); - int (*fstat)(int fd, struct stat *buf); - int (*fstat64)(int fd, struct stat64 *buf); - int (*fstatat)(int fd, char *path, struct stat *buf, int flag); - int (*fstatat64)(int fd, char *path, struct stat64 *buf, int flag); - int (*lstat)(const char *path, struct stat *buf); - int (*lstat64)(const char *path, struct stat64 *buf); - int (*dup)(int oldfd); - int (*dup2)(int oldfd, int newfd); - int (*chown)(const char *path, uid_t owner, gid_t group); - int (*fchown)(int fd, uid_t owner, gid_t group); - int (*fchownat)(int fd, char *path, uid_t owner, gid_t group, int flag); - int (*lchown)(const char *path, uid_t owner, gid_t group); - int (*chmod)(const char *path, mode_t mode); - int (*fchmod)(int fd, mode_t mode); - int (*fchmodat)(int fd, char *path, mode_t mode, int flag); - int (*lchmod)(const char *path, mode_t mode); - int (*mkdir)(const char *path, mode_t mode); - int (*mkdirat)(int dirfd, const char *path, mode_t mode); - int (*rmdir)(const char *path); - ssize_t (*readlink)(const char *path, char *buf, size_t bufsiz); - int (*readlinkat)(int dirfd, const char *path, char *buf, size_t bufsiz); - ssize_t (*symlink)(const char *oldpath, const char *newpath); - int (*symlinkat)(const char *oldpath, int newdirfd, const char *newpath); - ssize_t (*link)(const char *oldpath, const char *newpath); - int (*linkat)(const char *oldpath, int newdirfd, - const char *newpath, int flags); - int (*readdir)(unsigned int fd, struct dirent *dirp, unsigned int count); - int (*getdents)(unsigned int fd, struct dirent *dirp, unsigned int count); - int (*access)(const char * path, int mode); - int (*faccessat)(int dirfd, const char * path, int mode, int flags); - int (*flock)(int fd, int op); - int (*fcntl)(int fd, int cmd, ...); - void (*sync)(void); - int (*fsync)(int fd); - int (*fdatasync)(int fd); - mode_t (*umask)(mode_t mask); - mode_t (*getumask)(void); - int (*getdtablesize)(void); -} posix_ops; - -extern posix_ops glibc_ops; -extern posix_ops pvfs_ops; - -/* PVFS Descriptor table entry */ -typedef struct pvfs_descriptor_s { - int fd; /* file number in PVFS descriptor_table */ - int dup_cnt; /* number of table slots with this des */ - posix_ops *fsops; /* syscalls to use for this file */ - int posix_fd; /* non-PVFS files, the true file number */ - PVFS_object_ref pvfs_ref; /* PVFS fs_id and handle for PVFS file */ - int flags; /* the open flags used for this file */ - off64_t file_pointer; /* offset from the beginning of the file */ - char is_in_use; /* true if this descriptor is valid */ - /* stdio fields */ - char dirty; /* buffer has changed data in it */ - char eof; /* true if tried to read past EOF */ - char error; /* true if an error occured */ - char *buf; /* beginning of buffer */ - size_t buftotal; /* number of valid bytes in buffer */ - size_t bufsize; /* the size of the buffer */ - off64_t buf_off; /* offset in file that buffer holds */ - char *bufptr; /* convenient pointer into the buffer */ -} pvfs_descriptor; - -typedef struct pvfs_descriptor_s PFILE; /* these are for posix interface */ -typedef struct pvfs_descriptor_s PDIR; - -#include -#include - -/* These are the standard function we are overloading in this lib */ -#if 0 -int open(const char *path, int flags, ...); -int open64(const char *path, int flags, ...); -ssize_t write(int fd, const void *buf, size_t count); -ssize_t read(int fd, void *buf, size_t count); -off_t lseek(int fd, off_t offset, int whence); -off64_t lseek64(int fd, off64_t offset, int whence); -ssize_t pread(int fd, void *buf, size_t nbytes, off_t offset); -ssize_t pwrite(int fd, const void *buf, size_t nbytes, off_t offset); -ssize_t readv(int fd, const struct iovec *iov, int iovcnt); -ssize_t writev(int fd, const struct iovec *iov, int iovcnt) ; -int unlink(const char *path); -int close(int fd); - -FILE * fopen(const char * path, const char * mode) ; -size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream); -size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream); -int fprintf(FILE *stream, const char *format, ...); -int fputs(const char *s, FILE *stream); -int fputc(int c, FILE *stream); -int fgetc(FILE *stream); -char *fgets(char *s, int size, FILE *stream); -void rewind(FILE *stream); -int fflush(FILE *stream); -int getc(FILE *stream); -int ungetc(int c, FILE *stream); -int fclose(FILE *stream); +#define O_HINTS 02000000 /* PVFS hints are present */ +#define O_NOTPVFS 04000000 /* Open non-PVFS files if possible */ + +/* constants for this library */ +/* size of stdio default buffer - starting at 1Meg */ +#define PVFS_BUFSIZE (1024*1024) + +/* extra function prototypes */ +int fseek64(FILE *stream, const off64_t offset, int whence); + +off64_t ftell64(FILE *stream); + +int pvfs_convert_iovec(const struct iovec *vector, + int count, + PVFS_Request *req, + void **buf); /* MPI functions */ -int MPI_File_open(MPI_Comm comm, char *filename, int amode, MPI_Info info, MPI_File *mpi_fh); -int MPI_File_write(MPI_File mpi_fh, void *buf, int count, MPI_Datatype datatype, MPI_Status *status); +//int MPI_File_open(MPI_Comm comm, char *filename, +// int amode, MPI_Info info, MPI_File *mpi_fh); +//int MPI_File_write(MPI_File mpi_fh, void *buf, +// int count, MPI_Datatype datatype, MPI_Status *status); + +/* Macros */ + +/* debugging */ + +//#define USRINT_DEBUG +#ifdef USRINT_DEBUG +#define debug(s,v) fprintf(stderr,s,v) +#else +#define debug(s,v) +#endif + +/* FD sets */ + +#ifdef FD_SET +#undef FD_SET +#endif +#define FD_SET(d,fdset) \ +do { \ + pvfs_descriptor *pd; \ + pd = pvfs_find_descriptor(d); \ + if (pd) \ + { \ + __FD_SET(pd->true_fd,(fdset)); \ + } \ +} while(0) + +#ifdef FD_CLR +#undef FD_CLR #endif +#define FD_CLR(d,fdset) \ +do { \ + pvfs_descriptor *pd; \ + pd = pvfs_find_descriptor(d); \ + if (pd) \ + { \ + __FD_CLR(pd->true_fd,(fdset)); \ + } \ +} while(0) + +#ifdef FD_ISSET +#undef FD_ISSET +#endif +#define FD_ISSET(d,fdset) \ +do { \ + pvfs_descriptor *pd; \ + pd = pvfs_find_descriptor(d); \ + if (pd) \ + { \ + __FD_ISSET(pd->true_fd,(fdset));\ + } \ +} while(0) //typedef uint64_t off64_t; #endif + +/* + * Local variables: + * c-indent-level: 4 + * c-basic-offset: 4 + * End: + * + * vim: ts=8 sts=4 sw=4 expandtab + */ + diff --git a/src/common/dotconf/dotconf.c b/src/common/dotconf/dotconf.c index 3e3ac38..abc57be 100644 --- a/src/common/dotconf/dotconf.c +++ b/src/common/dotconf/dotconf.c @@ -31,6 +31,11 @@ #include #include +/* Windows support added by Sam Sampson */ +#ifdef WIN32 +#include +#endif + /* Added by Stephen W. Boyer * for wildcard support in Include file paths */ @@ -54,12 +59,19 @@ #include #include +#ifndef WIN32 #include #include +#endif #include #include "./dotconf.h" +#ifdef WIN32 +#define snprintf _snprintf +#define strcasecmp stricmp +#endif + #ifndef MIN #define MIN(a,b) ((a)<(b)?(a):(b)) #endif @@ -864,7 +876,11 @@ configfile_t *PINT_dotconf_create( PINT_dotconf_register_options(new, options); if (new->flags & CASE_INSENSITIVE) +#ifdef WIN32 + new->cmp_func = strnicmp; +#else new->cmp_func = strncasecmp; +#endif else new->cmp_func = strncmp; @@ -1130,10 +1146,17 @@ int PINT_dotconf_handle_question_mark( char *ext) { configfile_t *included; +#ifdef WIN32 + HANDLE dh, hfile; + WIN32_FIND_DATA find_data; +#else DIR *dh = 0; struct dirent *dirptr = 0; +#endif int i; + char d_name[CFG_MAX_FILENAME]; + char new_pre[CFG_MAX_FILENAME]; char already_matched[CFG_MAX_FILENAME]; @@ -1152,15 +1175,30 @@ int PINT_dotconf_handle_question_mark( pre_len = strlen(pre); +#ifdef WIN32 + if ((dh = FindFirstFile(path, &find_data)) != INVALID_HANDLE_VALUE) +#else if ((dh = opendir(path)) != NULL) +#endif { +#ifdef WIN32 + do +#else while ((dirptr = readdir(dh)) != NULL) - { - match_state = PINT_dotconf_question_mark_match(dirptr->d_name, pre, ext); +#endif + { +#ifdef WIN32 + if ((find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) + continue; + strcpy(d_name, find_data.cFileName); +#else + strcpy(d_name, dirptr->d_name); +#endif + match_state = PINT_dotconf_question_mark_match(d_name, pre, ext); if (match_state >= 0) { - name_len = strlen(dirptr->d_name); + name_len = strlen(d_name); new_path_len = strlen(path) + name_len + strlen(ext) + 1; if (!alloced) @@ -1189,9 +1227,8 @@ int PINT_dotconf_handle_question_mark( } if (match_state == 1) - { - - strncpy(new_pre, dirptr->d_name, + { + strncpy(new_pre, d_name, (name_len > pre_len) ? (pre_len + 1) : pre_len); new_pre[(name_len > pre_len) ? (pre_len + 1) : pre_len] = '\0'; @@ -1232,15 +1269,32 @@ int PINT_dotconf_handle_question_mark( } - sprintf(new_path, "%s%s", path, dirptr->d_name); - + sprintf(new_path, "%s%s", path, d_name); + +#ifdef WIN32 + hfile = CreateFile(new_path, + GENERIC_READ, + FILE_SHARE_READ, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL); + if (hfile != INVALID_HANDLE_VALUE) + { + CloseHandle(hfile); + } + else +#else if (access(new_path, R_OK)) +#endif { PINT_dotconf_warning(cmd->configfile, DCLOG_WARNING, ERR_INCLUDE_ERROR, "Cannot open %s for inclusion.\n" "IncludePath is '%s'\n", new_path, cmd->configfile->includepath); + free(new_path); + return -1; } @@ -1263,8 +1317,13 @@ int PINT_dotconf_handle_question_mark( } } +#ifdef WIN32 + while (FindNextFile(dh, &find_data)); + FindClose(dh); +#else closedir(dh); +#endif free(new_path); } @@ -1281,8 +1340,14 @@ int PINT_dotconf_handle_star( char *ext) { configfile_t *included; +#ifdef WIN32 + HANDLE dh, hfile; + WIN32_FIND_DATA find_data; +#else DIR *dh = 0; struct dirent *dirptr = 0; +#endif + char d_name[CFG_MAX_FILENAME]; char new_pre[CFG_MAX_FILENAME]; char new_ext[CFG_MAX_FILENAME]; @@ -1326,18 +1391,34 @@ int PINT_dotconf_handle_star( strncpy(new_ext, s_ext, t_ext_count); new_ext[t_ext_count] = '\0'; +#ifdef WIN32 + if ((dh = FindFirstFile(path, &find_data)) != INVALID_HANDLE_VALUE) +#else if ((dh = opendir(path)) != NULL) +#endif { +#ifdef WIN32 + do +#else while ((dirptr = readdir(dh)) != NULL) +#endif { - sub_count = 0; +#ifdef WIN32 + if ((find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) + continue; + + strcpy(d_name, find_data.cFileName); +#else + strcpy(d_name, dirptr->d_name); +#endif + sub_count = 0; t_ext_count = 0; - match_state = PINT_dotconf_star_match(dirptr->d_name, pre, s_ext); + match_state = PINT_dotconf_star_match(d_name, pre, s_ext); if (match_state >= 0) { - name_len = strlen(dirptr->d_name); + name_len = strlen(d_name); new_path_len = strlen(path) + name_len + strlen(s_ext) + 1; if (!alloced) @@ -1369,12 +1450,12 @@ int PINT_dotconf_handle_star( { if ((sub = - strstr((dirptr->d_name + pre_len), new_ext)) == NULL) + strstr((d_name + pre_len), new_ext)) == NULL) { continue; } - while (sub != dirptr->d_name) + while (sub != d_name) { sub--; sub_count++; @@ -1385,7 +1466,7 @@ int PINT_dotconf_handle_star( continue; } - strncpy(new_pre, dirptr->d_name, (sub_count + t_ext_count)); + strncpy(new_pre, d_name, (sub_count + t_ext_count)); new_pre[sub_count + t_ext_count] = '\0'; strcat(new_pre, new_ext); @@ -1425,15 +1506,32 @@ int PINT_dotconf_handle_star( } - sprintf(new_path, "%s%s", path, dirptr->d_name); - + sprintf(new_path, "%s%s", path, d_name); + +#ifdef WIN32 + hfile = CreateFile(new_path, + GENERIC_READ, + FILE_SHARE_READ, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL); + if (hfile != INVALID_HANDLE_VALUE) + { + CloseHandle(hfile); + } + else +#else if (access(new_path, R_OK)) +#endif { PINT_dotconf_warning(cmd->configfile, DCLOG_WARNING, ERR_INCLUDE_ERROR, "Cannot open %s for inclusion.\n" "IncludePath is '%s'\n", new_path, cmd->configfile->includepath); + free(new_path); + return -1; } @@ -1452,8 +1550,13 @@ int PINT_dotconf_handle_star( } } +#ifdef WIN32 + while (FindNextFile(dh, &find_data)); + FindClose(dh); +#else closedir(dh); +#endif free(new_path); } @@ -1467,6 +1570,10 @@ DOTCONF_CB(dotconf_cb_include) char *filename = 0; configfile_t *included; +#ifdef WIN32 + HANDLE hfile; +#endif + char wild_card; char *path = 0; char *pre = 0; @@ -1519,8 +1626,22 @@ DOTCONF_CB(dotconf_cb_include) free(filename); return NULL; } - +#ifdef WIN32 + hfile = CreateFile(filename, + GENERIC_READ, + FILE_SHARE_READ, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL); + if (hfile != INVALID_HANDLE_VALUE) + { + CloseHandle(hfile); + } + else +#else if (access(filename, R_OK)) +#endif { PINT_dotconf_warning(cmd->configfile, DCLOG_WARNING, ERR_INCLUDE_ERROR, "Cannot open %s for inclusion.\n" diff --git a/src/common/events/debug.h b/src/common/events/debug.h index 1bc70e6..610051d 100644 --- a/src/common/events/debug.h +++ b/src/common/events/debug.h @@ -1,6 +1,6 @@ /************************************* * File : debug.h - * Version : $Id: debug.h,v 1.2 2008/11/20 01:16:52 slang Exp $ + * Version : $Id: debug.h,v 1.2 2008-11-20 01:16:52 slang Exp $ ************************************/ /* Author: Aroon Nataraj */ diff --git a/src/common/events/fmt_fsm.c b/src/common/events/fmt_fsm.c index db8183f..a67e447 100644 --- a/src/common/events/fmt_fsm.c +++ b/src/common/events/fmt_fsm.c @@ -1,6 +1,6 @@ /***************************************************** * File : fmt_fsm.cpp - * Version : $Id: fmt_fsm.c,v 1.2 2008/11/20 01:16:52 slang Exp $ + * Version : $Id: fmt_fsm.c,v 1.2 2008-11-20 01:16:52 slang Exp $ ****************************************************/ /* Author: Aroon Nataraj */ diff --git a/src/common/events/fmt_fsm.h b/src/common/events/fmt_fsm.h index 1c7b50a..6bf7555 100644 --- a/src/common/events/fmt_fsm.h +++ b/src/common/events/fmt_fsm.h @@ -1,6 +1,6 @@ /***************************************************** * File : fmt_fsm.h - * Version : $Id: fmt_fsm.h,v 1.2 2008/11/20 01:16:52 slang Exp $ + * Version : $Id: fmt_fsm.h,v 1.2 2008-11-20 01:16:52 slang Exp $ ****************************************************/ /* Author: Aroon Nataraj */ @@ -221,5 +221,5 @@ int ff_format::promoteIntegral(int patn_index, char* src, int src_sz, int *upto, /*************************************************************************** * $RCSfile: fmt_fsm.h,v $ $Author: slang $ - * $Revision: 1.2 $ $Date: 2008/11/20 01:16:52 $ + * $Revision: 1.2 $ $Date: 2008-11-20 01:16:52 $ ***************************************************************************/ diff --git a/src/common/events/pvfs_tau_api.c b/src/common/events/pvfs_tau_api.c index c66a1f4..101ddce 100644 --- a/src/common/events/pvfs_tau_api.c +++ b/src/common/events/pvfs_tau_api.c @@ -1,6 +1,6 @@ /***************************************************** * File : pvfs_tau_api.cpp - * Version : $Id: pvfs_tau_api.c,v 1.2 2008/11/20 01:16:52 slang Exp $ + * Version : $Id: pvfs_tau_api.c,v 1.2 2008-11-20 01:16:52 slang Exp $ ****************************************************/ /* Author: Aroon Nataraj */ diff --git a/src/common/events/pvfs_tau_api.h b/src/common/events/pvfs_tau_api.h index 0d02e32..51564de 100644 --- a/src/common/events/pvfs_tau_api.h +++ b/src/common/events/pvfs_tau_api.h @@ -1,6 +1,6 @@ /***************************************************** * File : pvfs_tau_api.h - * Version : $Id: pvfs_tau_api.h,v 1.2 2008/11/20 01:16:52 slang Exp $ + * Version : $Id: pvfs_tau_api.h,v 1.2 2008-11-20 01:16:52 slang Exp $ ****************************************************/ /* Author: Aroon Nataraj */ diff --git a/src/common/gen-locks/gen-locks.h b/src/common/gen-locks/gen-locks.h index 364a3f4..7859fe5 100644 --- a/src/common/gen-locks/gen-locks.h +++ b/src/common/gen-locks/gen-locks.h @@ -26,9 +26,17 @@ /* this is especially important for development in which case the locks * should really be enabled in order to verify proper operation */ -#if !defined(__GEN_NULL_LOCKING__) && !defined(__GEN_POSIX_LOCKING__) +#if !defined(__GEN_NULL_LOCKING__) +#ifdef WIN32 +#if !defined(__GEN_WIN_LOCKING__) +#define __GEN_WIN_LOCKING__ +#endif +#else +#if !defined(__GEN_POSIX_LOCKING__) #define __GEN_POSIX_LOCKING__ #endif +#endif +#endif #ifdef __GEN_POSIX_LOCKING__ #include @@ -69,6 +77,69 @@ typedef pthread_cond_t gen_cond_t; #define gen_cond_signal(c) gen_posix_cond_signal(c) #define gen_cond_broadcast(c) gen_posix_cond_broadcast(c) +#elif defined (__GEN_WIN_LOCKING__) + +#include + +typedef HANDLE gen_mutex_t; +typedef HANDLE gen_thread_t; + +/* Implementation based on Pthreads-win32 - POSIX Threads Library for Win32 + * Copyright (C) 1998 John E. Bossom + * Copyright (C) 1999,2005 Pthreads-win32 contributors + */ +struct timespec +{ + time_t tv_sec; + long int tv_nsec; +}; + +typedef struct gen_cond_t_ *gen_cond_t; +struct gen_cond_t_ +{ + long nWaitersBlocked; /* Number of threads blocked */ + long nWaitersGone; /* Number of threads timed out */ + long nWaitersToUnblock; /* Number of threads to unblock */ + HANDLE semBlockQueue; /* Queue up threads waiting for the condition to become signalled */ + HANDLE semBlockLock; /* Semaphore that guards access to waiters blocked count/block queue */ + HANDLE mtxUnblockLock; /* Mutex that guards access to waiters (to)unblock(ed) counts */ + gen_cond_t next; /* Doubly linked list */ + gen_cond_t prev; +}; + +int gen_win_mutex_lock(HANDLE *mut); +int gen_win_mutex_unlock(HANDLE *mut); +int gen_win_mutex_trylock(HANDLE *mut); +HANDLE *gen_win_mutex_build(void); +int gen_win_mutex_destroy(HANDLE *mut); +int gen_win_mutex_init(HANDLE *mut); +HANDLE gen_win_thread_self(void); + +#define GEN_MUTEX_INITIALIZER ((gen_mutex_t) -1) +#define gen_mutex_lock(m) gen_win_mutex_lock(m) +#define gen_mutex_unlock(m) gen_win_mutex_unlock(m) +#define gen_mutex_trylock(m) gen_win_mutex_trylock(m) +#define gen_mutex_destroy(m) gen_win_mutex_destroy(m) +#define gen_mutex_init(m) gen_win_mutex_init(m) + +#define gen_thread_self() gen_win_thread_self() + +int gen_win_cond_init(gen_cond_t *cond); +int gen_win_cond_destroy(gen_cond_t *cond); +int gen_win_cond_wait(gen_cond_t *cond, HANDLE *mut); +int gen_win_cond_timedwait(gen_cond_t *cond, HANDLE *mut, + const struct timespec *abstime); +int gen_win_cond_signal(gen_cond_t *cond); +int gen_win_cond_broadcast(gen_cond_t *cond); + +#define GEN_COND_INITIALIZER ((gen_cond_t) -1) +#define gen_cond_init(c) gen_win_cond_init(c) +#define gen_cond_destroy(c) gen_win_cond_destroy(c) +#define gen_cond_wait(c, m) gen_win_cond_wait(c, m) +#define gen_cond_timedwait(c, m, s) gen_win_cond_timedwait(c, m, s) +#define gen_cond_signal(c) gen_win_cond_signal(c) +#define gen_cond_broadcast(c) gen_win_cond_broadcast(c) + #elif defined (__GEN_NULL_LOCKING__) /* this stuff messes around just enough to prevent warnings */ typedef int gen_mutex_t; @@ -132,7 +203,7 @@ static inline int gen_cond_broadcast(gen_cond_t *cond) } #else /* __GEN_NULL_LOCKING__ */ -#error "Must define either POSIX or NULL locking" +#error "Must define either POSIX, Windows or NULL locking" #endif #endif /* __GEN_LOCKS_H */ diff --git a/src/common/gossip/gossip.c b/src/common/gossip/gossip.c index ab4cdaf..5a54a5f 100644 --- a/src/common/gossip/gossip.c +++ b/src/common/gossip/gossip.c @@ -15,10 +15,16 @@ #include #include #include -#include #include #include + +#ifdef WIN32 +#include "wincommon.h" +#else +#include #include +#endif + #include "pvfs2-config.h" #ifdef HAVE_EXECINFO_H #include @@ -49,7 +55,9 @@ int gossip_facility = GOSSIP_STDERR; static FILE *internal_log_file = NULL; /* syslog priority setting */ +#ifndef WIN32 static int internal_syslog_priority = LOG_INFO; +#endif /* what type of timestamp to put on logs */ static enum gossip_logstamp internal_logstamp = GOSSIP_LOGSTAMP_DEFAULT; @@ -83,6 +91,16 @@ static int gossip_disable_syslog( * * \return 0 on success, -errno on failure. */ +#ifdef WIN32 +/** Only a stub on Windows + * TODO: possibly add logging to Windows Event Log + */ +int gossip_enable_syslog( + int priority) +{ + return 0; +} +#else int gossip_enable_syslog( int priority) { @@ -105,6 +123,7 @@ int gossip_enable_syslog( return 0; } +#endif /** Turns on logging to stderr. * @@ -163,6 +182,23 @@ int gossip_enable_file( return 0; } +int gossip_reopen_file( + const char *filename, + const char *mode) +{ + if( gossip_facility != GOSSIP_FILE ) + { + return -EINVAL; + } + + /* close the file */ + gossip_disable_file(); + + /* open the file */ + gossip_enable_file( filename, mode ); + return 0; +} + /** Turns off any active logging facility and disables debugging. * * \return 0 on success, -errno on failure. @@ -408,6 +444,18 @@ void gossip_backtrace(void) * * returns 0 on success, -errno on failure */ +#ifdef WIN32 +/** Only a stub on Windows + * TODO: possibly add logging to Windows Event Log + */ +static int gossip_debug_syslog( + char prefix, + const char *format, + va_list ap) +{ + return 0; +} +#else static int gossip_debug_syslog( char prefix, const char *format, @@ -432,6 +480,7 @@ static int gossip_debug_syslog( return 0; } +#endif int gossip_debug_fp(FILE *fp, char prefix, enum gossip_logstamp ts, const char *format, ...) @@ -457,7 +506,7 @@ static int gossip_debug_fp_va(FILE *fp, char prefix, const char *format, va_list ap, enum gossip_logstamp ts) { char buffer[GOSSIP_BUF_SIZE], *bptr = buffer; - int bsize = sizeof(buffer); + int bsize = sizeof(buffer), temp_size; int ret = -EINVAL; struct timeval tv; time_t tp; @@ -487,10 +536,16 @@ static int gossip_debug_fp_va(FILE *fp, char prefix, gettimeofday(&tv, 0); tp = tv.tv_sec; strftime(bptr, 9, "%H:%M:%S", localtime(&tp)); - sprintf(bptr+8, ".%06ld (%ld)] ", (long)tv.tv_usec, - gen_thread_self()); - bptr += 30; - bsize -= 30; + bptr += 8; +#ifdef WIN32 + temp_size = sprintf(bptr, ".%03ld (%4ld)] ", (long)tv.tv_usec / 1000, + GetThreadId(GetCurrentThread())); +#else + temp_size = sprintf(bptr, ".%06ld (%ld)] ", (long)tv.tv_usec, + gen_thread_self()); +#endif + bptr += temp_size; + bsize -= temp_size; break; case GOSSIP_LOGSTAMP_NONE: @@ -525,6 +580,17 @@ static int gossip_debug_fp_va(FILE *fp, char prefix, * * returns 0 on success, -errno on failure */ +#ifdef WIN32 +/** just a stub on Windows + * TODO: possibly add errors to Windows Event Log + */ +static int gossip_err_syslog( + const char *format, + va_list ap) +{ + return 0; +} +#else static int gossip_err_syslog( const char *format, va_list ap) @@ -541,7 +607,7 @@ static int gossip_err_syslog( return 0; } - +#endif /* gossip_disable_stderr() * @@ -579,12 +645,23 @@ static int gossip_disable_file( * * returns 0 on success, -errno on failure */ +#ifdef WIN32 +/** just a stub on Windows + * TODO: Possibly add logging to Windows Event Log + */ +static int gossip_disable_syslog( + void) +{ + return 0; +} +#else static int gossip_disable_syslog( void) { closelog(); return 0; } +#endif /* * Local variables: diff --git a/src/common/gossip/gossip.h b/src/common/gossip/gossip.h index 533604d..5f24214 100644 --- a/src/common/gossip/gossip.h +++ b/src/common/gossip/gossip.h @@ -20,11 +20,17 @@ #ifndef __GOSSIP_H #define __GOSSIP_H +#ifdef WIN32 +#include "wincommon.h" +#endif + #ifndef __KERNEL__ #include #include +#ifndef WIN32 #include "syslog.h" #endif +#endif #include "pvfs2-config.h" /******************************************************************** @@ -85,6 +91,9 @@ int gossip_enable_stderr( int gossip_enable_file( const char *filename, const char *mode); +int gossip_reopen_file( + const char *filename, + const char *mode); int gossip_disable( void); int gossip_set_debug_mask( @@ -168,6 +177,21 @@ do { \ } while(0) #else /* ! __GNUC__ */ +extern int gossip_debug_on; +extern int gossip_facility; +extern uint64_t gossip_debug_mask; + +#define gossip_perf_log(format, ...) \ +do { \ + if ((gossip_debug_on) && \ + (gossip_debug_mask & GOSSIP_PERFCOUNTER_DEBUG) && \ + (gossip_facility)) \ + { \ + __gossip_debug(GOSSIP_PERFCOUNTER_DEBUG, 'P', \ + format, __VA_ARGS__); \ + } \ +} while(0) + int __gossip_debug( uint64_t mask, char prefix, @@ -183,15 +207,24 @@ int gossip_err( ...); #ifdef GOSSIP_DISABLE_DEBUG +#ifdef WIN32 +#define gossip_debug(__m, __f, ...) __gossip_debug_stub(__m, '?', __f, __VA_ARGS__); +#define gossip_ldebug(__m, __f, ...) __gossip_debug_stub(__m, '?', __f, __VA_ARGS__); +#else #define gossip_debug(__m, __f, f...) __gossip_debug_stub(__m, '?', __f, ##f); #define gossip_ldebug(__m, __f, f...) __gossip_debug_stub(__m, '?', __f, ##f); +#endif #define gossip_debug_enabled(__m) 0 #else +#ifdef WIN32 +#define gossip_debug(__m, __f, ...) __gossip_debug(__m, '?', __f, __VA_ARGS__); +#define gossip_ldebug(__m, __f, ...) __gossip_debug(__m, '?', __f, __VA_ARGS__); +#else #define gossip_debug(__m, __f, f...) __gossip_debug(__m, '?', __f, ##f); #define gossip_ldebug(__m, __f, f...) __gossip_debug(__m, '?', __f, ##f); +#endif #define gossip_debug_enabled(__m) \ ((gossip_debug_on != 0) && (__m & gossip_debug_mask)) - #endif /* GOSSIP_DISABLE_DEBUG */ #define gossip_lerr gossip_err diff --git a/src/common/id-generator/id-generator.c b/src/common/id-generator/id-generator.c index d7d8a85..36ddef9 100644 --- a/src/common/id-generator/id-generator.c +++ b/src/common/id-generator/id-generator.c @@ -6,6 +6,11 @@ #include #include + +#ifdef WIN32 +#include "wincommon.h" +#endif + #include "id-generator.h" #include "quickhash.h" #include "gen-locks.h" diff --git a/src/common/mgmt/pint-worker-threaded-queues.c b/src/common/mgmt/pint-worker-threaded-queues.c index 1359768..2ff3a96 100644 --- a/src/common/mgmt/pint-worker-threaded-queues.c +++ b/src/common/mgmt/pint-worker-threaded-queues.c @@ -74,6 +74,9 @@ static int threaded_queues_init(struct PINT_manager_s *manager, free(w->threads); gen_cond_destroy(&w->cond); } + gossip_debug(GOSSIP_MGMT_DEBUG,"%s:thread_id %d:thread #%d.\n" + ,__func__ + ,(int)w->threads[i].thread_id,i); } exit: @@ -85,12 +88,11 @@ static int threaded_queues_destroy(struct PINT_manager_s *manager, { struct PINT_worker_threaded_queues_s *w; struct PINT_worker_thread_entry * tentry; - int i, count; + int i; w = &inst->threaded; gen_mutex_lock(&w->mutex); - count = w->attr.thread_count; gen_mutex_unlock(&w->mutex); /* stop all threads */ @@ -338,6 +340,12 @@ static void *PINT_worker_queues_thread_function(void * ptr) manager = worker->manager; gen_mutex_unlock(&thread->mutex); + gossip_debug(GOSSIP_MGMT_DEBUG,"%s:thread-id %d:worker location is %p: manager location is %p.\n" + ,__func__ + ,(int)thread->thread_id + ,worker + ,manager); + gen_mutex_lock(&worker->mutex); op_count = worker->attr.ops_per_queue; timeout = worker->attr.timeout; @@ -347,6 +355,11 @@ static void *PINT_worker_queues_thread_function(void * ptr) } gen_mutex_unlock(&worker->mutex); + gossip_debug(GOSSIP_MGMT_DEBUG,"%s:thread-id %d:op-count is %d:timeout is %d.\n" + ,__func__ + ,(int)thread->thread_id + ,op_count + ,timeout); qentries = malloc(sizeof(PINT_queue_entry_t *) * op_count); if(!qentries) { @@ -357,6 +370,9 @@ static void *PINT_worker_queues_thread_function(void * ptr) gen_mutex_lock(&thread->mutex); thread->running = 1; + gossip_debug(GOSSIP_MGMT_DEBUG,"%s: starting thread function for thread_id %d\n" + ,__func__ + ,(int)thread->thread_id); while(thread->running) { /* unlock the thread mutex to allow someone else @@ -421,10 +437,20 @@ static void *PINT_worker_queues_thread_function(void * ptr) if(op_count > 0) { + gossip_debug(GOSSIP_MGMT_DEBUG,"%s:thread_id %d: op_count is %d.\n" + ,__func__ + ,(int)thread->thread_id,op_count); for(i = 0; i < op_count; ++i) { + struct PINT_op_entry *op_entry; + gossip_debug(GOSSIP_MGMT_DEBUG,"%s:thread_id %d: i is %d.\n" + ,__func__ + ,(int)thread->thread_id,i); op = PINT_op_from_qentry(qentries[i]); /* service the operation */ + gossip_debug(GOSSIP_MGMT_DEBUG,"%s:thread_id %d: calling PINT_manager_service_op.\n" + ,__func__ + ,(int)thread->thread_id); ret = PINT_manager_service_op( manager, op, &service_time, &error); if(ret < 0) @@ -433,6 +459,9 @@ static void *PINT_worker_queues_thread_function(void * ptr) goto free_ops; } + gossip_debug(GOSSIP_MGMT_DEBUG,"%s:thread_id %d: calling PINT_manager_complete_op.\n" + ,__func__ + ,(int)thread->thread_id); ret = PINT_manager_complete_op( manager, op, error); if(ret < 0) @@ -440,6 +469,13 @@ static void *PINT_worker_queues_thread_function(void * ptr) /* fatal if we can't complete an op */ goto free_ops; } + op_entry = id_gen_safe_lookup(op->id); + if (op_entry) + { + id_gen_safe_unregister(op_entry->op.id); + free(op_entry); + op_entry = NULL; + } } } } @@ -466,7 +502,7 @@ static void *PINT_worker_queues_thread_function(void * ptr) } /* lock the mutex again before checking the running field */ gen_mutex_lock(&thread->mutex); - } + }/*end while thread->running*/ gen_mutex_unlock(&thread->mutex); diff --git a/src/common/misc/errno-mapping.c b/src/common/misc/errno-mapping.c index e445759..7618634 100644 --- a/src/common/misc/errno-mapping.c +++ b/src/common/misc/errno-mapping.c @@ -12,12 +12,25 @@ #include "pvfs2-util.h" #include "gossip.h" +#ifdef WIN32 +#include "wincommon.h" + +#define snprintf(b, c, f, ...) _snprintf(b, c, f, __VA_ARGS__) + +/* error codes not defined on Windows */ +#define EREMOTE 66 +#define EHOSTDOWN 112 +#endif + #define MAX_PVFS_STRERROR_LEN 256 +/* static global controls whether pvfs_sys calls print user errors */ +static int pvfs_perror_gossip_silent = 0; + /* macro defined in include/pvfs2-types.h */ DECLARE_ERRNO_MAPPING_AND_FN(); -/* +/** the pvfs analog to strerror_r that handles PVFS_error codes as well as errno error codes */ @@ -33,7 +46,7 @@ int PVFS_strerror_r(int errnum, char *buf, int n) } else { -#ifdef HAVE_GNU_STRERROR_R +#if defined(HAVE_GNU_STRERROR_R) || defined(_GNU_SOURCE) char *tmpbuf = strerror_r(tmp, buf, limit); if (tmpbuf && (strcmp(tmpbuf, buf))) { @@ -41,14 +54,16 @@ int PVFS_strerror_r(int errnum, char *buf, int n) strncpy(buf, tmpbuf, (size_t)limit); } ret = (tmpbuf ? 0 : -1); -#else - ret = strerror_r(tmp, buf, (size_t)limit); +#elif defined(WIN32) + ret = (int) strerror_s(buf, (size_t) limit, tmp); +#else + ret = (int)strerror_r(tmp, buf, (size_t)limit); #endif } return ret; } -/* PVFS_perror() +/** PVFS_perror() * * prints a message on stderr, consisting of text argument followed by * a colon, space, and error string for the given retcode. NOTE: also @@ -81,13 +96,33 @@ void PVFS_perror(const char *text, int retcode) return; } -/* PVFS_perror_gossip() +/** silences user error messages from system interface calls + */ +void PVFS_perror_gossip_silent(void) +{ + pvfs_perror_gossip_silent = 1; + return; +} + +/** turns on user error messages from system interface calls + */ +void PVFS_perror_gossip_verbose(void) +{ + pvfs_perror_gossip_silent = 0; + return; +} + +/** PVFS_perror_gossip() * * same as PVFS_perror, except that the output is routed through * gossip rather than stderr */ void PVFS_perror_gossip(const char *text, int retcode) { + if (pvfs_perror_gossip_silent) + { + return; + } if (IS_PVFS_NON_ERRNO_ERROR(-retcode)) { char buf[MAX_PVFS_STRERROR_LEN] = {0}; diff --git a/src/common/misc/extent-utils.c b/src/common/misc/extent-utils.c index be00eff..ce03d70 100644 --- a/src/common/misc/extent-utils.c +++ b/src/common/misc/extent-utils.c @@ -45,7 +45,7 @@ PINT_llist *PINT_create_extent_list(char *extent_str) new_extent->first = cur_extent.first; new_extent->last = cur_extent.last; - + PINT_llist_add_to_tail(extent_list,(void *)new_extent); } } @@ -64,8 +64,13 @@ PINT_llist *PINT_create_extent_list(char *extent_str) */ int PINT_handle_in_extent(PVFS_handle_extent *ext, PVFS_handle handle) { + /* return ((handle > ext->first-1) && - (handle < ext->last+1)); + (handle < ext->last+1)); + */ + /* ext->last may be max, 2^64 - 1 */ + return ((handle >= ext->first) && + (handle <= ext->last)); } /* PINT_handle_in_extent_array() diff --git a/src/common/misc/fsck-utils.c b/src/common/misc/fsck-utils.c index 40f5796..27a817c 100755 --- a/src/common/misc/fsck-utils.c +++ b/src/common/misc/fsck-utils.c @@ -6,7 +6,9 @@ #include #include #include +#ifndef WIN32 #include +#endif #include #include @@ -18,6 +20,140 @@ #define SERVER_CONFIG_BUFFER_SIZE 5000 #define FS_CONFIG_BUFFER_SIZE 10000 +#ifdef WIN32 +int PVFS_fsck_initialize( + const struct PINT_fsck_options* options, + const PVFS_credentials* creds, + const PVFS_fs_id* cur_fs) +{ + return -PVFS_EOPNOTSUPP; +} + +int PVFS_fsck_validate_dfile( + const struct PINT_fsck_options* fsck_options, + const PVFS_handle* handle, + const PVFS_fs_id* cur_fs, + const PVFS_credentials* creds, + PVFS_size* dfile_total_size) +{ + return -PVFS_EOPNOTSUPP; +} + +int PVFS_fsck_validate_dfile_attr( + const struct PINT_fsck_options* fsck_options, + const PVFS_sysresp_getattr* attributes) +{ + return -PVFS_EOPNOTSUPP; +} + +int PVFS_fsck_validate_metafile( + const struct PINT_fsck_options* fsck_options, + const PVFS_object_ref* obj_ref, + const PVFS_sysresp_getattr* attributes, + const PVFS_credentials* creds) +{ + return -PVFS_EOPNOTSUPP; +} + +int PVFS_fsck_validate_metafile_attr( + const struct PINT_fsck_options* fsck_options, + const PVFS_sysresp_getattr* attributes) +{ + return -PVFS_EOPNOTSUPP; +} + +int PVFS_fsck_validate_symlink( + const struct PINT_fsck_options* fsck_options, + const PVFS_object_ref* obj_ref, + const PVFS_sysresp_getattr* attributes) +{ + return -PVFS_EOPNOTSUPP; +} + +int PVFS_fsck_validate_symlink_attr( + const struct PINT_fsck_options* fsck_options, + const PVFS_sysresp_getattr* attributes) +{ + return -PVFS_EOPNOTSUPP; +} + +int PVFS_fsck_validate_symlink_target( + const struct PINT_fsck_options* fsck_options, + const PVFS_sysresp_getattr* attributes) +{ + return -PVFS_EOPNOTSUPP; +} + +int PVFS_fsck_validate_dirdata( + const struct PINT_fsck_options* fsck_options, + const PVFS_handle* handle, + const PVFS_fs_id* cur_fs, + const PVFS_credentials* creds) +{ + return -PVFS_EOPNOTSUPP; +} + +int PVFS_fsck_validate_dirdata_attr( + const struct PINT_fsck_options* fsck_options, + const PVFS_sysresp_getattr* attributes) +{ + return -PVFS_EOPNOTSUPP; +} + +int PVFS_fsck_validate_dir( + const struct PINT_fsck_options* fsck_options, + const PVFS_object_ref* obj_ref, + const PVFS_sysresp_getattr* attributes, + const PVFS_credentials* creds, + PVFS_dirent* directory_entries) +{ + return -PVFS_EOPNOTSUPP; +} + +int PVFS_fsck_validate_dir_attr( + const struct PINT_fsck_options* fsck_options, + const PVFS_sysresp_getattr* attributes) +{ + return -PVFS_EOPNOTSUPP; +} + +int PVFS_fsck_validate_dir_ent( + const struct PINT_fsck_options* fsck_options, + const char* filename) +{ + return -PVFS_EOPNOTSUPP; +} + +int PVFS_fsck_finalize( + const struct PINT_fsck_options* fsck_options, + const PVFS_fs_id* cur_fs, + const PVFS_credentials* cred) +{ + return -PVFS_EOPNOTSUPP; +} + +int PVFS_fsck_get_attributes( + const struct PINT_fsck_options* fsck_options, + const PVFS_object_ref* object_ref, + const PVFS_credentials* cred, + PVFS_sysresp_getattr* sysresp_getattr) +{ + return -PVFS_EOPNOTSUPP; +} + +int PVFS_fsck_check_server_configs( + const struct PINT_fsck_options* fsck_options, + const PVFS_credentials* cred, + const PVFS_fs_id* fs_id) +{ + return -PVFS_EOPNOTSUPP; +} + +#else +/** + * Just stub functions out on Windows + */ + /** \file * \ingroup fsckutils * Implementation of the fsck-utils component. @@ -1656,6 +1792,7 @@ static void set_return_code( *ret = retval; } } +#endif /* WIN32 */ /* @} */ diff --git a/src/common/misc/mmap-ra-cache.c b/src/common/misc/mmap-ra-cache.c index 5e78f18..bfc447d 100644 --- a/src/common/misc/mmap-ra-cache.c +++ b/src/common/misc/mmap-ra-cache.c @@ -9,8 +9,10 @@ #include #include #include +#ifndef WIN32 #include #include +#endif #include "pvfs2.h" #include "gossip.h" diff --git a/src/common/misc/module.mk.in b/src/common/misc/module.mk.in index 105f773..266c148 100644 --- a/src/common/misc/module.mk.in +++ b/src/common/misc/module.mk.in @@ -21,7 +21,8 @@ LIBSRC += $(DIR)/server-config.c \ $(DIR)/fsck-utils.c \ $(DIR)/pint-eattr.c \ $(DIR)/pint-hint.c \ - $(DIR)/pint-mem.c + $(DIR)/pint-mem.c \ + $(DIR)/pint-uid-mgmt.c SERVERSRC += $(DIR)/server-config.c \ $(DIR)/server-config-mgr.c \ $(DIR)/str-utils.c \ @@ -40,7 +41,8 @@ SERVERSRC += $(DIR)/server-config.c \ $(DIR)/msgpairarray.c \ $(DIR)/pint-eattr.c \ $(DIR)/pint-mem.c \ - $(DIR)/pint-hint.c + $(DIR)/pint-hint.c \ + $(DIR)/pint-uid-mgmt.c LIBBMISRC += $(DIR)/str-utils.c \ $(DIR)/pint-event.c \ diff --git a/src/common/misc/msgpairarray.sm b/src/common/misc/msgpairarray.sm index 645eaa5..47f75e1 100644 --- a/src/common/misc/msgpairarray.sm +++ b/src/common/misc/msgpairarray.sm @@ -25,6 +25,20 @@ #include "pvfs2-internal.h" #include "state-machine.h" +#ifdef WIN32 +#define gossip_err_unless_quiet(format, ...) \ +do {\ + if(mop->params.quiet_flag)\ + {\ + gossip_debug(GOSSIP_MSGPAIR_DEBUG, format, __VA_ARGS__); \ + }\ + else \ + {\ + gossip_err(format, __VA_ARGS__); \ + }\ +} while(0) + +#else #define gossip_err_unless_quiet(format, f...) \ do {\ if(mop->params.quiet_flag)\ @@ -32,6 +46,7 @@ do {\ else \ gossip_err(format, ##f); \ } while(0) +#endif enum { @@ -124,7 +139,6 @@ static PINT_sm_action msgpairarray_init( mop->params.comp_ct -= 2; } else msg_p->complete = 0; - } return SM_ACTION_COMPLETE; } diff --git a/src/common/misc/pint-cached-config.c b/src/common/misc/pint-cached-config.c index 462ef5b..7c4f32b 100644 --- a/src/common/misc/pint-cached-config.c +++ b/src/common/misc/pint-cached-config.c @@ -8,10 +8,14 @@ #include #include #include +#ifndef WIN32 #include +#endif #include #include +#ifndef WIN32 #include +#endif #include "pvfs2-types.h" #include "pvfs2-attr.h" @@ -73,7 +77,7 @@ static int hash_fsid_compare( static int cache_server_array(PVFS_fs_id fsid); static int handle_lookup_entry_compare(const void *p1, const void *p2); -static const struct handle_lookup_entry* find_handle_lookup_entry( +const struct handle_lookup_entry* find_handle_lookup_entry( PVFS_handle handle, PVFS_fs_id fsid); static int load_handle_lookup_table( struct config_fs_cache_s *cur_config_fs_cache); @@ -101,7 +105,7 @@ int PINT_cached_config_initialize(void) PINT_fsid_config_cache_table = qhash_init(hash_fsid_compare,hash_fsid,11); } - + /* include time, pid, and hostname in random seed in order to help avoid * collisions on object placement when many clients are launched * concurrently @@ -109,8 +113,11 @@ int PINT_cached_config_initialize(void) gettimeofday(&tv, NULL); seed += tv.tv_sec; seed += tv.tv_usec; - +#ifdef WIN32 + seed += GetCurrentProcessId(); +#else seed += getpid(); +#endif ret = gethostname(hostname, HOST_NAME_MAX); if(ret == 0) @@ -259,7 +266,7 @@ int PINT_cached_config_handle_load_mapping( cur_config_fs_cache->fs->meta_handle_ranges; cur_config_fs_cache->data_server_cursor = cur_config_fs_cache->fs->data_handle_ranges; - + /* populate table used to speed up mapping of handle values * to servers */ @@ -270,7 +277,7 @@ int PINT_cached_config_handle_load_mapping( gossip_err("Error: failed to load handle lookup table.\n"); return(ret); } - + qhash_add(PINT_fsid_config_cache_table, &(cur_config_fs_cache->fs->coll_id), &(cur_config_fs_cache->hash_link)); @@ -319,7 +326,7 @@ int PINT_cached_config_get_server( return(-PVFS_EINVAL); } - if(type != PINT_SERVER_TYPE_META && type != PINT_SERVER_TYPE_IO) + if((int)type != PINT_SERVER_TYPE_META && (int)type != PINT_SERVER_TYPE_IO) { return(-PVFS_EINVAL); } @@ -336,7 +343,7 @@ int PINT_cached_config_get_server( assert(cur_config_cache); assert(cur_config_cache->fs); - if(type == PINT_SERVER_TYPE_META) + if((int)type == PINT_SERVER_TYPE_META) { server_cursor = cur_config_cache->fs->meta_handle_ranges; @@ -346,14 +353,14 @@ int PINT_cached_config_get_server( server_cursor = cur_config_cache->fs->data_handle_ranges; } - + cur_mapping = PINT_cached_config_find_server(server_cursor, host); /* didn't find the server */ if(!cur_mapping) { return(-PVFS_ENOENT); } - + ext_array->extent_count = cur_mapping->handle_extent_array.extent_count; ext_array->extent_array = @@ -507,7 +514,7 @@ static int PINT_cached_config_get_extents( PVFS_BMI_addr_t tmp_addr; struct config_fs_cache_s *cur_config_cache = NULL; struct host_handle_mapping_s *cur_mapping = NULL; - int num_io_servers, ret; + int ret; hash_link = qhash_search(PINT_fsid_config_cache_table,&(fsid)); if(!hash_link) @@ -523,7 +530,6 @@ static int PINT_cached_config_get_extents( assert(cur_config_cache->fs); server_list = cur_config_cache->fs->data_handle_ranges; - num_io_servers = PINT_llist_count(server_list); while(!PINT_llist_empty(server_list)) { @@ -622,7 +628,6 @@ int PINT_cached_config_map_servers( /* fall through */ case PVFS_SYS_LAYOUT_ROUND_ROBIN: - if(num_io_servers < *inout_num_datafiles) { *inout_num_datafiles = num_io_servers; @@ -1093,8 +1098,7 @@ int PINT_cached_config_map_to_server( PVFS_handle handle, PVFS_fs_id fs_id) { - const struct handle_lookup_entry* tmp_entry; - + struct handle_lookup_entry* tmp_entry; tmp_entry = find_handle_lookup_entry(handle, fs_id); if(!tmp_entry) @@ -1112,7 +1116,7 @@ int PINT_cached_config_map_to_server( * * Returns 0 if the number of dfiles has been successfully set * - * Sets the number of dfiles to a distribution approved the value. Clients + * Sets the number of dfiles to a distribution approved value. Clients * may pass in num_dfiles_requested as a hint, if no hint is given, the server * configuration is checked to find a hint there. The distribution will * choose a correct number of dfiles even if no hint is set. @@ -1163,6 +1167,16 @@ int PINT_cached_config_get_num_dfiles( return(-PVFS_EINVAL); } + if (*num_dfiles > num_io_servers) + { + gossip_err("%s: Distribution requires more datafiles(%d) than I/O servers(%d) currently defined in the system. Capping " + "number of datafiles to the number of I/O servers.\n" + ,__func__ + ,*num_dfiles + ,num_io_servers); + *num_dfiles = num_io_servers; + } + return 0; } @@ -1295,7 +1309,7 @@ int PINT_cached_config_get_server_name( PVFS_handle handle, PVFS_fs_id fsid) { - const struct handle_lookup_entry* tmp_entry; + struct handle_lookup_entry* tmp_entry; tmp_entry = find_handle_lookup_entry(handle, fsid); @@ -1681,9 +1695,9 @@ static int handle_lookup_entry_compare(const void *p1, const void *p2) * * returns pointer to table entry on success, NULL on failure */ -static const struct handle_lookup_entry* find_handle_lookup_entry( +const struct handle_lookup_entry* find_handle_lookup_entry( PVFS_handle handle, PVFS_fs_id fsid) -{ +{ struct qlist_head *hash_link = NULL; struct config_fs_cache_s *cur_config_cache = NULL; int high, low, mid; @@ -1765,7 +1779,7 @@ static int load_handle_lookup_table( int i; int j; PINT_llist* range_list[2] = - { + { cur_config_fs_cache->fs->meta_handle_ranges, cur_config_fs_cache->fs->data_handle_ranges }; @@ -1815,21 +1829,20 @@ static int load_handle_lookup_table( = cur_mapping->handle_extent_array.extent_array[i]; cur_config_fs_cache->handle_lookup_table[table_offset].server_name = cur_mapping->alias_mapping->bmi_address; - - if (strncmp(cur_config_fs_cache->handle_lookup_table[table_offset].server_name, "osd", 3)) + +#ifndef __PVFS2_SERVER__ + ret = BMI_addr_lookup( + &cur_config_fs_cache->handle_lookup_table[table_offset].server_addr, + cur_config_fs_cache->handle_lookup_table[table_offset].server_name); + + if(ret < 0) { - ret = BMI_addr_lookup( - &cur_config_fs_cache->handle_lookup_table[table_offset].server_addr, + free(cur_config_fs_cache->handle_lookup_table); + gossip_err("Error: failed to resolve address of server: %s\n", cur_config_fs_cache->handle_lookup_table[table_offset].server_name); - - if(ret < 0) - { - free(cur_config_fs_cache->handle_lookup_table); - gossip_err("Error: failed to resolve address of server: %s\n", - cur_config_fs_cache->handle_lookup_table[table_offset].server_name); - return(ret); - } + return(ret); } +#endif table_offset++; } diff --git a/src/common/misc/pint-cached-config.h b/src/common/misc/pint-cached-config.h index 0fb87b4..7d0c47f 100644 --- a/src/common/misc/pint-cached-config.h +++ b/src/common/misc/pint-cached-config.h @@ -106,6 +106,15 @@ int PINT_cached_config_get_server_name( int max_server_name_len, PVFS_handle handle, PVFS_fs_id fsid); + +int PINT_cached_config_update_first_handle( + PVFS_handle handle, + PVFS_fs_id fsid); + +int PINT_cached_config_get_first_handle( + PVFS_handle initial_handle, + PVFS_fs_id fs_id, + PVFS_handle *new_handle); int PINT_cached_config_get_server_handle_count( const char *server_addr_str, @@ -140,6 +149,11 @@ int PINT_cached_config_io_server_names( char ***list, int *size, PVFS_fs_id fsid); + +int PINT_cached_config_store_new_oid( + PVFS_BMI_addr_t *addr, + PVFS_fs_id fs_id, + PVFS_handle new_oid); #endif /* __PINT_CACHED_CONFIG_H */ diff --git a/src/common/misc/pint-event.c b/src/common/misc/pint-event.c index 2f19456..a6b3779 100644 --- a/src/common/misc/pint-event.c +++ b/src/common/misc/pint-event.c @@ -6,11 +6,19 @@ #include #include +#ifndef WIN32 #include +#endif #include +#ifdef WIN32 +#include "wincommon.h" + +#define strdup(s) _strdup(s) +#else #include +#endif #include "pint-event.h" #include "pvfs2-types.h" diff --git a/src/common/misc/pint-event.h b/src/common/misc/pint-event.h index 223fd03..75d34d7 100644 --- a/src/common/misc/pint-event.h +++ b/src/common/misc/pint-event.h @@ -70,6 +70,19 @@ int PINT_event_log_event(PINT_event_type type, #ifdef __PVFS2_ENABLE_EVENT__ +#ifdef WIN32 + +#define PINT_EVENT_START(ET, PID, TID, EID, ...) \ + PINT_event_start_event(ET, PID, TID, EID, __VA_ARGS__) + +#define PINT_EVENT_END(ET, PID, TID, EID, ...) \ + PINT_event_end_event(ET, PID, TID, EID, __VA_ARGS__) + +#define PINT_EVENT_LOG(ET, PID, TID, ...) \ + PINT_event_log_event(ET, PID, TID, __VA_ARGS__) + +#else + #define PINT_EVENT_START(ET, PID, TID, EID, args...) \ PINT_event_start_event(ET, PID, TID, EID, ## args) @@ -79,10 +92,25 @@ int PINT_event_log_event(PINT_event_type type, #define PINT_EVENT_LOG(ET, PID, TID, args...) \ PINT_event_log_event(ET, PID, TID, ## args) +#endif /* WIN32 */ + #define PINT_EVENT_ENABLED 1 #else /* __PVFS2_ENABLE_EVENT__ */ +#ifdef WIN32 + +#define PINT_EVENT_START(ET, PID, TID, EID, ...) \ + do { } while(0) + +#define PINT_EVENT_END(ET, PID, TID, EID, ...) \ + do { } while(0) + +#define PINT_EVENT_LOG(ET, PID, TID, ...) \ + do { } while(0) + +#else + #define PINT_EVENT_START(ET, PID, TID, EID, args...) \ do { } while(0) @@ -92,6 +120,8 @@ int PINT_event_log_event(PINT_event_type type, #define PINT_EVENT_LOG(ET, PID, TID, args...) \ do { } while(0) +#endif /* WIN32 */ + #define PINT_EVENT_ENABLED 0 #endif /* __PVFS2_ENABLE_EVENT__ */ diff --git a/src/common/misc/pint-hint.c b/src/common/misc/pint-hint.c index 17e2a0e..4108790 100644 --- a/src/common/misc/pint-hint.c +++ b/src/common/misc/pint-hint.c @@ -118,6 +118,7 @@ int PVFS_hint_add_internal( { int ret; const struct PINT_hint_info *info; + PINT_hint *new_hint; info = PINT_hint_get_info_by_type(type); if(info) @@ -129,7 +130,7 @@ int PVFS_hint_add_internal( } } - PINT_hint * new_hint = malloc(sizeof(PINT_hint)); + new_hint = malloc(sizeof(PINT_hint)); if (!new_hint) { return -PVFS_ENOMEM; @@ -219,6 +220,7 @@ int PVFS_hint_add( { int ret; const struct PINT_hint_info *info; + PINT_hint *new_hint; info = PINT_hint_get_info_by_name(type); if(info) @@ -230,7 +232,7 @@ int PVFS_hint_add( } } - PINT_hint * new_hint = malloc(sizeof(PINT_hint)); + new_hint = malloc(sizeof(PINT_hint)); if (!new_hint) { return -PVFS_ENOMEM; @@ -466,12 +468,20 @@ int PVFS_hint_import_env(PVFS_hint * out_hint) strncpy(env_copy, env, len+1); /* parse hints and do not overwrite already specified hints !*/ +#ifdef WIN32 + aktvar = strtok(env_copy, "+"); /* thread-safe */ +#else aktvar = strtok_r(env_copy, "+", & save_ptr); +#endif while( aktvar != NULL ) { char * rest; - rest = index(aktvar, ':'); +#ifdef WIN32 + rest = strchr(aktvar, ':'); +#else + rest = index(aktvar, ':'); +#endif if (rest == NULL) { gossip_err("Environment variable PVFS2_HINTS is " @@ -528,8 +538,11 @@ int PVFS_hint_import_env(PVFS_hint * out_hint) free(env_copy); return ret; } - +#ifdef WIN32 + aktvar = strtok(NULL, "+"); +#else aktvar = strtok_r(NULL, "+", & save_ptr); +#endif } free(env_copy); diff --git a/src/common/misc/pint-mem.c b/src/common/misc/pint-mem.c index f7093e1..246fdef 100644 --- a/src/common/misc/pint-mem.c +++ b/src/common/misc/pint-mem.c @@ -12,6 +12,14 @@ #include #endif +#ifdef WIN32 +#include "wincommon.h" + +/* do not declare inline on Windows (can't be exported)*/ +#undef inline +#define inline +#endif + /* prototype definitions */ inline void* PINT_mem_aligned_alloc(size_t size, size_t alignment); inline void PINT_mem_aligned_free(void *ptr); @@ -29,7 +37,16 @@ inline void* PINT_mem_aligned_alloc(size_t size, size_t alignment) int ret; void *ptr; +#ifdef WIN32 + ret = 0; + ptr = _aligned_malloc(size, alignment); + if (ptr == NULL) + { + ret = ENOMEM; + } +#else ret = posix_memalign(&ptr, alignment, size); +#endif if(ret != 0) { errno = ret; @@ -48,7 +65,11 @@ inline void* PINT_mem_aligned_alloc(size_t size, size_t alignment) */ inline void PINT_mem_aligned_free(void *ptr) { +#ifdef WIN32 + _aligned_free(ptr); +#else free(ptr); +#endif return; } diff --git a/src/common/misc/pint-perf-counter.c b/src/common/misc/pint-perf-counter.c index b0f3882..2cc4145 100644 --- a/src/common/misc/pint-perf-counter.c +++ b/src/common/misc/pint-perf-counter.c @@ -4,9 +4,17 @@ * See COPYING in top-level directory. */ +/** + * a perf counter (pc) has a linked list of samples (pc->sample) that + * in turn has a start time, and interval, and a pointer to an array of + * counters. + */ + #include #include +#ifndef WIN32 #include +#endif #include #include #include @@ -15,35 +23,78 @@ #include "pvfs2-util.h" #include "pvfs2-internal.h" #include "pint-perf-counter.h" +#include "pint-util.h" #include "gossip.h" #define PINT_PERF_REALLOC_ARRAY(__pc, __tmp_ptr, __src_ptr, __new_history, __type) \ { \ - __tmp_ptr = (__type*)malloc(__new_history*sizeof(__type)); \ + __tmp_ptr = (__type *)malloc(__new_history * sizeof(__type)); \ if(!__tmp_ptr) \ return(-PVFS_ENOMEM); \ - memset(__tmp_ptr, 0, (__new_history*sizeof(__type))); \ + memset(__tmp_ptr, 0, (__new_history * sizeof(__type))); \ memcpy(__tmp_ptr, __src_ptr, \ - (__pc->history_size*sizeof(__type))); \ + (__pc->history_size * sizeof(__type))); \ free(__src_ptr); \ __src_ptr = __tmp_ptr; \ } +/** + * track performance counters for the server + * keys must be defined here in order based on the + * enumeration in include/pvfs2-mgmt.h + */ +struct PINT_perf_key server_keys[] = +{ + {"bytes read", PINT_PERF_READ, PINT_PERF_PRESERVE}, + {"bytes written", PINT_PERF_WRITE, PINT_PERF_PRESERVE}, + {"metadata reads", PINT_PERF_METADATA_READ, PINT_PERF_PRESERVE}, + {"metadata writes", PINT_PERF_METADATA_WRITE, PINT_PERF_PRESERVE}, + {"metadata dspace ops", PINT_PERF_METADATA_DSPACE_OPS, PINT_PERF_PRESERVE}, + {"metadata keyval ops", PINT_PERF_METADATA_KEYVAL_OPS, PINT_PERF_PRESERVE}, + {"request scheduler", PINT_PERF_REQSCHED, PINT_PERF_PRESERVE}, + {"requests received ", PINT_PERF_REQUESTS, PINT_PERF_PRESERVE}, + {"bytes read by small_io", PINT_PERF_SMALL_READ, PINT_PERF_PRESERVE}, + {"bytes written by small_io", PINT_PERF_SMALL_WRITE, PINT_PERF_PRESERVE}, + {"bytes read by flow", PINT_PERF_FLOW_READ, PINT_PERF_PRESERVE}, + {"bytes written by flow", PINT_PERF_FLOW_WRITE, PINT_PERF_PRESERVE}, + {NULL, 0, 0}, +}; + +/** + * this utility removes all of the samples from a perf counter + * this is mostly for cleanup in case of a memory alloc error + */ +void PINT_free_pc (struct PINT_perf_counter *pc) +{ + struct PINT_perf_sample *tmp, *tmp2; + if (!pc) + return; + tmp = pc->sample; + while(tmp) + { + if (tmp->value) + free (tmp->value); + tmp2 = tmp; + tmp = tmp->next; + free (tmp2); + } + free(pc); +} + /** * creates a new perf counter instance * \note key_array must not be freed by caller until after * PINT_perf_finalize() * \returns pointer to perf counter on success, NULL on failure */ -struct PINT_perf_counter* PINT_perf_initialize( - struct PINT_perf_key* key_array) /**< NULL terminated array of keys */ +struct PINT_perf_counter *PINT_perf_initialize(struct PINT_perf_key *key_array) { - struct PINT_perf_counter* pc = NULL; - struct PINT_perf_key* key = NULL; + struct PINT_perf_counter *pc = NULL; + struct PINT_perf_key *key = NULL; int i; - struct timeval tv; + struct PINT_perf_sample *tmp; - pc = (struct PINT_perf_counter*)malloc(sizeof(struct PINT_perf_counter)); + pc = (struct PINT_perf_counter *)malloc(sizeof(struct PINT_perf_counter)); if(!pc) { return(NULL); @@ -52,7 +103,7 @@ struct PINT_perf_counter* PINT_perf_initialize( gen_mutex_init(&pc->mutex); pc->key_array = key_array; - key = &key_array[pc->key_count]; + key = &key_array[pc->key_count]; /* key count is zero */ while(key->key_name) { /* keys must be in order from zero */ @@ -75,66 +126,55 @@ struct PINT_perf_counter* PINT_perf_initialize( return(NULL); } + /* running will be used to decide if we should start an update process */ pc->history_size = PERF_DEFAULT_HISTORY_SIZE; + pc->running = (pc->history_size > 1); + pc->interval = PERF_DEFAULT_UPDATE_INTERVAL; - /* allocate time arrays */ - pc->start_time_array_ms = - (uint64_t*)malloc(PERF_DEFAULT_HISTORY_SIZE*sizeof(uint64_t)); - if(!pc->start_time_array_ms) + /* create a simple linked list of samples, each with a value array */ + tmp = (struct PINT_perf_sample *)malloc(sizeof (struct PINT_perf_sample)); + if(!tmp) { gen_mutex_destroy(&pc->mutex); free(pc); return(NULL); } - pc->interval_array_ms = - (uint64_t*)malloc(PERF_DEFAULT_HISTORY_SIZE*sizeof(uint64_t)); - if(!pc->interval_array_ms) + memset(tmp, 0, sizeof(struct PINT_perf_sample)); + tmp->next = NULL; + tmp->value = (int64_t *)malloc(pc->key_count * sizeof(int64_t)); + if(!tmp->value) { - free(pc->start_time_array_ms); gen_mutex_destroy(&pc->mutex); - free(pc); + PINT_free_pc(pc); return(NULL); } - memset(pc->start_time_array_ms, 0, - PERF_DEFAULT_HISTORY_SIZE*sizeof(uint64_t)); - memset(pc->interval_array_ms, 0, - PERF_DEFAULT_HISTORY_SIZE*sizeof(uint64_t)); - - /* allocate value matrix */ - pc->value_matrix = (int64_t**)malloc(pc->key_count*sizeof(int64_t*)); - if(!pc->value_matrix) + memset(tmp->value, 0, pc->key_count * sizeof(int64_t)); + pc->sample = tmp; + for (i = pc->history_size - 1; i > 0 && tmp; i--) { - free(pc->start_time_array_ms); - free(pc->interval_array_ms); - gen_mutex_destroy(&pc->mutex); - free(pc); - return(NULL); - } - - for(i=0; ikey_count; i++) - { - pc->value_matrix[i] = - (int64_t*)malloc(pc->history_size*sizeof(int64_t)); - if(!pc->value_matrix[i]) + tmp->next = (struct PINT_perf_sample *) + malloc(sizeof (struct PINT_perf_sample)); + if(!tmp->next) { - for(i=i-1; i>= 0; i--) - { - free(pc->value_matrix[i]); - } - free(pc->value_matrix); - free(pc->start_time_array_ms); - free(pc->interval_array_ms); gen_mutex_destroy(&pc->mutex); - free(pc); + PINT_free_pc(pc); return(NULL); } - memset(pc->value_matrix[i], 0, pc->history_size*sizeof(int64_t)); + memset(tmp->next, 0, sizeof(struct PINT_perf_sample)); + tmp->next->next = NULL; + tmp->next->value = (int64_t *)malloc(pc->key_count * sizeof(int64_t)); + if(!tmp->value) + { + gen_mutex_destroy(&pc->mutex); + PINT_free_pc(pc); + return(NULL); + } + memset(tmp->next->value, 0, pc->key_count * sizeof(int64_t)); + tmp = tmp->next; } /* set initial timestamp */ - gettimeofday(&tv, NULL); - pc->start_time_array_ms[0] = ((uint64_t)tv.tv_sec)*1000 + - tv.tv_usec/1000; + pc->sample->start_time_ms = PINT_util_get_time_ms(); return(pc); } @@ -147,28 +187,28 @@ void PINT_perf_reset( struct PINT_perf_counter* pc) { int i; - struct timeval tv; + struct PINT_perf_sample *s; gen_mutex_lock(&pc->mutex); - /* zero out all fields */ - memset(pc->start_time_array_ms, 0, - PERF_DEFAULT_HISTORY_SIZE*sizeof(uint64_t)); - memset(pc->interval_array_ms, 0, - PERF_DEFAULT_HISTORY_SIZE*sizeof(uint64_t)); - for(i=0; ikey_count; i++) + if (!pc || !pc->sample || !pc->sample->value) + return; + for(s = pc->sample; s; s = s->next) { - if(!(pc->key_array[i].flag & PINT_PERF_PRESERVE)) + /* zero out all fields */ + memset(&s->start_time_ms, 0, sizeof(uint64_t)); + memset(&s->interval_ms, 0, sizeof(uint64_t)); + for(i = 0; i < pc->key_count; i++) { - memset(pc->value_matrix[i], 0, pc->history_size*sizeof(int64_t)); + if(!(pc->key_array[i].flag & PINT_PERF_PRESERVE)) + { + memset(&s->value[i], 0, sizeof(int64_t)); + } } } /* set initial timestamp */ - gettimeofday(&tv, NULL); - pc->start_time_array_ms[0] = ((uint64_t)tv.tv_sec)*1000 + - tv.tv_usec/1000; - + s->start_time_ms = PINT_util_get_time_ms(); gen_mutex_unlock(&pc->mutex); return; @@ -178,21 +218,9 @@ void PINT_perf_reset( * destroys a perf counter instance */ void PINT_perf_finalize( - struct PINT_perf_counter* pc) /**< pointer to counter instance */ + struct PINT_perf_counter *pc) /**< pointer to counter instance */ { - int i; - - for(i=0; ikey_count; i++) - { - free(pc->value_matrix[i]); - } - free(pc->value_matrix); - free(pc->start_time_array_ms); - free(pc->interval_array_ms); - gen_mutex_destroy(&pc->mutex); - free(pc); - pc = NULL; - + PINT_free_pc(pc); return; } @@ -200,13 +228,16 @@ void PINT_perf_finalize( * performs an operation on the given key within a performance counter * \see PINT_perf_count macro */ -void __PINT_perf_count( - struct PINT_perf_counter* pc, - int key, - int64_t value, - enum PINT_perf_ops op) +void __PINT_perf_count( struct PINT_perf_counter* pc, + int key, + int64_t value, + enum PINT_perf_ops op) { - if(!pc) +#if 0 + int64_t tmp; /* this is for debugging purposes */ +#endif + + if(!pc || !pc->sample || !pc->sample->value) { /* do nothing if perf counter is not initialized */ return; @@ -214,84 +245,80 @@ void __PINT_perf_count( gen_mutex_lock(&pc->mutex); +#if 0 + tmp = pc->sample->value[key]; +#endif + if(key >= pc->key_count) { gossip_err("Error: PINT_perf_count(): invalid key.\n"); - return; + goto errorout; } switch(op) { case PINT_PERF_ADD: - pc->value_matrix[key][0] = pc->value_matrix[key][0] + value; + pc->sample->value[key] += value; break; case PINT_PERF_SUB: - pc->value_matrix[key][0] = pc->value_matrix[key][0] - value; + pc->sample->value[key] -= value; break; case PINT_PERF_SET: - pc->value_matrix[key][0] = value; + pc->sample->value[key] = value; break; } +#if 0 +/* debug code shows counters being manipulated */ +gossip_err("COUNT %d %lld was %lld is now %lld\n", key, value, + tmp, pc->sample->value[key]); +#endif + +errorout: gen_mutex_unlock(&pc->mutex); return; } -#ifdef __PVFS2_DISABLE_PERF_COUNTERS__ - #define PINT_perf_count(w,x,y,z) do{}while(0) -#else - #define PINT_perf_count __PINT_perf_count -#endif - /** * rolls over the current history window */ -void PINT_perf_rollover( - struct PINT_perf_counter* pc) +void PINT_perf_rollover( struct PINT_perf_counter* pc) { int i; - struct timeval tv; uint64_t int_time; + struct PINT_perf_sample *head, *tail; - if(!pc) + if(!pc || !pc->sample || !pc->sample->value) { /* do nothing if perf counter is not initialized */ return; } - gettimeofday(&tv, NULL); - int_time = ((uint64_t)tv.tv_sec)*1000 + tv.tv_usec/1000; + int_time = PINT_util_get_time_ms(); gen_mutex_lock(&pc->mutex); - /* rotate all values back one */ - if(pc->history_size > 1) + /* rotate newest sample to the back */ + head = pc->sample; + for(tail = head; tail && tail->next; tail = tail->next); + if(head != tail) { - for(i=0; ikey_count; i++) - { - memmove(&pc->value_matrix[i][1], &pc->value_matrix[i][0], - ((pc->history_size-1)*sizeof(int64_t))); - } - memmove(&pc->interval_array_ms[1], &pc->interval_array_ms[0], - ((pc->history_size-1)*sizeof(uint64_t))); - memmove(&pc->start_time_array_ms[1], &pc->start_time_array_ms[0], - ((pc->history_size-1)*sizeof(uint64_t))); - if(int_time > pc->start_time_array_ms[1]) - { - pc->interval_array_ms[1] = int_time - pc->start_time_array_ms[1]; - } + /* move head to the tail */ + pc->sample = head->next; + tail->next = head; + head->next = NULL; + memcpy(pc->sample, tail->next, sizeof(struct PINT_perf_sample)); } /* reset times for next interval */ - pc->start_time_array_ms[0] = int_time; - pc->interval_array_ms[0] = 0; + pc->sample->start_time_ms = int_time; + pc->sample->interval_ms = 0; - for(i=0; ikey_count; i++) + for(i = 0; i < pc->key_count; i++) { - /* reset next interval's value, unless preserve flag set */ if(!(pc->key_array[i].flag & PINT_PERF_PRESERVE)) { - pc->value_matrix[i][0] = 0; + memset(&pc->sample->value[i], 0, sizeof(int64_t)); } } @@ -304,59 +331,92 @@ void PINT_perf_rollover( * sets runtime tunable performance counter options * \returns 0 on success, -PVFS_error on failure */ -int PINT_perf_set_info( - struct PINT_perf_counter* pc, - enum PINT_perf_option option, - unsigned int arg) +int PINT_perf_set_info( struct PINT_perf_counter* pc, + enum PINT_perf_option option, + unsigned int arg) { - uint64_t* tmp_unsigned; - int64_t* tmp_signed; - int i; - - if(!pc) + if(!pc || !pc->sample || !pc->sample->value) { /* do nothing if perf counter is not initialized */ return 0; } + if (arg < 1) + { + /* bad argument */ + return(-PVFS_EINVAL); + } + gen_mutex_lock(&pc->mutex); switch(option) { - case PINT_PERF_HISTORY_SIZE: - if(arg <= pc->history_size) + case PINT_PERF_HISTORY_SIZE: + if(arg <= pc->history_size) + { + while(arg < pc->history_size) { - pc->history_size = arg; + struct PINT_perf_sample *s; + /* remove one sample from list */ + s = pc->sample->next; + if (s) + { + /* removing just behind first sample */ + pc->sample->next = s->next; + s->next = NULL; + free(s->value); + free(s); + pc->history_size--; + } + else + { + /* something is wrong */ + gen_mutex_unlock(&pc->mutex); + return(-PVFS_EINVAL); + } } - else + /* if history_size is now 1 stop the rollover SM */ + pc->running = (pc->history_size > 1); + } + else + { + while(arg > pc->history_size) { - /* we have to reallocate everything */ - /* NOTE: these macros will return error if needed, and - * counter instance will still be operational - */ - PINT_PERF_REALLOC_ARRAY(pc, - tmp_unsigned, - pc->start_time_array_ms, - arg, - uint64_t); - PINT_PERF_REALLOC_ARRAY(pc, - tmp_unsigned, - pc->interval_array_ms, - arg, - uint64_t); - for(i=0; ikey_count; i++) + struct PINT_perf_sample *s; + /* add one sample to list */ + s = (struct PINT_perf_sample *) + malloc(sizeof(struct PINT_perf_sample)); + if(!s) + { + gen_mutex_unlock(&pc->mutex); + return(-PVFS_ENOMEM); + } + memset(s, 0, sizeof(sizeof(struct PINT_perf_sample))); + s->value = (int64_t *) + malloc(pc->key_count * sizeof(int64_t)); + if(!s->value); { - PINT_PERF_REALLOC_ARRAY(pc, - tmp_signed, - pc->value_matrix[i], - arg, - int64_t); + free(s); + gen_mutex_unlock(&pc->mutex); + return(-PVFS_ENOMEM); } - pc->history_size = arg; + memset(s->value, 0, + sizeof(pc->key_count * sizeof(int64_t))); + /* adding just after first sample */ + s->next = pc->sample->next; + pc->sample->next = s; + pc->history_size++; } - break; - default: - gen_mutex_unlock(&pc->mutex); - return(-PVFS_EINVAL); + /* if not running start rollover SM */ + pc->running = (pc->history_size > 1); + } + break; + case PINT_PERF_UPDATE_INTERVAL: + if (arg > 0) + pc->interval = arg; + break; + default: + gen_mutex_unlock(&pc->mutex); + return(-PVFS_EINVAL); } gen_mutex_unlock(&pc->mutex); @@ -367,10 +427,9 @@ int PINT_perf_set_info( * retrieves runtime tunable performance counter options * \returns 0 on success, -PVFS_error on failure */ -int PINT_perf_get_info( - struct PINT_perf_counter* pc, - enum PINT_perf_option option, - unsigned int* arg) +int PINT_perf_get_info( struct PINT_perf_counter* pc, + enum PINT_perf_option option, + unsigned int* arg) { if(!pc) { @@ -381,15 +440,18 @@ int PINT_perf_get_info( gen_mutex_lock(&pc->mutex); switch(option) { - case PINT_PERF_HISTORY_SIZE: - *arg = pc->history_size; - break; - case PINT_PERF_KEY_COUNT: - *arg = pc->key_count; - break; - default: - gen_mutex_unlock(&pc->mutex); - return(-PVFS_EINVAL); + case PINT_PERF_HISTORY_SIZE: + *arg = pc->history_size; + break; + case PINT_PERF_KEY_COUNT: + *arg = pc->key_count; + break; + case PINT_PERF_UPDATE_INTERVAL: + *arg = pc->interval; + break; + default: + gen_mutex_unlock(&pc->mutex); + return(-PVFS_EINVAL); } gen_mutex_unlock(&pc->mutex); @@ -398,22 +460,34 @@ int PINT_perf_get_info( /** * retrieves measurement history + * + * This copies the data from the samples (stored in a linked list) into + * a temporary array where they can be inspected without worry of update + * this array will store up to max_key counters PLUS two time values, the + * start time and intervale, both as ms counts. The samples might have + * more or less keys in them, and the system might have more or less + * samples than space in the array. + * + * the array is really a 2D Matrix (keys+times vs history) but is treated + * as a 1D array because the sizes aren't well known until runtime, and + * even then can change. This results in some 2D indexing (i*max_key+2) + * in the loop where + * data is copied from the samples to the value_array. Also the location + * of the time stampls is generally index max_key, and max_key+1 */ void PINT_perf_retrieve( - struct PINT_perf_counter* pc, /**< performance counter */ - int64_t** value_matrix, /**< 2d matrix to fill in with measurements */ - uint64_t* start_time_array_ms, /**< array of start times */ - uint64_t* interval_array_ms, /**< array of interval lengths */ - int max_key, /**< max key value (1st dimension) */ - int max_history) /**< max history (2nd dimension) */ + struct PINT_perf_counter* pc, /* performance counter */ + int64_t *value_array, /* array of output measurements */ + int max_key, /* max key value (1st dimension) */ + int max_history) /* max history (2nd dimension) */ { int i; int tmp_max_key; int tmp_max_history; - struct timeval tv; uint64_t int_time; + struct PINT_perf_sample *s; - if(!pc) + if(!pc || !pc->sample || !pc->sample->value) { /* do nothing if perf counter is not initialized */ return; @@ -432,68 +506,80 @@ void PINT_perf_retrieve( if(max_key > pc->key_count || max_history > pc->history_size) { - /* zero out value matrix, we won't use all fields */ - for(i=0; i pc->history_size) - { - /* zero out time arrays, we won't use all fields */ - memset(start_time_array_ms, 0, (max_history*sizeof(uint64_t))); - memset(interval_array_ms, 0, (max_history*sizeof(uint64_t))); + memset(value_array, 0, + (max_history * (max_key + 2) * sizeof(int64_t))); } /* copy data out */ - for(i=0; isample; i < tmp_max_history && s; i++, s = s->next) { - memcpy(value_matrix[i], pc->value_matrix[i], - (tmp_max_history*sizeof(int64_t))); + /* copy counters */ + memcpy(&value_array[i * (max_key + 2)], s->value, + (tmp_max_key * sizeof(int64_t))); + /* copy time codes */ + value_array[(i * (max_key + 2)) + max_key] = s->start_time_ms; + value_array[(i * (max_key + 2)) + max_key + 1] = s->interval_ms; } - memcpy(start_time_array_ms, pc->start_time_array_ms, - (tmp_max_history*sizeof(uint64_t))); - memcpy(interval_array_ms, pc->interval_array_ms, - (tmp_max_history*sizeof(uint64_t))); + +#if 0 +/* debug code prints first sample to log */ +{int k; for(k=0;ksample->value[k]);} +#endif gen_mutex_unlock(&pc->mutex); /* fill in interval length for newest interval */ - gettimeofday(&tv, NULL); - int_time = ((uint64_t)tv.tv_sec) * 1000 + tv.tv_usec / 1000; - if(int_time > start_time_array_ms[0]) + int_time = PINT_util_get_time_ms(); + if(int_time > value_array[max_key]) { - interval_array_ms[0] = int_time - start_time_array_ms[0]; + value_array[max_key + 1] = int_time - value_array[max_key]; } + + /* auto-rollover when data is retrieved */ + /* this may obviate last step above */ + PINT_perf_rollover(pc); return; } -char* PINT_perf_generate_text( - struct PINT_perf_counter* pc, - int max_size) +char *PINT_perf_generate_text( struct PINT_perf_counter* pc, + int max_size) { int total_size = 0; int line_size = 0; int actual_size = 0; - char* tmp_str; - char* position; + char *tmp_str; + char *position; int i, j; uint64_t int_time; - struct timeval tv; time_t tmp_time_t; struct tm tmp_tm; +#ifdef WIN32 + struct tm *ptmp_tm; +#endif int ret; + struct PINT_perf_sample *s = NULL; + + if (!pc || !pc->sample || !pc->sample->value) + { + return NULL; + } gen_mutex_lock(&pc->mutex); - line_size = 26 + (24*pc->history_size); - total_size = (pc->key_count+2)*line_size + 1; + line_size = 26 + (24 * pc->history_size); + total_size = (pc->key_count + 2) * line_size + 1; actual_size = PVFS_util_min(total_size, max_size); - if((actual_size/line_size) < 3) + if((actual_size / line_size) < 3) { /* don't bother trying to display anything, can't fit any results in * that size @@ -501,7 +587,7 @@ char* PINT_perf_generate_text( return(NULL); } - tmp_str = (char*)malloc(actual_size*sizeof(char)); + tmp_str = (char *)malloc(actual_size * sizeof(char)); if(!tmp_str) { gen_mutex_unlock(&pc->mutex); @@ -512,16 +598,21 @@ char* PINT_perf_generate_text( /* start times */ sprintf(position, "%-24.24s: ", "Start times (hr:min:sec)"); position += 25; - for(i=0; ihistory_size; i++) + for(i = 0, s = pc->sample; i < pc->history_size && s; i++, s = s->next) { - if(pc->start_time_array_ms[i]) + PVFS_time start_i = (PVFS_time)s->start_time_ms; + if(start_i) { - tmp_time_t = pc->start_time_array_ms[i]/1000; + tmp_time_t = start_i / 1000; +#ifdef WIN32 + ptmp_tm = localtime(&tmp_time_t); + tmp_tm = *ptmp_tm; +#else localtime_r(&tmp_time_t, &tmp_tm); +#endif strftime(position, 11, " %H:%M:%S", &tmp_tm); position += 10; - sprintf(position, ".%03u", - (unsigned)(pc->start_time_array_ms[i]%1000)); + sprintf(position, ".%03u", (unsigned)(start_i % 1000)); position += 4; } else @@ -534,26 +625,29 @@ char* PINT_perf_generate_text( position++; /* fill in interval length for newest interval */ - gettimeofday(&tv, NULL); - int_time = ((uint64_t)tv.tv_sec) * 1000 + tv.tv_usec / 1000; - if(int_time > pc->start_time_array_ms[0]) + int_time = PINT_util_get_time_ms(); + if(int_time > pc->sample->interval_ms) { - pc->interval_array_ms[0] = int_time - pc->start_time_array_ms[0]; + pc->sample->interval_ms = int_time - pc->sample->start_time_ms; } /* intervals */ sprintf(position, "%-24.24s:", "Intervals (hr:min:sec)"); position += 25; - for(i=0; ihistory_size; i++) + for(i = 0, s = pc->sample; i < pc->history_size && s; i++, s = s->next) { - if(pc->interval_array_ms[i]) + PVFS_time interval_i = s->interval_ms; + if(interval_i) { - tmp_time_t = pc->interval_array_ms[i]/1000; + tmp_time_t = interval_i / 1000; +#ifdef WIN32 + gmtime_s(&tmp_tm, &tmp_time_t); +#else gmtime_r(&tmp_time_t, &tmp_tm); +#endif strftime(position, 11, " %H:%M:%S", &tmp_tm); position += 10; - sprintf(position, ".%03u", - (unsigned)(pc->interval_array_ms[i]%1000)); + sprintf(position, ".%03u", (unsigned)(interval_i % 1000)); position += 4; } else @@ -568,7 +662,7 @@ char* PINT_perf_generate_text( sprintf(position, "-------------------------"); position += 25; - for(i=0; ihistory_size; i++) + for(i = 0; i < pc->history_size; i++) { sprintf(position, "--------------"); position += 14; @@ -577,13 +671,17 @@ char* PINT_perf_generate_text( position++; /* values */ - for(i=0; ikey_count; i++) + for(i = 0; i < pc->key_count; i++) { sprintf(position, "%-24.24s:", pc->key_array[i].key_name); position += 25; - for(j=0; jhistory_size; j++) + for(j = 0, s = pc->sample; j < pc->history_size && s; j++, s = s->next) { - ret = snprintf(position, 15, " %13Ld", lld(pc->value_matrix[i][j])); +#ifdef WIN32 + ret = _snprintf(position, 15, " %13Ld", lld(s->value[i])); +#else + ret = snprintf(position, 15, " %13Ld", lld(s->value[i])); +#endif if(ret >= 15) { sprintf(position, "%14.14s", "Overflow!"); diff --git a/src/common/misc/pint-perf-counter.h b/src/common/misc/pint-perf-counter.h index 530b4fa..0a101ea 100644 --- a/src/common/misc/pint-perf-counter.h +++ b/src/common/misc/pint-perf-counter.h @@ -12,29 +12,16 @@ #include "gen-locks.h" enum { -PERF_DEFAULT_TIME_INTERVAL_SECS = 300, -PERF_DEFAULT_HISTORY_SIZE = 6, + PERF_DEFAULT_UPDATE_INTERVAL = 1000, /* msecs */ + PERF_DEFAULT_HISTORY_SIZE = 1, }; -/** flag that indicates that values for a particular key should be preserved +/** flag that indicates that values for a + * particular key should be preserved * across rollover rather than reset to 0 */ #define PINT_PERF_PRESERVE 1 -/* TODO: this may be moved in the long term; it is an enumeration of keys - * that pvfs2-server supports (used by trove and flow counters) - */ -enum PINT_server_perf_keys -{ - PINT_PERF_READ = 0, - PINT_PERF_WRITE = 1, - PINT_PERF_METADATA_READ = 2, - PINT_PERF_METADATA_WRITE = 3, - PINT_PERF_METADATA_DSPACE_OPS = 4, - PINT_PERF_METADATA_KEYVAL_OPS = 5, - PINT_PERF_REQSCHED = 6 -}; - /** enumeration of valid measurement operations */ enum PINT_perf_ops { @@ -46,8 +33,9 @@ enum PINT_perf_ops /** enumeration of runtime options */ enum PINT_perf_option { - PINT_PERF_HISTORY_SIZE = 1, /**< sets/gets the history size */ - PINT_PERF_KEY_COUNT = 2 /**< gets the key coung (cannot be set) */ + PINT_PERF_HISTORY_SIZE = 1, /**< sets/gets the history size */ + PINT_PERF_KEY_COUNT = 2, /**< gets the key count (cannot be set) */ + PINT_PERF_UPDATE_INTERVAL = 3 /**< sets/gets the update interval */ }; /** describes a single key to be stored in the perf counter interface */ @@ -58,36 +46,46 @@ struct PINT_perf_key int flag; /**< flags that modify behavior of values in this key */ }; -/** struct representing a perf counter instance */ +/** struct holding one sample for a multi-sample set of counters */ +struct PINT_perf_sample +{ + PVFS_time start_time_ms; /**< time this sample was started */ + PVFS_time interval_ms; /**< ms this sample lasted */ + int64_t *value; /**< this points to an array of counters */ + struct PINT_perf_sample *next; /**< link to next sample */ +}; + +/** struct representing a multi-sample set of perf counters */ struct PINT_perf_counter { gen_mutex_t mutex; struct PINT_perf_key* key_array; /**< keys (provided by initialize()) */ int key_count; /**< number of keys */ int history_size; /**< number of history intervals */ - /** matrix of statistics, first dimension is key, second is history */ - int64_t** value_matrix; - uint64_t* start_time_array_ms; /**< array of start times */ - uint64_t* interval_array_ms; /**< array of interval lengths */ + int running; /**< true if a rollover running */ + int interval; /**< milliseconds between rollovers */ + struct PINT_perf_sample *sample; /**< list of samples for this counter */ }; + /** server-wide perf counter structure */ +extern struct PINT_perf_key server_keys[]; + extern struct PINT_perf_counter *PINT_server_pc; -struct PINT_perf_counter* PINT_perf_initialize( - struct PINT_perf_key* key_array); +struct PINT_perf_counter* PINT_perf_initialize(struct PINT_perf_key *key); void PINT_perf_finalize( - struct PINT_perf_counter* pc); + struct PINT_perf_counter* pc); void PINT_perf_reset( - struct PINT_perf_counter* pc); + struct PINT_perf_counter* pc); void __PINT_perf_count( - struct PINT_perf_counter* pc, - int key, - int64_t value, - enum PINT_perf_ops op); + struct PINT_perf_counter* pc, + int key, + int64_t value, + enum PINT_perf_ops op); #ifdef __PVFS2_DISABLE_PERF_COUNTERS__ #define PINT_perf_count(w,x,y,z) do{}while(0) @@ -96,29 +94,29 @@ void __PINT_perf_count( #endif void PINT_perf_rollover( - struct PINT_perf_counter* pc); + struct PINT_perf_counter* pc); int PINT_perf_set_info( - struct PINT_perf_counter* pc, - enum PINT_perf_option option, - unsigned int arg); + struct PINT_perf_counter* pc, + enum PINT_perf_option option, + unsigned int arg); int PINT_perf_get_info( - struct PINT_perf_counter* pc, - enum PINT_perf_option option, - unsigned int* arg); + struct PINT_perf_counter* pc, + enum PINT_perf_option option, + unsigned int* arg); void PINT_perf_retrieve( - struct PINT_perf_counter* pc, - int64_t** value_matrix, - uint64_t* start_time_array_ms, - uint64_t* interval_array_ms, - int max_key, - int max_history); + struct PINT_perf_counter* pc, + int64_t* value_array, + int max_key, + int max_history); char* PINT_perf_generate_text( - struct PINT_perf_counter* pc, - int max_size); + struct PINT_perf_counter* pc, + int max_size); + +void PINT_free_pc (struct PINT_perf_counter *pc); #endif /* __PINT_PERF_COUNTER_H */ diff --git a/src/common/misc/pint-util.c b/src/common/misc/pint-util.c index 7128858..8e37c78 100644 --- a/src/common/misc/pint-util.c +++ b/src/common/misc/pint-util.c @@ -13,6 +13,14 @@ #include #include +#ifdef WIN32 +#include +#include "wincommon.h" + +/* uid and gid types */ +typedef unsigned int uid_t, gid_t; + +#else #include #include #include @@ -20,6 +28,7 @@ #include #include #include +#endif #define __PINT_REQPROTO_ENCODE_FUNCS_C #include "gen-locks.h" @@ -42,12 +51,31 @@ static int PINT_check_group(uid_t uid, gid_t gid); void PINT_time_mark(PINT_time_marker *out_marker) { +#ifdef WIN32 + FILETIME creation, exit, system, user; + ULARGE_INTEGER li_system, li_user; +#else struct rusage usage; +#endif gettimeofday(&out_marker->wtime, NULL); +#ifdef WIN32 + GetProcessTimes(GetCurrentProcess(), &creation, &exit, &system, &user); + li_system.LowPart = system.dwLowDateTime; + li_system.HighPart = system.dwHighDateTime; + li_user.LowPart = user.dwLowDateTime; + li_user.HighPart = user.dwHighDateTime; + + /* FILETIME is in 100-nanosecond increments */ + out_marker->stime.tv_sec = li_system.QuadPart / 10000000; + out_marker->stime.tv_usec = (li_system.QuadPart % 10000000) / 10; + out_marker->utime.tv_sec = li_system.QuadPart / 10000000; + out_marker->utime.tv_usec = (li_system.QuadPart % 10000000) / 10; +#else getrusage(RUSAGE_SELF, &usage); out_marker->utime = usage.ru_utime; out_marker->stime = usage.ru_stime; +#endif } void PINT_time_diff(PINT_time_marker mark1, @@ -113,6 +141,10 @@ int PINT_copy_object_attr(PVFS_object_attr *dest, PVFS_object_attr *src) { dest->group = src->group; } + if (src->mask & PVFS_ATTR_COMMON_CID) + { + dest->cid = src->cid; + } if (src->mask & PVFS_ATTR_COMMON_PERM) { dest->perms = src->perms; @@ -391,6 +423,9 @@ char *PINT_util_get_object_type(int objtype) return obj_types[6]; } +/* + * this is just a wrapper for gettimeofday + */ void PINT_util_get_current_timeval(struct timeval *tv) { gettimeofday(tv, NULL); @@ -402,7 +437,9 @@ int PINT_util_get_timeval_diff(struct timeval *tv_start, struct timeval *tv_end) (tv_start->tv_sec * 1e6 + tv_start->tv_usec); } - +/* + * this returns time in seconds + */ PVFS_time PINT_util_get_current_time(void) { struct timeval t = {0,0}; @@ -413,6 +450,47 @@ PVFS_time PINT_util_get_current_time(void) return current_time; } +/* + * this gets time in ms - warning, can roll over + */ +PVFS_time PINT_util_get_time_ms(void) +{ + struct timeval t = {0,0}; + PVFS_time current_time = 0; + + gettimeofday(&t, NULL); + current_time = ((PVFS_time)t.tv_sec) * 1000 + t.tv_usec / 1000; + return current_time; +} + +/* + * this gets time in us - warning, can roll over + */ +PVFS_time PINT_util_get_time_us(void) +{ + struct timeval t = {0,0}; + PVFS_time current_time = 0; + + gettimeofday(&t, NULL); + current_time = ((PVFS_time)t.tv_sec) * 1000000 + t.tv_usec; + return current_time; +} + +/* parses a struct timeval into a readable timestamp string*/ +/* assumes sufficient memory has been allocated for str, no checking */ +/* to be safe, make str a 64 character string atleast */ +void PINT_util_parse_timeval(struct timeval tv, char *str) +{ + time_t now; + struct tm *currentTime; + + now = tv.tv_sec; + currentTime = localtime(&now); + strftime(str, 64, "%m/%d/%Y %H:%M:%S", currentTime); + + return; +} + PVFS_time PINT_util_mktime_version(PVFS_time time) { struct timeval t = {0,0}; @@ -436,7 +514,17 @@ struct timespec PINT_util_get_abs_timespec(int microsecs) gettimeofday(&now, NULL); add.tv_sec = (microsecs / 1e6); add.tv_usec = (microsecs % 1000000); +#ifdef WIN32 + result.tv_sec = add.tv_sec + now.tv_sec; + result.tv_usec = add.tv_usec + now.tv_usec; + if (result.tv_usec >= 1000000) + { + result.tv_usec -= 1000000; + result.tv_sec++; + } +#else timeradd(&now, &add, &result); +#endif tv.tv_sec = result.tv_sec; tv.tv_nsec = result.tv_usec * 1e3; return tv; @@ -448,11 +536,19 @@ void PINT_util_gen_credentials( assert(credentials); memset(credentials, 0, sizeof(PVFS_credentials)); +#ifndef WIN32 + /* TODO */ credentials->uid = geteuid(); credentials->gid = getegid(); +#endif } -inline void encode_PVFS_BMI_addr_t(char **pptr, const PVFS_BMI_addr_t *x) +/* Windows - inline functions can't be exported to other libraries */ + +#ifndef WIN32 +inline +#endif +void encode_PVFS_BMI_addr_t(char **pptr, const PVFS_BMI_addr_t *x) { const char *addr_str; @@ -461,21 +557,29 @@ inline void encode_PVFS_BMI_addr_t(char **pptr, const PVFS_BMI_addr_t *x) } /* determines how much protocol space a BMI_addr_t encoding will consume */ -inline int encode_PVFS_BMI_addr_t_size_check(const PVFS_BMI_addr_t *x) +#ifndef WIN32 +inline +#endif +int encode_PVFS_BMI_addr_t_size_check(const PVFS_BMI_addr_t *x) { const char *addr_str; addr_str = BMI_addr_rev_lookup(*x); return(encode_string_size_check(&addr_str)); } - -inline void decode_PVFS_BMI_addr_t(char **pptr, PVFS_BMI_addr_t *x) +#ifndef WIN32 +inline +#endif +void decode_PVFS_BMI_addr_t(char **pptr, PVFS_BMI_addr_t *x) { char *addr_string; decode_string(pptr, &addr_string); BMI_addr_lookup(x, addr_string); } -inline void encode_PVFS_sys_layout(char **pptr, const struct PVFS_sys_layout_s *x) +#ifndef WIN32 +inline +#endif +void encode_PVFS_sys_layout(char **pptr, const struct PVFS_sys_layout_s *x) { int tmp_size; int i; @@ -510,7 +614,10 @@ inline void encode_PVFS_sys_layout(char **pptr, const struct PVFS_sys_layout_s * } } -inline void decode_PVFS_sys_layout(char **pptr, struct PVFS_sys_layout_s *x) +#ifndef WIN32 +inline +#endif +void decode_PVFS_sys_layout(char **pptr, struct PVFS_sys_layout_s *x) { int i; @@ -533,7 +640,6 @@ char *PINT_util_guess_alias(void) { char tmp_alias[1024]; char *tmpstr; - char *alias; int ret; /* hmm...failed to find alias as part of the server config filename, @@ -547,7 +653,6 @@ char *PINT_util_guess_alias(void) "process directly\n"); return NULL; } - alias = tmp_alias; tmpstr = strstr(tmp_alias, "."); if(tmpstr) @@ -957,6 +1062,107 @@ int PINT_check_acls(void *acl_buf, size_t acl_size, return -PVFS_EACCES; } +#ifdef WIN32 +int PINT_statfs_lookup(const char *path, struct statfs *buf) +{ + char *abs_path, *root_path; + int rc, start, index, slash_max, slash_count; + DWORD sect_per_cluster, bytes_per_sect, free_clusters, total_clusters; + + if (path == NULL || buf == NULL) + { + errno = EFAULT; + return -1; + } + + /* allocate a buffer to get an absolute path */ + abs_path = (char *) malloc(MAX_PATH + 1); + if (_fullpath(abs_path, path, MAX_PATH) == NULL) + { + free(abs_path); + errno = ENOENT; + return -1; + } + + /* allocate buffer for root path */ + root_path = (char *) malloc(strlen(abs_path) + 1); + + /* parse out the root directory--it will be in + \\MyServer\MyFolder\ form or C:\ form */ + if (abs_path[0] == '\\' && abs_path[1] == '\\') + { + start = 2; + slash_max = 2; + } + else + { + start = 0; + slash_max = 1; + } + + slash_count = 0; + index = start; + + while (abs_path[index] && slash_count < slash_max) + { + if (abs_path[index++] == '\\') + slash_count++; + } + + /* copy root path */ + strncpy_s(root_path, strlen(abs_path)+1, abs_path, index); + + rc = 0; + if (GetDiskFreeSpace(root_path, §_per_cluster, &bytes_per_sect, + &free_clusters, &total_clusters)) + { + buf->f_type = 0; /* not used by PVFS */ + buf->f_bsize = (uint64_t) sect_per_cluster * bytes_per_sect; + buf->f_bavail = buf->f_bfree = (uint64_t) free_clusters; + buf->f_blocks = (uint64_t) total_clusters; + buf->f_fsid = 0; /* no meaningful definition on Windows */ + } + else + { + errno = GetLastError(); + rc = -1; + } + + free(root_path); + free(abs_path); + + return rc; + +} + +int PINT_statfs_fd_lookup(int fd, struct statfs *buf) +{ + HANDLE handle; + char *path; + int rc; + + /* get handle from fd */ + handle = (HANDLE) _get_osfhandle(fd); + + /* get file path from handle */ + path = (char *) malloc(MAX_PATH + 1); + /* Note: only available on Vista/WS2008 and later */ + if (GetFinalPathNameByHandle(handle, path, MAX_PATH, 0) != 0) + { + free(path); + errno = GetLastError(); + return -1; + } + + rc = PINT_statfs_lookup(path, buf); + + free(path); + + return rc; + +} + +#endif /* * Local variables: * c-indent-level: 4 diff --git a/src/common/misc/pint-util.h b/src/common/misc/pint-util.h index 4c787a5..3fae703 100644 --- a/src/common/misc/pint-util.h +++ b/src/common/misc/pint-util.h @@ -32,6 +32,11 @@ do{ \ (dest)->perms = (src)->perms; \ (dest)->mask |= PVFS_ATTR_COMMON_PERM; \ } \ + if ((src)->mask & PVFS_ATTR_SYS_CID) \ + { \ + (dest)->cid = (src)->cid; \ + (dest)->mask |= PVFS_ATTR_COMMON_CID; \ + } \ if ((src)->mask & PVFS_ATTR_SYS_ATIME) \ { \ (dest)->mask |= PVFS_ATTR_COMMON_ATIME; \ @@ -110,6 +115,31 @@ void PINT_time_diff(PINT_time_marker mark1, #define PINT_statfs_blocks(_statfs) (_statfs)->f_blocks #define PINT_statfs_fsid(_statfs) (_statfs)->f_fsid +#elif defined(WIN32) +/* the statfs type must be defined on Windows */ +typedef unsigned long fsid_t; +struct statfs { + uint64_t f_type; + uint64_t f_bsize; + uint64_t f_blocks; + uint64_t f_bfree; + uint64_t f_bavail; + uint64_t f_files; + uint64_t f_ffree; + fsid_t f_fsid; + uint64_t f_namelen; +}; + +#define PINT_statfs_t struct statfs +/* Use functions with Windows API calls--defined in pint-util.c */ +int PINT_statfs_lookup(const char *path, struct statfs *buf); +int PINT_statfs_fd_lookup(int fd, struct statfs *buf); +#define PINT_statfs_bsize(_statfs) (_statfs)->f_bsize +#define PINT_statfs_bavail(_statfs) (_statfs)->f_bavail +#define PINT_statfs_bfree(_statfs) (_statfs)->f_bfree +#define PINT_statfs_blocks(_statfs) (_statfs)->f_blocks +#define PINT_statfs_fsid(_statfs) (_statfs)->f_fsid + #else #error OS does not have sys/vfs.h or sys/mount.h. @@ -119,8 +149,11 @@ void PINT_time_diff(PINT_time_marker mark1, char *PINT_util_get_object_type(int objtype); PVFS_time PINT_util_get_current_time(void); +PVFS_time PINT_util_get_time_ms(void); +PVFS_time PINT_util_get_time_us(void); void PINT_util_get_current_timeval(struct timeval *tv); int PINT_util_get_timeval_diff(struct timeval *tv_start, struct timeval *tv_end); +void PINT_util_parse_timeval(struct timeval tv, char *str); PVFS_time PINT_util_mktime_version(PVFS_time time); PVFS_time PINT_util_mkversion_time(PVFS_time version); diff --git a/src/common/misc/pvfs2-hint.c b/src/common/misc/pvfs2-hint.c index 0fc1259..9eb5f95 100644 --- a/src/common/misc/pvfs2-hint.c +++ b/src/common/misc/pvfs2-hint.c @@ -12,12 +12,13 @@ /* Size: 4 for sentinel at the end, 8 + string size for each element, * type + length*/ int32_t PINT_hint_calc_size(const PVFS_hint * hint){ + int count = 4; + PVFS_hint * act; + #ifdef NO_PVFS_HINT_SUPPORT return 0; #endif - int count = 4; - PVFS_hint * act; for( act = (PVFS_hint *) hint ; act != NULL ; act = act->next_hint){ if (hint_types[act->type].transfer_to_server){ /* length + type + act. string + 8-byte alignment*/ diff --git a/src/common/misc/pvfs2-util.c b/src/common/misc/pvfs2-util.c index 72ff24e..9474bc8 100644 --- a/src/common/misc/pvfs2-util.c +++ b/src/common/misc/pvfs2-util.c @@ -14,10 +14,12 @@ #include #include #include -#include #include +#ifndef WIN32 +#include #include #include +#endif #include "pvfs2-config.h" #include "pvfs2-sysint.h" @@ -206,6 +208,7 @@ int PVFS_util_copy_sys_attr( dest_attr->atime = src_attr->atime; dest_attr->mtime = src_attr->mtime; dest_attr->ctime = src_attr->ctime; + dest_attr->cid = src_attr->cid; dest_attr->dfile_count = src_attr->dfile_count; dest_attr->objtype = src_attr->objtype; dest_attr->mask = src_attr->mask; @@ -1627,6 +1630,8 @@ uint32_t PVFS_util_sys_to_object_attr_mask( attrmask |= PVFS_ATTR_COMMON_GID; if(sys_attrmask & PVFS_ATTR_SYS_PERM) attrmask |= PVFS_ATTR_COMMON_PERM; + if(sys_attrmask & PVFS_ATTR_SYS_CID) + attrmask |= PVFS_ATTR_COMMON_CID; if(sys_attrmask & PVFS_ATTR_SYS_ATIME) attrmask |= PVFS_ATTR_COMMON_ATIME; if(sys_attrmask & PVFS_ATTR_SYS_CTIME) diff --git a/src/common/misc/realpath.c b/src/common/misc/realpath.c index 1158db3..b93fdf0 100644 --- a/src/common/misc/realpath.c +++ b/src/common/misc/realpath.c @@ -30,7 +30,9 @@ #ifndef PATH_MAX #define PATH_MAX 8192 #endif +#ifndef WIN32 #include +#endif #include #include #include @@ -39,6 +41,34 @@ #define MAX_READLINKS 32 +#ifdef WIN32 +/* PINT_realpath() + * + * canonicalizes path and places the result into resolved_path. Includes + * cleaning of symbolic links, trailing slashes, and .. or . components. + * maxreslth is the maximum length allowed in resolved_path. + * + * returns 0 on success, -PVFS_error on failure. + */ +int PINT_realpath( + const char *path, + char *resolved_path, + int maxreslth) +{ + char *ret_path; + + if (resolved_path == NULL || path == NULL) + return -PVFS_EINVAL; + + /* just use CRT version for now */ + ret_path = _fullpath(resolved_path, path, maxreslth); + + if (ret_path == NULL) + return -PVFS_EINVAL; + + return 0; +} +#else /* PINT_realpath() * * canonicalizes path and places the result into resolved_path. Includes @@ -179,6 +209,7 @@ int PINT_realpath( free(buf); return ret; } +#endif /* WIN32 */ /* * Local variables: diff --git a/src/common/misc/server-config-mgr.c b/src/common/misc/server-config-mgr.c index 652aabc..2cf06c0 100644 --- a/src/common/misc/server-config-mgr.c +++ b/src/common/misc/server-config-mgr.c @@ -8,7 +8,9 @@ #include #include #include +#ifndef WIN32 #include +#endif #include #include #include @@ -190,7 +192,7 @@ int PINT_server_config_mgr_reload_cached_config_interface(void) gossip_debug(GOSSIP_CLIENT_DEBUG, "Reloading handle mappings for fs_id %d\n", cur_fs->coll_id); - + ret = PINT_cached_config_handle_load_mapping(cur_fs); if (ret) { diff --git a/src/common/misc/server-config.c b/src/common/misc/server-config.c index 09c943a..322dbe1 100644 --- a/src/common/misc/server-config.c +++ b/src/common/misc/server-config.c @@ -8,11 +8,16 @@ #include #include #include +#ifndef WIN32 #include +#endif #include #include #include #include +#ifdef WIN32 +#include +#endif #include "src/common/dotconf/dotconf.h" #include "server-config.h" @@ -119,6 +124,7 @@ static DOTCONF_CB(get_trove_method); static DOTCONF_CB(get_osd_type); static DOTCONF_CB(get_osd_dir_type); static DOTCONF_CB(get_create_type); +static DOTCONF_CB(get_member_attr_type); static DOTCONF_CB(get_small_file_size); static DOTCONF_CB(directio_thread_num); static DOTCONF_CB(directio_ops_per_queue); @@ -1010,6 +1016,11 @@ static const configoption_t options[] = */ { "PostCreate", ARG_STR, get_create_type, NULL, CTX_DEFAULTS, "no" }, + /* + * Specifies if getting member attributes is enabled or not + */ + { "MemberAttr", ARG_STR, get_member_attr_type, NULL, CTX_DEFAULTS, "no" }, + /* Specifies the size of the small file transition point */ {"SmallFileSize", ARG_INT, get_small_file_size, NULL, CTX_FILESYSTEM, NULL}, @@ -1564,6 +1575,9 @@ DOTCONF_CB(get_tcp_buffer_send) return NULL; } +#ifdef WIN32 +#define strcasecmp stricmp +#endif DOTCONF_CB(get_tcp_bind_specific) { struct server_configuration_s *config_s = @@ -2979,6 +2993,21 @@ static DOTCONF_CB(get_create_type) return ret; } +static DOTCONF_CB(get_member_attr_type) +{ + const char *str = cmd->data.str; + struct server_configuration_s *config = cmd->context; + const char *ret = NULL; + + if (!strcmp(str, "no")) + config->member_attr = NO_MEMBER_ATTR; + else if (!strcmp(str, "yes")) + config->member_attr = GET_MEMBER_ATTR; + else + ret = "get_member_attr_type: unknown FileSystem PostCreate option\n"; + return ret; +} + static DOTCONF_CB(get_osd_type) { const char *str = cmd->data.str; @@ -4043,7 +4072,7 @@ char *PINT_config_get_merged_handle_range_str( char *merged_range = NULL; char *mrange = get_handle_range_str(config_s,fs,1); char *drange = get_handle_range_str(config_s,fs,0); - + if (mrange && drange) { merged_range = PINT_merge_handle_range_strs(mrange, drange); @@ -4073,13 +4102,21 @@ static int cache_config_files( { int fd = 0, nread = 0; struct stat statbuf; +#ifdef WIN32 + char working_dir[MAX_PATH+1]; +#else char *working_dir = NULL; +#endif char *my_global_fn = NULL; char buf[512] = {0}; assert(config_s); +#ifdef WIN32 + GetCurrentDirectory(MAX_PATH+1, working_dir); +#else working_dir = getenv("PWD"); +#endif /* pick some filenames if not provided */ my_global_fn = ((global_config_filename != NULL) ? @@ -4107,7 +4144,11 @@ static int cache_config_files( else { assert(working_dir); +#ifdef WIN32 + _snprintf(buf, 512, "%s\\%s",working_dir, my_global_fn); +#else snprintf(buf, 512, "%s/%s",working_dir, my_global_fn); +#endif my_global_fn = buf; goto open_global_config; } @@ -4186,9 +4227,9 @@ static char *get_handle_range_str( assert(cur_h_mapping->alias_mapping); assert(cur_h_mapping->alias_mapping->host_alias); assert(cur_h_mapping->handle_range); - + if (strcmp(cur_h_mapping->alias_mapping->host_alias, - my_alias) == 0) + my_alias) == 0 || !strncmp(cur_h_mapping->alias_mapping->bmi_address, "osd", 3)) { ret = cur_h_mapping->handle_range; break; @@ -4197,6 +4238,7 @@ static char *get_handle_range_str( } } } + return ret; } diff --git a/src/common/misc/server-config.h b/src/common/misc/server-config.h index cb1bd16..c53f877 100644 --- a/src/common/misc/server-config.h +++ b/src/common/misc/server-config.h @@ -216,10 +216,15 @@ typedef struct server_configuration_s } osd_dir_type; enum { - POST_CREATE, /* delay the creates, create and write at the same time */ - NO_POST_CREATE, /* create the object first and then write to it */ + NO_POST_CREATE, /* create the object first and then write to it */ + POST_CREATE, /* delay the creates, create and write at the same time */ } post_create; + enum { + NO_MEMBER_ATTR, /* fetch attributes of a single object at once */ + GET_MEMBER_ATTR, /* fetch attributes of all the objects that are members of a collection */ + } member_attr; + void *private_data; } server_configuration_s; diff --git a/src/common/misc/state-machine-fns.c b/src/common/misc/state-machine-fns.c index 29e06ea..b316f61 100644 --- a/src/common/misc/state-machine-fns.c +++ b/src/common/misc/state-machine-fns.c @@ -68,7 +68,11 @@ int PINT_state_machine_terminate(struct PINT_smcb *smcb, job_status_s *r) /* base frame will not be processed */ gossip_debug(GOSSIP_STATE_MACHINE_DEBUG,"[SM Terminating Child]: my_frame:%p\n",my_frame); +#ifdef WIN32 + qlist_for_each_entry(f, &smcb->parent_smcb->frames, link, struct PINT_frame_s) +#else qlist_for_each_entry(f, &smcb->parent_smcb->frames, link) +#endif { if(my_frame == f->frame) { @@ -555,7 +559,11 @@ void PINT_smcb_free(struct PINT_smcb *smcb) gossip_debug(GOSSIP_STATE_MACHINE_DEBUG,"PINT_smcb_free: smcb:%p\n",smcb); +#ifdef WIN32 + qlist_for_each_entry_safe(frame_entry, tmp, &smcb->frames, link, struct PINT_frame_s, struct PINT_frame_s) +#else qlist_for_each_entry_safe(frame_entry, tmp, &smcb->frames, link) +#endif { if (frame_entry->frame) { @@ -678,7 +686,7 @@ void *PINT_sm_frame(struct PINT_smcb *smcb, int index) * Synopsis: pushes a new frame pointer onto the frame_stack */ 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, "[SM Frame PUSH]: (%p) frame: %p\n", @@ -795,7 +803,11 @@ static void PINT_sm_start_child_frames(struct PINT_smcb *smcb, int* children_sta * the first one immediately completes it will mistakenly believe it is * the last one and signal the parent. */ +#ifdef WIN32 + qlist_for_each_entry(f, &smcb->frames, link, struct PINT_frame_s) +#else qlist_for_each_entry(f, &smcb->frames, link) +#endif { /* run from TOS until the parent frame */ if(f->frame == my_frame) @@ -811,8 +823,11 @@ static void PINT_sm_start_child_frames(struct PINT_smcb *smcb, int* children_sta * complete before we leave this function. */ *children_started = smcb->children_running; - +#ifdef WIN32 + qlist_for_each_entry(f, &smcb->frames, link, struct PINT_frame_s) +#else qlist_for_each_entry(f, &smcb->frames, link) +#endif { /* run from TOS until the parent frame */ if(f->frame == my_frame) diff --git a/src/common/misc/state-machine.h b/src/common/misc/state-machine.h index 0241525..3de9ad2 100644 --- a/src/common/misc/state-machine.h +++ b/src/common/misc/state-machine.h @@ -203,7 +203,11 @@ PINT_sm_action PINT_state_machine_invoke(struct PINT_smcb *, job_status_s *); PINT_sm_action PINT_state_machine_start(struct PINT_smcb *, job_status_s *); PINT_sm_action PINT_state_machine_continue( struct PINT_smcb *smcb, job_status_s *r); +#ifdef WIN32 +int PINT_state_machine_locate(struct PINT_smcb *); +#else int PINT_state_machine_locate(struct PINT_smcb *) __attribute__((used)); +#endif 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); diff --git a/src/common/misc/str-utils.c b/src/common/misc/str-utils.c index 221753e..bf7067d 100644 --- a/src/common/misc/str-utils.c +++ b/src/common/misc/str-utils.c @@ -11,6 +11,14 @@ #include #include +#ifdef WIN32 +#include "wincommon.h" + +#define index(s, c) strchr(s, c) +#define snprintf(b, c, f, ...) _snprintf(b, c, f, __VA_ARGS__) +#define strdup(s) _strdup(s) +#endif + #include "str-utils.h" /* PINT_string_count_segments() @@ -219,7 +227,9 @@ int PINT_parse_handle_ranges( `\0' but **endptr is `\0' on return, the entire string is valid. */ out_extent->first = out_extent->last = -#ifdef HAVE_STRTOULL +#if defined(WIN32) + (PVFS_handle)_strtoui64(p, &endchar, 0); +#elif defined(HAVE_STRTOULL) (PVFS_handle)strtoull(p, &endchar, 0); #else (PVFS_handle)strtoul(p, &endchar, 0); @@ -234,7 +244,9 @@ int PINT_parse_handle_ranges( switch (*endchar) { case '-': /* we got the first half of the range. grab 2nd half */ -#ifdef HAVE_STRTOULL +#if defined(WIN32) + out_extent->last = (PVFS_handle)_strtoui64(p, &endchar, 0); +#elif defined(HAVE_STRTOULL) out_extent->last = (PVFS_handle)strtoull(p, &endchar, 0); #else out_extent->last = (PVFS_handle)strtoul(p, &endchar, 0); @@ -335,7 +347,7 @@ int PINT_get_next_path(char *path, char **newpath, int skip) return (-PVFS_EINVAL); } - *newpath = malloc(pathlen - delimiter1); + *newpath = (char *) malloc(pathlen - delimiter1); if (*newpath == NULL) { return (-PVFS_ENOMEM); @@ -523,6 +535,140 @@ int PINT_remove_base_dir( return ret; } +#if 0 +/* Initial Windows version -- not yet sure about file path format */ +/* PINT_remove_dir_prefix() + * + * Strips prefix directory out of the path, output includes beginning + * backslash + * + * path and prefix must start with \\path or X:\ + * + * Parameters: + * pathname - pointer to directory string (absolute) + * prefix - pointer to prefix dir string (absolute) + * out_path - pointer to output dir string + * max_out_len - max length of out_base_dir buffer + * + * All incoming arguments must be valid and non-zero + * + * Returns 0 on success; -errno on failure + * + * Example inputs and outputs/return values: + * + * pathname: \\mnt\pvfs2\foo, prefix: \\mnt\pvfs2 + * out_path: \foo, returns 0 + * pathname: \\mnt\pvfs2\foo, prefix: \\mnt\pvfs2\ + * out_path: \foo, returns 0 + * pathname: \\mnt\pvfs2\foo\bar, prefix: \\mnt\pvfs2 + * out_path: \foo\bar, returns 0 + * pathname: X:\mnt\pvfs2\foo\bar, prefix: X:\ (or X:) + * out_path: \mnt\pvfs2\foo\bar, returns 0 + * + * invalid pathname input examples: + * pathname: \\mnt\foo\bar, prefix: \\mnt\pvfs2 + * out_path: undefined, returns -PVFS_ENOENT + * pathname: \\mnt\pvfs2fake\foo\bar, prefix: \\mnt\pvfs2 + * out_path: undefined, returns -PVFS_ENOENT + * pathname: \\mnt\foo\bar, prefix: mnt\pvfs2 + * out_path: undefined, returns -PVFS_EINVAL + * pathname: mnt\foo\bar, prefix: \\mnt\pvfs2 + * out_path: undefined, returns -PVFS_EINVAL + * out_max_len not large enough for buffer, returns -PVFS_ENAMETOOLONG + */ +int PINT_remove_dir_prefix( + const char *pathname, + const char *prefix, + char *out_path, + int out_max_len) +{ + int ret = -PVFS_EINVAL; + int valid; + int prefix_len, pathname_len; + int cut_index; + + if (!pathname || !prefix || strlen(pathname) < 2 || strlen(prefix) < 2 || + !out_path || !out_max_len) + { + return ret; + } + + /* make sure we are given absolute paths */ + valid = pathname[0] >= 'A' && pathname[0] <= 'z' && + pathname[1] == ':' && + prefix[0] >= 'A' && prefix[0] <= 'z' && + prefix[1] == ':'; + if (!valid) + { + valid = (strncmp(pathname, "\\\\", 2) == 0) && + (strncmp(prefix, "\\\\", 2) == 0); + } + + if (!valid) + { + return ret; + } + + prefix_len = strlen(prefix); + pathname_len = strlen(pathname); + + /* account for trailing slashes on prefix */ + while (prefix[prefix_len - 1] == '\\') + { + prefix_len--; + } + + /* if prefix_len is now zero, then prefix must have been root + * directory; return copy of entire pathname + */ + if (prefix_len == 0) + { + cut_index = 0; + } + else + { + /* make sure prefix would fit in pathname */ + if (prefix_len > (pathname_len + 1)) + return (-PVFS_ENOENT); + + if (strncmp(prefix, pathname, prefix_len) == 0) + { + /* apparent match; see if next element is a slash */ + if ((pathname[prefix_len] != '\\') && + (pathname[prefix_len] != '\0')) + return (-PVFS_ENOENT); + + /* this was indeed a match */ + /* in the case of no trailing slash cut_index will point to the end + * of "prefix" (NULL). */ + cut_index = prefix_len; + } + else + { + return (-PVFS_ENOENT); + } + } + + /* if we hit this point, then we were successful */ + + /* is the buffer large enough? */ + if ((1 + strlen(&(pathname[cut_index]))) > out_max_len) + return (-PVFS_ENAMETOOLONG); + + /* try to handle the case of no trailing slash */ + if (pathname[cut_index] == '\0') + { + out_path[0] = '\\'; + out_path[1] = '\0'; + } + else + /* copy out appropriate part of pathname */ + strcpy(out_path, &(pathname[cut_index])); + + return 0; +} + +#endif /* PINT_remove_dir_prefix() * * Strips prefix directory out of the path, output includes beginning diff --git a/src/common/misc/tcache.h b/src/common/misc/tcache.h index 91ab5dc..2ebd820 100644 --- a/src/common/misc/tcache.h +++ b/src/common/misc/tcache.h @@ -7,7 +7,11 @@ #ifndef __TCACHE_H #define __TCACHE_H +#ifndef WIN32 #include +#else +#include "wincommon.h" +#endif #include "pvfs2-types.h" #include "quicklist.h" #include "quickhash.h" diff --git a/src/common/misc/xattr-utils.h b/src/common/misc/xattr-utils.h index e416afa..fe41453 100644 --- a/src/common/misc/xattr-utils.h +++ b/src/common/misc/xattr-utils.h @@ -17,6 +17,10 @@ #include #endif +#ifdef WIN32 +typedef size_t ssize_t; +#endif + #ifndef HAVE_FGETXATTR_PROTOTYPE #ifndef HAVE_FGETXATTR_EXTRA_ARGS /* prototype taken from fgetxattr(2) on Fedora FC4 */ diff --git a/src/common/quicklist/quicklist.h b/src/common/quicklist/quicklist.h index 6ea221b..538fc15 100644 --- a/src/common/quicklist/quicklist.h +++ b/src/common/quicklist/quicklist.h @@ -21,6 +21,10 @@ #include +#ifdef WIN32 +#include "wincommon.h" +#endif + struct qlist_head { struct qlist_head *next, *prev; }; @@ -191,11 +195,17 @@ static __inline__ void qlist_splice(struct qlist_head *qlist, struct qlist_head * @head: the head for your list. * @member: the name of the list_struct within the struct. */ -#define qlist_for_each_entry(pos, head, member) \ +#ifdef WIN32 +#define qlist_for_each_entry(pos, head, member, type) \ + for (pos = qlist_entry((head)->next, type, member); \ + &pos->member != (head); \ + pos = qlist_entry(pos->member.next, type, member)) +#else +#define qlist_for_each_entry(pos, head, member) \ for (pos = qlist_entry((head)->next, typeof(*pos), member); \ - &pos->member != (head); \ - pos = qlist_entry(pos->member.next, typeof(*pos), member)) \ - + &pos->member != (head); \ + pos = qlist_entry(pos->member.next, typeof(*pos), member)) +#endif /** * qlist_for_each_entry_safe - iterate over list of given type safe against removal of list entry * @pos: the type * to use as a loop counter. @@ -203,12 +213,19 @@ static __inline__ void qlist_splice(struct qlist_head *qlist, struct qlist_head * @head: the head for your list. * @member: the name of the list_struct within the struct. */ +#ifdef WIN32 +#define qlist_for_each_entry_safe(pos, n, head, member, pos_type, n_type) \ + for (pos = qlist_entry((head)->next, pos_type, member), \ + n = qlist_entry(pos->member.next, pos_type, member); \ + &pos->member != (head); \ + pos = n, n = qlist_entry(n->member.next, n_type, member)) +#else #define qlist_for_each_entry_safe(pos, n, head, member) \ for (pos = qlist_entry((head)->next, typeof(*pos), member), \ n = qlist_entry(pos->member.next, typeof(*pos), member); \ &pos->member != (head); \ pos = n, n = qlist_entry(n->member.next, typeof(*n), member)) - +#endif static inline int qlist_exists(struct qlist_head *list, struct qlist_head *qlink) { struct qlist_head *pos; diff --git a/src/common/statecomp/codegen.c b/src/common/statecomp/codegen.c index 22827dd..bccdcb3 100644 --- a/src/common/statecomp/codegen.c +++ b/src/common/statecomp/codegen.c @@ -22,7 +22,11 @@ static int needcomma = 1; +#ifdef WIN32 +static void gen_state_decl(struct state *s, char *state_name); +#else static void gen_state_decl(char *state_name); +#endif static void gen_runfunc_decl(char *func_name); static void gen_state_start(char *state_name, char *machine_name); static void gen_state_action( @@ -48,13 +52,23 @@ void gen_machine(char *machine_name) { if(s->action == ACTION_RUN || s->action == ACTION_PJMP) gen_runfunc_decl(s->function_or_machine); +#ifdef WIN32 + gen_state_decl(s, s->name); +#else gen_state_decl(s->name); +#endif } /* delcare the machine start point */ fprintf(out_file, "\nstruct PINT_state_machine_s %s = {\n", machine_name); +#ifdef WIN32 + /* Windows (VC++) does not support field names in structs */ + fprintf(out_file, "\t\"%s\", /* name */\n", machine_name); + fprintf(out_file, "\t&ST_%s /* first_state */\n", states->name); +#else fprintf(out_file, "\t.name = \"%s\",\n", machine_name); fprintf(out_file, "\t.first_state = &ST_%s\n", states->name); +#endif fprintf(out_file, "};\n\n"); /* generate all output */ @@ -167,22 +181,53 @@ static void gen_runfunc_decl(char *func_name) } } +#ifdef WIN32 +static void gen_state_decl(struct state *s, char *state_name) +#else static void gen_state_decl(char *state_name) +#endif { +#ifdef WIN32 + struct task *task; + struct transition *t; + int count; +#endif fprintf(out_file, "static struct PINT_state_s ST_%s;\n", state_name); +#ifdef WIN32 + /* determine PJMP count for array declaration */ + if (s->action == ACTION_PJMP) + { + for (task = s->task, count = 0; task; task = task->next, ++count) ; + fprintf(out_file, "static struct PINT_pjmp_tbl_s ST_%s_pjtbl[%d];\n", + state_name, count); + } + /* determine transition count for array declaration */ + for (t = s->transition, count = 0; t; t = t->next, ++count) ; + fprintf(out_file, "static struct PINT_tran_tbl_s ST_%s_trtbl[%d];\n", + state_name, count); +#else fprintf(out_file, "static struct PINT_pjmp_tbl_s ST_%s_pjtbl[];\n", state_name); fprintf(out_file, "static struct PINT_tran_tbl_s ST_%s_trtbl[];\n", state_name); +#endif } void gen_state_start(char *state_name, char *machine_name) { +#ifdef WIN32 + fprintf(out_file, + "static struct PINT_state_s ST_%s = {\n" + "\t \"%s\" , /* state_name */\n" + "\t &%s , /* parent_machine */\n", + state_name, state_name, machine_name); +#else fprintf(out_file, "static struct PINT_state_s ST_%s = {\n" "\t .state_name = \"%s\" ,\n" "\t .parent_machine = &%s ,\n", state_name, state_name, machine_name); +#endif } /** generates first two lines in the state machine (I think), @@ -195,24 +240,46 @@ void gen_state_action(enum state_action action, char *state_name) { switch (action) { - case ACTION_RUN: - fprintf(out_file, "\t .flag = SM_RUN ,\n"); + case ACTION_RUN: +#ifdef WIN32 + fprintf(out_file, "\t SM_RUN , /* flag */\n"); + fprintf(out_file, "\t { %s } , /* action.func */\n", run_func); + fprintf(out_file,"\t NULL , /* pjtbl */\n"); + fprintf(out_file,"\t ST_%s_trtbl /* trtbl */", state_name); +#else + fprintf(out_file, "\t .flag = SM_RUN ,\n"); fprintf(out_file, "\t .action.func = %s ,\n", run_func); fprintf(out_file,"\t .pjtbl = NULL ,\n"); fprintf(out_file,"\t .trtbl = ST_%s_trtbl ", state_name); - break; - case ACTION_PJMP: - fprintf(out_file, "\t .flag = SM_PJMP ,\n"); +#endif + break; + case ACTION_PJMP: +#ifdef WIN32 + fprintf(out_file, "\t SM_PJMP , /* flag */\n"); + fprintf(out_file, "\t { &%s }, /* action.func */\n", run_func); + fprintf(out_file,"\t ST_%s_pjtbl , /* pjtbl */\n", state_name); + fprintf(out_file,"\t ST_%s_trtbl /* trtbl */", state_name); + +#else + fprintf(out_file, "\t .flag = SM_PJMP ,\n"); fprintf(out_file, "\t .action.func = &%s ,\n", run_func); fprintf(out_file,"\t .pjtbl = ST_%s_pjtbl ,\n", state_name); fprintf(out_file,"\t .trtbl = ST_%s_trtbl ", state_name); - break; - case ACTION_JUMP: - fprintf(out_file, "\t .flag = SM_JUMP ,\n"); +#endif + break; + case ACTION_JUMP: +#ifdef WIN32 + fprintf(out_file, "\t SM_JUMP , /* flag */\n"); + fprintf(out_file, "\t { &%s }, /* action.nested */\n", run_func); + fprintf(out_file,"\t NULL , /* pjtbl */\n"); + fprintf(out_file,"\t ST_%s_trtbl /* trtbl */", state_name); +#else + fprintf(out_file, "\t .flag = SM_JUMP ,\n"); fprintf(out_file, "\t .action.nested = &%s ,\n", run_func); fprintf(out_file,"\t .pjtbl = NULL ,\n"); fprintf(out_file,"\t .trtbl = ST_%s_trtbl ", state_name); - break; +#endif + break; } /* generate the end of the state struct with refs to jump tbls */ } @@ -239,7 +306,11 @@ static void gen_return_code(char *return_code) { fprintf(out_file,",\n"); } +#ifdef WIN32 + fprintf(out_file, "\t{ %s ", return_code); +#else fprintf(out_file, "\t{ .return_value = %s ", return_code); +#endif needcomma = 1; } @@ -250,20 +321,41 @@ static void gen_next_state(enum transition_type type, char *new_state) fprintf(out_file,",\n"); } switch (type) { - case TRANS_PJMP: - fprintf(out_file, "\n\t .state_machine = &%s }", new_state); - break; - case TRANS_NEXT_STATE: - fprintf(out_file, "\t .next_state = &ST_%s }", new_state); - break; - case TRANS_RETURN: - terminate_path_flag = 1; - fprintf(out_file, "\t .flag = SM_RETURN }"); - break; - case TRANS_TERMINATE: - terminate_path_flag = 1; - fprintf(out_file, "\n\t .flag = SM_TERM }"); - break; + case TRANS_PJMP: +#ifdef WIN32 + fprintf(out_file, "\t SM_NONE ,\n"); /* flag */ + fprintf(out_file, "\n\t &%s }", new_state); +#else + fprintf(out_file, "\n\t .state_machine = &%s }", new_state); +#endif + break; + case TRANS_NEXT_STATE: +#ifdef WIN32 + fprintf(out_file, "\t SM_NONE ,\n"); /* flag */ + fprintf(out_file, "\t &ST_%s }", new_state); +#else + fprintf(out_file, "\t .next_state = &ST_%s }", new_state); +#endif + break; + case TRANS_RETURN: + terminate_path_flag = 1; +#ifdef WIN32 + fprintf(out_file, "\t SM_RETURN ,\n"); /* flag */ + fprintf(out_file, "\t NULL }"); /* next_state/state_machine */ + +#else + fprintf(out_file, "\t .flag = SM_RETURN }"); +#endif + break; + case TRANS_TERMINATE: + terminate_path_flag = 1; +#ifdef WIN32 + fprintf(out_file, "\t SM_TERM ,\n"); /* flag */ + fprintf(out_file, "\t NULL }"); /* next_state/state_machine */ +#else + fprintf(out_file, "\n\t .flag = SM_TERM }"); +#endif + break; } needcomma = 1; } diff --git a/src/common/statecomp/parser.y b/src/common/statecomp/parser.y index 90bded7..a4747c4 100644 --- a/src/common/statecomp/parser.y +++ b/src/common/statecomp/parser.y @@ -18,6 +18,10 @@ #include "statecomp.h" +#ifdef WIN32 +#define _STDLIB_H /* mark stdlib.h included */ +#endif + /* We never use this, disable default. */ #define YY_LOCATION_PRINT 0 diff --git a/src/common/statecomp/scanner.l b/src/common/statecomp/scanner.l index 27b31a5..7c32ffd 100644 --- a/src/common/statecomp/scanner.l +++ b/src/common/statecomp/scanner.l @@ -80,7 +80,9 @@ id [_a-zA-Z][_0-9a-zA-Z]* "\%" {fprintf(out_file, "%s", yytext);} "\%\%" {BEGIN(CODE);} -"\%\%" {fprintf(out_file,"# %d \"%s\"\n", line, in_file_name); +"\%\%" {fprintf(out_file,"#ifndef WIN32\n"); + fprintf(out_file,"# %d \"%s\"\n", line, in_file_name); + fprintf(out_file,"#endif\n"); BEGIN(0);} "machine" {RETURNVAL(MACHINE);} diff --git a/src/common/statecomp/statecomp.c b/src/common/statecomp/statecomp.c index 6b75f3b..2a3e798 100644 --- a/src/common/statecomp/statecomp.c +++ b/src/common/statecomp/statecomp.c @@ -25,7 +25,9 @@ #include #include #include +#ifndef WIN32 #include +#endif #include "statecomp.h" @@ -37,6 +39,13 @@ int yyparse (void); #endif #endif +#ifdef WIN32 +#define __func__ __FUNCTION__ +#define unlink _unlink + +extern int yyparse(); +#endif + /* * Global Variables */ diff --git a/src/io/bmi/bmi-types.h b/src/io/bmi/bmi-types.h index 371be71..684752a 100644 --- a/src/io/bmi/bmi-types.h +++ b/src/io/bmi/bmi-types.h @@ -24,6 +24,10 @@ #include #include "pvfs2-debug.h" +#ifdef WIN32 +#include +#endif + typedef int64_t bmi_size_t; /**< Data region size */ typedef int32_t bmi_msg_tag_t; /**< User-specified message tag */ typedef int64_t bmi_context_id; /**< Context identifier */ diff --git a/src/io/bmi/bmi.c b/src/io/bmi/bmi.c index 4b76973..47556b0 100644 --- a/src/io/bmi/bmi.c +++ b/src/io/bmi/bmi.c @@ -14,7 +14,9 @@ #include #include #include +#ifndef WIN32 #include +#endif #include #include "bmi.h" @@ -29,6 +31,13 @@ #include "pvfs2-internal.h" #include "pvfs2-debug.h" +#ifdef WIN32 +#include "wincommon.h" + +#define EREMOTE 66 +#define EHOSTDOWN 112 +#endif + static int bmi_initialized_count = 0; static gen_mutex_t bmi_initialize_mutex = GEN_MUTEX_INITIALIZER; @@ -558,6 +567,12 @@ int BMI_finalize(void) /* (side effect: destroys all method addresses as well) */ ref_list_cleanup(cur_ref_list); +#ifdef WIN32 + /* Windows Sockets finalize + This must be done here rather than bmi_wintcp--after all addresses + have been destroyed */ + WSACleanup(); +#endif /* shut down id generator */ id_gen_safe_finalize(); @@ -996,7 +1011,13 @@ int BMI_testunexpected(int incount, int ret = -1; int position = 0; int tmp_outcount = 0; +#ifdef WIN32 + struct bmi_method_unexpected_info *sub_info = + (struct bmi_method_unexpected_info *) + malloc(sizeof(struct bmi_method_unexpected_info) * incount); +#else struct bmi_method_unexpected_info sub_info[incount]; +#endif ref_st_p tmp_ref = NULL; int tmp_active_method_count = 0; @@ -1010,7 +1031,12 @@ int BMI_testunexpected(int incount, gen_mutex_unlock(&active_method_count_mutex); if (max_idle_time_ms < 0) + { +#ifdef WIN32 + free(sub_info); +#endif return (bmi_errno_to_pvfs(-EINVAL)); + } *outcount = 0; @@ -1026,6 +1052,9 @@ int BMI_testunexpected(int incount, if (ret < 0) { /* can't recover from this */ +#ifdef WIN32 + free(sub_info); +#endif gossip_lerr("Error: critical BMI_testunexpected failure.\n"); return (ret); } @@ -1050,6 +1079,9 @@ int BMI_testunexpected(int incount, if (!tmp_ref) { /* yeah, right */ +#ifdef WIN32 + free(sub_info); +#endif gossip_lerr("Error: critical BMI_testunexpected failure.\n"); gen_mutex_unlock(&ref_mutex); return (bmi_errno_to_pvfs(-EPROTO)); @@ -1061,7 +1093,9 @@ int BMI_testunexpected(int incount, gen_mutex_unlock(&ref_mutex); info_array[i].addr = tmp_ref->bmi_addr; } - +#ifdef WIN32 + free(sub_info); +#endif /* return 1 if anything completed */ if (ret == 0 && *outcount > 0) { @@ -1090,14 +1124,18 @@ int BMI_testcontext(int incount, int position = 0; int tmp_outcount = 0; int tmp_active_method_count = 0; +#ifndef WIN32 struct timespec ts; +#endif gen_mutex_lock(&active_method_count_mutex); tmp_active_method_count = active_method_count; gen_mutex_unlock(&active_method_count_mutex); if (max_idle_time_ms < 0) + { return (bmi_errno_to_pvfs(-EINVAL)); + } *outcount = 0; @@ -1106,9 +1144,13 @@ int BMI_testcontext(int incount, /* nothing active yet, just snooze and return */ if(max_idle_time_ms > 0) { - ts.tv_sec = 0; +#ifdef WIN32 + Sleep(2); +#else + ts.tv_sec = 0; ts.tv_nsec = 2000; nanosleep(&ts, NULL); +#endif } return(0); } @@ -1118,7 +1160,8 @@ int BMI_testcontext(int incount, while (position < incount && i < tmp_active_method_count) { - if (expected_method_usage[i].plan) { + if (expected_method_usage[i].plan) + { ret = active_method_table[i]->testcontext( incount - position, &out_id_array[position], @@ -2286,9 +2329,9 @@ static void bmi_check_forget_list(void) static void bmi_addr_drop(ref_st_p tmp_ref) { struct method_drop_addr_query query; + int ret = 0; query.response = 0; query.addr = tmp_ref->method_addr; - int ret = 0; /* reference count is zero; ask module if it wants us to discard * the address; TCP will tell us to drop addresses for which the @@ -2349,7 +2392,11 @@ static void bmi_check_addr_force_drop (void) link); gen_mutex_unlock(&bmi_addr_force_drop_list_mutex); gen_mutex_lock(&ref_mutex); +#ifdef WIN32 + qlist_for_each_entry(ref_item, cur_ref_list, list_link, ref_st) +#else qlist_for_each_entry(ref_item, cur_ref_list, list_link) +#endif { if ((ref_item->ref_count == 0) && (ref_item->interface->method_name == drop_item->method_name)) diff --git a/src/io/bmi/bmi_ib/ib.c b/src/io/bmi/bmi_ib/ib.c index 29c0872..19fcb0a 100644 --- a/src/io/bmi/bmi_ib/ib.c +++ b/src/io/bmi/bmi_ib/ib.c @@ -1557,6 +1557,7 @@ static struct bmi_method_addr *ib_alloc_method_addr(ib_connection_t *c, ibmap->hostname = hostname; ibmap->port = port; ibmap->reconnect_flag = reconnect_flag; + ibmap->ref_count = 1; return map; } @@ -1609,6 +1610,7 @@ static struct bmi_method_addr *BMI_ib_method_addr_lookup(const char *id) ib_method_addr_t *ibmap = c->remote_map->method_data; if (ibmap->port == port && !strcmp(ibmap->hostname, hostname)) { map = c->remote_map; + ibmap->ref_count++; break; } } @@ -1953,8 +1955,12 @@ static int BMI_ib_set_info(int option, void *param __unused) case BMI_DROP_ADDR: { struct bmi_method_addr *map = param; ib_method_addr_t *ibmap = map->method_data; - free(ibmap->hostname); - free(map); + ibmap->ref_count--; + if (ibmap->ref_count == 0) + { + free(ibmap->hostname); + free(map); + } break; } case BMI_OPTIMISTIC_BUFFER_REG: { diff --git a/src/io/bmi/bmi_ib/ib.h b/src/io/bmi/bmi_ib/ib.h index 7635c2c..0f17e74 100644 --- a/src/io/bmi/bmi_ib/ib.h +++ b/src/io/bmi/bmi_ib/ib.h @@ -82,6 +82,7 @@ typedef struct { int port; ib_connection_t *c; int reconnect_flag; + int ref_count; } ib_method_addr_t; /* diff --git a/src/io/bmi/bmi_mx/mx.c b/src/io/bmi/bmi_mx/mx.c index 519ddc3..ff7bcf0 100644 --- a/src/io/bmi/bmi_mx/mx.c +++ b/src/io/bmi/bmi_mx/mx.c @@ -24,11 +24,11 @@ gen_mutex_t mem_used_lock; /* lock */ #endif /* statics for event logging */ -static PINT_event_type bmi_mx_send_event_id; -static PINT_event_type bmi_mx_recv_event_id; +static PINT_event_type bmi_mx_send_event_id __attribute__ ((unused)); +static PINT_event_type bmi_mx_recv_event_id __attribute__ ((unused)); -static PINT_event_group bmi_mx_event_group; -static pid_t bmi_mx_pid; +static PINT_event_group bmi_mx_event_group __attribute__ ((unused)); +static pid_t bmi_mx_pid __attribute__ ((unused)); mx_unexp_handler_action_t bmx_unexpected_recv(void *context, mx_endpoint_addr_t source, @@ -39,6 +39,12 @@ bmx_peer_connect(struct bmx_peer *peer); static void bmx_create_peername(void); +void * +BMI_mx_memalloc(bmi_size_t size, enum bmi_op_type send_recv); + +static int +bmx_peer_init_state(struct bmx_peer *peer) __attribute__ ((unused)); + /**** Completion function token handling ****************************/ /* We should not hold any locks when calling mx_test[_any](), * mx_wait_any() or mx_cancel(). We want to avoid races between them, @@ -532,41 +538,36 @@ bmx_verify_num_str(char *num_str) static int bmx_parse_peername(const char *peername, char **hostname, uint32_t *board, uint32_t *ep_id) { - int ret = 0; - int colon1_found = 0; - int colon2_found = 0; - char *s = NULL; - char *colon1 = NULL; - char *colon2 = NULL; - char *fs = NULL; - char *host = NULL; - uint32_t bd = -1; - uint32_t ep = 0; - - if (peername == NULL || hostname == NULL || board == NULL || ep_id == NULL) { - debug(BMX_DB_INFO, "parse_peername() called with invalid parameter"); + int ret = 0; + int colon1_found = 0; + int colon2_found = 0; + char *tmp_peername = NULL; + char *colon1 = NULL; + char *colon2 = NULL; + char *fs = NULL; + char *host = NULL; + uint32_t bd = -1; + uint32_t ep = 0; + + tmp_peername = string_key("mx",peername); + if (!tmp_peername) { + debug(BMX_DB_INFO, "parse_peername() called with invalid peername"); return -BMI_EINVAL; } - if (peername[0] != 'm' || - peername[1] != 'x' || - peername[2] != ':' || - peername[3] != '/' || - peername[4] != '/') { - debug(BMX_DB_INFO, "parse_peername() peername does not start with mx://"); - return -1; + if (tmp_peername == NULL || hostname == NULL || board == NULL || ep_id == NULL) { + debug(BMX_DB_INFO, "parse_peername() called with invalid parameter"); + return -BMI_EINVAL; } - - s = strdup(&peername[5]); - fs = strchr(s, '/'); + fs = strchr(tmp_peername, '/'); if (fs) { *fs = '\0'; } - colon1 = strchr(s, ':'); + colon1 = strchr(tmp_peername, ':'); if (!colon1) { debug(BMX_DB_INFO, "parse_peername() strchr() failed"); } else { - colon2 = strrchr(s, ':'); + colon2 = strrchr(tmp_peername, ':'); if (colon1 == colon2) { /* colon2_found == 0 */ debug(BMX_DB_INFO, "parse_peername() MX hostname does not " @@ -600,15 +601,15 @@ bmx_parse_peername(const char *peername, char **hostname, uint32_t *board, uint3 NULL != strchr(colon2, ':')) { debug(BMX_DB_INFO, "parse_peername() too many ':' (%s %s)", colon1, colon2); - free(s); + free(tmp_peername); return -1; } } - host = strdup(s); + host = strdup(tmp_peername); if (!host) { debug(BMX_DB_MEM, "parse_peername() malloc() failed"); - free(s); + free(tmp_peername); return -1; } @@ -620,7 +621,7 @@ bmx_parse_peername(const char *peername, char **hostname, uint32_t *board, uint3 } else { debug(BMX_DB_WARN, "%s is not a valid hostname", host); free(host); - free(s); + free(tmp_peername); return -1; } @@ -628,21 +629,21 @@ bmx_parse_peername(const char *peername, char **hostname, uint32_t *board, uint3 if (ret != 0) { debug(BMX_DB_INFO, "%s is not a valid hostname", host); free(host); - free(s); + free(tmp_peername); return -1; } ret = bmx_verify_num_str(colon1); if (ret != 0) { debug(BMX_DB_INFO, "%s is not a valid board ID", host); free(host); - free(s); + free(tmp_peername); return -1; } ret = bmx_verify_num_str(colon2); if (ret != 0) { debug(BMX_DB_INFO, "%s is not a valid endpoint ID", host); free(host); - free(s); + free(tmp_peername); return -1; } @@ -650,7 +651,7 @@ bmx_parse_peername(const char *peername, char **hostname, uint32_t *board, uint3 *board = bd; *ep_id = ep; - free(s); + free(tmp_peername); return 0; } diff --git a/src/io/bmi/bmi_tcp/bmi-tcp.c b/src/io/bmi/bmi_tcp/bmi-tcp.c index ed70446..551bf84 100644 --- a/src/io/bmi/bmi_tcp/bmi-tcp.c +++ b/src/io/bmi/bmi_tcp/bmi-tcp.c @@ -182,7 +182,9 @@ struct tcp_msg_header #define BMI_TCP_ENC_HDR(hdr) \ do { \ - *((uint32_t*)&((hdr).enc_hdr[0])) = htobmi32((hdr).magic_nr); \ + uint32_t *tmp32; \ + tmp32 = (uint32_t *)&(hdr).enc_hdr[0]; \ + *(tmp32) = htobmi32((hdr).magic_nr); \ *((uint32_t*)&((hdr).enc_hdr[4])) = htobmi32((hdr).mode); \ *((uint64_t*)&((hdr).enc_hdr[8])) = htobmi64((hdr).tag); \ *((uint64_t*)&((hdr).enc_hdr[16])) = htobmi64((hdr).size); \ @@ -190,12 +192,15 @@ struct tcp_msg_header #define BMI_TCP_DEC_HDR(hdr) \ do { \ - (hdr).magic_nr = bmitoh32(*((uint32_t*)&((hdr).enc_hdr[0]))); \ - (hdr).mode = bmitoh32(*((uint32_t*)&((hdr).enc_hdr[4]))); \ - (hdr).tag = bmitoh64(*((uint64_t*)&((hdr).enc_hdr[8]))); \ - (hdr).size = bmitoh64(*((uint64_t*)&((hdr).enc_hdr[16]))); \ + uint32_t tmp32; \ + memcpy(&tmp32,&(hdr).enc_hdr[0],sizeof(uint32_t)); \ + (hdr).magic_nr = bmitoh32(tmp32); \ + (hdr).mode = bmitoh32(*((uint32_t*)&((hdr).enc_hdr[4]))); \ + (hdr).tag = bmitoh64(*((uint64_t*)&((hdr).enc_hdr[8]))); \ + (hdr).size = bmitoh64(*((uint64_t*)&((hdr).enc_hdr[16]))); \ } while(0) + /* enumerate states that we care about */ enum bmi_tcp_state { @@ -3122,6 +3127,7 @@ static int tcp_do_work_recv(bmi_method_addr_p map, int* stall_flag) /* decode the header */ BMI_TCP_DEC_HDR(new_header); + /* so we have the header. now what? These are the possible * scenarios: * a) unexpected message diff --git a/src/io/bmi/reference-list.h b/src/io/bmi/reference-list.h index b91e50b..1bd63fd 100644 --- a/src/io/bmi/reference-list.h +++ b/src/io/bmi/reference-list.h @@ -19,6 +19,12 @@ #include "quicklist.h" #include "quickhash.h" +#ifdef WIN32 +/* interface is a macro on Windows */ +#undef interface +#define interface _interface +#endif + typedef struct qlist_head *ref_list_p; /**********************************************************************/ diff --git a/src/io/description/dist-basic.c b/src/io/description/dist-basic.c index 8e0e2fb..2129705 100644 --- a/src/io/description/dist-basic.c +++ b/src/io/description/dist-basic.c @@ -106,6 +106,15 @@ static PINT_dist_methods basic_methods = { params_string }; +#ifdef WIN32 +PINT_dist basic_dist = { + PVFS_DIST_BASIC_NAME, + roundup8(PVFS_DIST_BASIC_NAME_SIZE), /* name size */ + 0, /* param size */ + &basic_params, + &basic_methods +}; +#else PINT_dist basic_dist = { .dist_name = PVFS_DIST_BASIC_NAME, .name_size = roundup8(PVFS_DIST_BASIC_NAME_SIZE), /* name size */ @@ -113,6 +122,7 @@ PINT_dist basic_dist = { .params = &basic_params, .methods = &basic_methods }; +#endif /* * Local variables: diff --git a/src/io/description/dist-simple-stripe.c b/src/io/description/dist-simple-stripe.c index 851be7c..cd12b02 100644 --- a/src/io/description/dist-simple-stripe.c +++ b/src/io/description/dist-simple-stripe.c @@ -219,6 +219,15 @@ static PINT_dist_methods simple_stripe_methods = { params_string }; +#ifdef WIN32 +PINT_dist simple_stripe_dist = { + PVFS_DIST_SIMPLE_STRIPE_NAME, + roundup8(PVFS_DIST_SIMPLE_STRIPE_NAME_SIZE), /* name size */ + roundup8(sizeof(PVFS_simple_stripe_params)), /* param size */ + &simple_stripe_params, + &simple_stripe_methods +}; +#else PINT_dist simple_stripe_dist = { .dist_name = PVFS_DIST_SIMPLE_STRIPE_NAME, .name_size = roundup8(PVFS_DIST_SIMPLE_STRIPE_NAME_SIZE), /* name size */ @@ -226,6 +235,7 @@ PINT_dist simple_stripe_dist = { .params = &simple_stripe_params, .methods = &simple_stripe_methods }; +#endif /* diff --git a/src/io/description/dist-twod-stripe.c b/src/io/description/dist-twod-stripe.c index 0be966d..e99ac62 100644 --- a/src/io/description/dist-twod-stripe.c +++ b/src/io/description/dist-twod-stripe.c @@ -556,6 +556,15 @@ static PINT_dist_methods twod_stripe_methods = { params_string }; +#ifdef WIN32 +PINT_dist twod_stripe_dist = { + PVFS_DIST_TWOD_STRIPE_NAME, + roundup8(PVFS_DIST_TWOD_STRIPE_NAME_SIZE), /* name size */ + roundup8(sizeof(PVFS_twod_stripe_params)), /* param size */ + &twod_stripe_params, + &twod_stripe_methods +}; +#else PINT_dist twod_stripe_dist = { .dist_name = PVFS_DIST_TWOD_STRIPE_NAME, .name_size = roundup8(PVFS_DIST_TWOD_STRIPE_NAME_SIZE), /* name size */ @@ -563,6 +572,7 @@ PINT_dist twod_stripe_dist = { .params = &twod_stripe_params, .methods = &twod_stripe_methods }; +#endif /* * Local variables: diff --git a/src/io/description/dist-varstrip-parser.c b/src/io/description/dist-varstrip-parser.c index 129659a..142d676 100644 --- a/src/io/description/dist-varstrip-parser.c +++ b/src/io/description/dist-varstrip-parser.c @@ -71,7 +71,11 @@ static int strips_parse_elem( s_size = strtok(NULL, ";"); if (s_size != NULL) { +#ifdef WIN32 + i_size = _atoi64(s_size); +#else i_size = atoll(s_size); +#endif if (i_size > 0) { if (strlen(s_size) > 1) diff --git a/src/io/description/dist-varstrip.c b/src/io/description/dist-varstrip.c index 9a057b5..347bf91 100644 --- a/src/io/description/dist-varstrip.c +++ b/src/io/description/dist-varstrip.c @@ -456,6 +456,15 @@ static PINT_dist_methods varstrip_methods = { params_string }; +#ifdef WIN32 +PINT_dist varstrip_dist = { + PVFS_DIST_VARSTRIP_NAME, + roundup8(PVFS_DIST_VARSTRIP_NAME_SIZE), /* name size */ + roundup8(sizeof(PVFS_varstrip_params)), /* param size */ + &varstrip_params, + &varstrip_methods +}; +#else PINT_dist varstrip_dist = { .dist_name = PVFS_DIST_VARSTRIP_NAME, .name_size = roundup8(PVFS_DIST_VARSTRIP_NAME_SIZE), /* name size */ @@ -463,6 +472,7 @@ PINT_dist varstrip_dist = { .params = &varstrip_params, .methods = &varstrip_methods }; +#endif /* * Local variables: diff --git a/src/io/description/pint-dist-utils.c b/src/io/description/pint-dist-utils.c index c958278..eb3ab97 100644 --- a/src/io/description/pint-dist-utils.c +++ b/src/io/description/pint-dist-utils.c @@ -195,15 +195,15 @@ int PINT_dist_register_param_offset(const char* dist_name, int PINT_dist_unregister_param_offset(const char *dist_name, const char *param_name) { - int i = 0; + int i = 0, dlen, plen; if( !dist_name || !param_name ) { return -EINVAL; } - int dlen = strlen(dist_name) + 1; - int plen = strlen(param_name) + 1; + dlen = strlen(dist_name) + 1; + plen = strlen(param_name) + 1; for( i = 0; i < PINT_dist_param_table_entries; i++ ) { diff --git a/src/io/description/pint-request.c b/src/io/description/pint-request.c index 0b9cb61..13bbba5 100644 --- a/src/io/description/pint-request.c +++ b/src/io/description/pint-request.c @@ -14,6 +14,10 @@ #include #include "pvfs2-internal.h" +#ifdef WIN32 +typedef uint32_t u_int32_t; +#endif + static PVFS_offset PINT_request_disp(PINT_Request *request); /* this macro is only used in this file to add a segment to the @@ -577,14 +581,22 @@ PVFS_size PINT_distribute(PVFS_offset offset, if (!rfdata || !rfdata->dist || !rfdata->dist->methods || !rfdata->dist->params) { - if (!rfdata) + if (!rfdata) + { gossip_debug(GOSSIP_REQUEST_DEBUG,"rfdata is NULL\n"); + } else if (!rfdata->dist) + { gossip_debug(GOSSIP_REQUEST_DEBUG,"rfdata->dist is NULL\n"); + } else if (!rfdata->dist->methods) + { gossip_debug(GOSSIP_REQUEST_DEBUG,"rfdata->dist->methods is NULL\n"); + } else if (!rfdata->dist->params) + { gossip_debug(GOSSIP_REQUEST_DEBUG,"rfdata->dist->params is NULL\n"); + } gossip_lerr("Bad Distribution! Bailing out!\n"); return 0; } diff --git a/src/io/description/pvfs-request.c b/src/io/description/pvfs-request.c index e4ccae5..4db4530 100644 --- a/src/io/description/pvfs-request.c +++ b/src/io/description/pvfs-request.c @@ -7,7 +7,9 @@ #include #include +#ifndef WIN32 #include +#endif #include "string.h" #include "pvfs2-types.h" #include "pint-request.h" @@ -238,6 +240,7 @@ int PVFS_Request_indexed(int32_t count, return PVFS_SUCCESS; } +#ifndef WIN32 static int PVFS_Request_indexed_block(int32_t count, int32_t blocklength, PVFS_size * displacements, @@ -258,6 +261,7 @@ static int PVFS_Request_indexed_block(int32_t count, return PVFS_Request_indexed(count, blocklengths, displacements, oldreq, newreq); } +#endif int PVFS_Request_hindexed(int32_t count, int32_t * blocklengths, diff --git a/src/io/dev/pint-dev-shared.h b/src/io/dev/pint-dev-shared.h index 0c6a1ef..82b063b 100644 --- a/src/io/dev/pint-dev-shared.h +++ b/src/io/dev/pint-dev-shared.h @@ -15,8 +15,10 @@ #ifdef __KERNEL__ #include #else +#ifndef WIN32 #include /* needed for constructing the _IO macros */ #endif +#endif /* version number for use in communicating between kernel space and user * space diff --git a/src/io/dev/pint-dev.c b/src/io/dev/pint-dev.c index f0584f3..7b5dc8b 100644 --- a/src/io/dev/pint-dev.c +++ b/src/io/dev/pint-dev.c @@ -8,26 +8,44 @@ */ #include +#ifndef WIN32 #include +#endif #include #include #include #include #include #include +#ifndef WIN32 #include #include #include #include +#endif #include +#ifndef WIN32 #include +#endif + +#ifdef WIN32 +#include + +/* define our own iovec */ +struct iovec { + void *iov_base; + size_t iov_len; +}; +#endif #include "pint-mem.h" #include "pvfs2-types.h" #include "pvfs2-debug.h" #include "gossip.h" #include "pint-dev.h" +#ifndef WIN32 #include "pvfs2-dev-proto.h" +#endif #include "pvfs2-internal.h" #ifdef WITH_LINUX_KMOD @@ -171,7 +189,11 @@ void PINT_dev_finalize(void) { if (pdev_fd > -1) { +#ifdef WIN32 + _close(pdev_fd); +#else close(pdev_fd); +#endif pdev_fd = -1; } } @@ -231,7 +253,6 @@ int PINT_dev_get_mapped_regions(int ndesc, struct PVFS_dev_map_desc *desc, break; } -#ifdef REDHAT_RELEASE_9 /* fixes a corruption issue on linux 2.4 kernels where the buffers are * not being pinned in memory properly */ @@ -240,7 +261,7 @@ int PINT_dev_get_mapped_regions(int ndesc, struct PVFS_dev_map_desc *desc, gossip_err("Error: FAILED to mlock shared buffer\n"); break; } -#endif + desc[i].ptr = ptr; desc[i].total_size = total_size; desc[i].size = params[i].dev_buffer_size; @@ -298,7 +319,6 @@ void PINT_dev_put_mapped_regions(int ndesc, struct PVFS_dev_map_desc *desc) ptr = (void *) desc[i].ptr; assert(ptr); -#ifdef REDHAT_RELEASE_9 /* fixes a corruption issue on linux 2.4 kernels where the buffers are * not being pinned in memory properly */ @@ -306,7 +326,6 @@ void PINT_dev_put_mapped_regions(int ndesc, struct PVFS_dev_map_desc *desc) { gossip_err("Error: FAILED to munlock shared buffer\n"); } -#endif PINT_mem_aligned_free(ptr); } @@ -609,11 +628,15 @@ int PINT_dev_write_list( enum PINT_dev_buffer_type buffer_type, PVFS_id_gen_t tag) { - struct iovec io_array[8]; + struct iovec io_array[10]; int io_count = 3; int i; int ret = -1; int32_t proto_ver = PVFS_KERNEL_PROTO_VERSION; +#ifdef WIN32 + char *buffer, *b; + size_t bsize = 0; +#endif /* lets be reasonable about list size :) */ /* two vecs are taken up by magic nr and tag */ @@ -650,8 +673,35 @@ int PINT_dev_write_list( io_count++; } - ret = writev(pdev_fd, io_array, io_count); +#ifdef WIN32 + /* we must write one buffer on Windows */ + /* compute buffer size */ + for (i = 0; i < io_count; i++) + { + bsize += io_array[i].iov_len; + } + + /* allocate buffer */ + buffer = (char *) malloc(bsize); + if (buffer == NULL) + { + return (-PVFS_ENOMEM); + } + + /* copy multiple vectors into buffer */ + for (i = 0, b = buffer; i < io_count; i++) + { + memcpy(b, io_array[i].iov_base, io_array[i].iov_len); + b += io_array[i].iov_len; + } + /* write the buffer */ + ret = _write(pdev_fd, buffer, bsize); + + free(buffer); +#else + ret = writev(pdev_fd, io_array, io_count); +#endif return ((ret < 0) ? -(PVFS_EIO|PVFS_ERROR_DEV) : 0); } diff --git a/src/io/flow/flow.c b/src/io/flow/flow.c index 671830c..54726f5 100644 --- a/src/io/flow/flow.c +++ b/src/io/flow/flow.c @@ -8,8 +8,10 @@ /* (see flow.h) */ #include +#ifndef WIN32 #include #include +#endif #include #include diff --git a/src/io/flow/flowproto-bmi-trove/flowproto-multiqueue.c b/src/io/flow/flowproto-bmi-trove/flowproto-multiqueue.c index 810dd12..ef700bc 100644 --- a/src/io/flow/flowproto-bmi-trove/flowproto-multiqueue.c +++ b/src/io/flow/flowproto-bmi-trove/flowproto-multiqueue.c @@ -9,8 +9,10 @@ #include #include #include +#ifndef WIN32 #include #include +#endif #include "gossip.h" #include "quicklist.h" @@ -1066,6 +1068,10 @@ static int bmi_send_callback_fn(void *user_ptr, PINT_PERF_READ, actual_size, PINT_PERF_ADD); + PINT_perf_count(PINT_server_pc, + PINT_PERF_FLOW_READ, + actual_size, + PINT_PERF_ADD); flow_data->parent->total_transferred += actual_size; @@ -1351,11 +1357,14 @@ static void trove_write_callback_fn(void *user_ptr, result_tmp = &q_item->result_chain; do{ q_item->parent->total_transferred += result_tmp->result.bytes; - PINT_perf_count( - PINT_server_pc, - PINT_PERF_WRITE, - result_tmp->result.bytes, - PINT_PERF_ADD); + PINT_perf_count( PINT_server_pc, + PINT_PERF_WRITE, + result_tmp->result.bytes, + PINT_PERF_ADD); + PINT_perf_count( PINT_server_pc, + PINT_PERF_FLOW_WRITE, + result_tmp->result.bytes, + PINT_PERF_ADD); old_result_tmp = result_tmp; result_tmp = result_tmp->next; if(old_result_tmp != &q_item->result_chain) diff --git a/src/io/job/job-desc-queue.c b/src/io/job/job-desc-queue.c index 619efa7..fcf0f72 100644 --- a/src/io/job/job-desc-queue.c +++ b/src/io/job/job-desc-queue.c @@ -18,6 +18,10 @@ #include "id-generator.h" #include "pint-util.h" +#ifdef WIN32 +typedef enum job_type job_type_t; +#endif + /*************************************************************** * Visible functions */ @@ -41,7 +45,11 @@ struct job_desc *alloc_job_desc(int type) id_gen_safe_register(&(jd->job_id), jd); +#ifdef WIN32 + jd->type = (job_type_t) type; +#else jd->type = type; +#endif return (jd); }; diff --git a/src/io/job/job-time-mgr.c b/src/io/job/job-time-mgr.c index 3444b07..733927d 100644 --- a/src/io/job/job-time-mgr.c +++ b/src/io/job/job-time-mgr.c @@ -4,7 +4,9 @@ * See COPYING in top-level directory. */ +#ifndef WIN32 #include +#endif #include #include diff --git a/src/io/job/job.c b/src/io/job/job.c index 2febbf9..6b334d0 100644 --- a/src/io/job/job.c +++ b/src/io/job/job.c @@ -7,8 +7,10 @@ /* this file contains a skeleton implementation of the job interface */ #include +#ifndef WIN32 #include #include +#endif #include #include #include @@ -5385,10 +5387,14 @@ static void do_one_work_cycle_all(int idle_time_ms) * don't have a single thing to do. Sleep here to prevent busy * spins. */ +#ifdef WIN32 + Sleep(idle_time_ms); +#else struct timespec ts; ts.tv_sec = idle_time_ms/1000; ts.tv_nsec = (idle_time_ms%1000)*1000*1000; nanosleep(&ts, NULL); +#endif } gen_mutex_unlock(&work_cycle_mutex); @@ -6368,7 +6374,6 @@ static struct fs_pool* find_fs(PVFS_fs_id fsid) return(NULL); } - #endif /* __PVFS2_TROVE_SUPPORT__ */ /* diff --git a/src/io/job/job.h b/src/io/job/job.h index 5ea97ad..5b8ac9e 100644 --- a/src/io/job/job.h +++ b/src/io/job/job.h @@ -9,7 +9,11 @@ #ifndef __JOB_H #define __JOB_H +#ifdef WIN32 +#include "wincommon.h" +#else #include +#endif #include "src/io/flow/flow.h" #include "bmi.h" diff --git a/src/io/trove/pvfs2-storage.h b/src/io/trove/pvfs2-storage.h index 687af97..3eb163c 100644 --- a/src/io/trove/pvfs2-storage.h +++ b/src/io/trove/pvfs2-storage.h @@ -23,6 +23,9 @@ typedef enum PVFS_coll_getinfo_options_e PVFS_coll_getinfo_options; struct PVFS_vtag_s { /* undefined */ +#ifdef WIN32 + int field; +#endif }; typedef struct PVFS_vtag_s PVFS_vtag; /* key/value descriptor definition moved to include/pvfs2-types.h */ @@ -80,6 +83,7 @@ struct PVFS_ds_attributes_s PVFS_uid uid; PVFS_gid gid; PVFS_permissions mode; + PVFS_handle cid; int32_t __pad1; PVFS_time ctime; @@ -111,6 +115,7 @@ do { \ (__oa)->mtime = (__dsa)->mtime; \ (__oa)->atime = (__dsa)->atime; \ (__oa)->objtype = (__dsa)->type; \ + (__oa)->cid = (__dsa)->cid; \ (__oa)->u.meta.dfile_count = (__dsa)->u.metafile.dfile_count; \ (__oa)->u.meta.dist_size = (__dsa)->u.metafile.dist_size; \ } while(0) @@ -124,6 +129,7 @@ do { \ (__dsa)->mtime = (__oa)->mtime; \ (__dsa)->atime = (__oa)->atime; \ (__dsa)->type = (__oa)->objtype; \ + (__dsa)->cid = (__oa)->cid; \ (__dsa)->u.metafile.dfile_count = (__oa)->u.meta.dfile_count; \ (__dsa)->u.metafile.dist_size = (__oa)->u.meta.dist_size; \ } while(0) @@ -136,6 +142,8 @@ do { \ (dest)->group = (src)->group; \ if ((src)->mask & PVFS_ATTR_COMMON_PERM) \ (dest)->perms = (src)->perms; \ + if ((src)->mask & PVFS_ATTR_COMMON_CID) \ + (dest)->cid = (src)->cid; \ if ((src)->mask & PVFS_ATTR_COMMON_ATIME) \ { \ if ((src)->mask & PVFS_ATTR_COMMON_ATIME_SET) \ diff --git a/src/io/trove/trove-dbpf/dbpf-bstream-direct.c b/src/io/trove/trove-dbpf/dbpf-bstream-direct.c index f90646c..08026f7 100644 --- a/src/io/trove/trove-dbpf/dbpf-bstream-direct.c +++ b/src/io/trove/trove-dbpf/dbpf-bstream-direct.c @@ -34,6 +34,7 @@ #include "pint-op.h" static gen_mutex_t dbpf_update_size_lock = GEN_MUTEX_INITIALIZER; +static gen_mutex_t grow_bstream_table_lock = GEN_MUTEX_INITIALIZER; typedef struct { @@ -42,6 +43,17 @@ typedef struct TROVE_offset offset; } dbpf_stream_extents_t; +struct qhash_table *grow_bstream_table = NULL; + +struct grow_bstream_handle +{ + struct qlist_head hash_link; + gen_mutex_t handle_lock; + gen_mutex_t refcount_lock; + PVFS_handle handle; + int refcount; +}; + static int dbpf_bstream_get_extents( char **mem_offset_array, TROVE_size *mem_size_array, @@ -52,6 +64,18 @@ static int dbpf_bstream_get_extents( int *ext_count, dbpf_stream_extents_t *extents); +static int hash_handle_compare( + void *key, + struct qlist_head *link); + +static int hash_handle( + void *handle, + int table_size); + +static int grow_bstream_handle_table_init( int size ); +static int grow_bstream_handle_acquire_lock( TROVE_object_ref ref ); +static int grow_bstream_handle_release_lock( TROVE_object_ref ref ); + static size_t direct_aligned_write(int fd, void *buf, off_t buf_offset, @@ -166,7 +190,8 @@ int dbpf_aligned_blocks_finalize(void); * * @param write_offset - the offset into the bstream to start the write * - * @param stream_size - the actual size of the bstream (might be stored elsewhere) + * @param stream_size - the actual size of the bstream (might be stored + * elsewhere) * * @returns bytes written, otherwise a negative errno error code */ @@ -681,7 +706,8 @@ static int dbpf_bstream_direct_read_op_svc(void *ptr, PVFS_hint hint) ret = dbpf_dspace_attr_get(qop_p->op.coll_p, ref, &attr); if(ret != 0) { - gossip_err("%s: failed to get size in dspace attr: (error=%d)\n", __func__, ret); + gossip_err("%s: failed to get size in dspace attr: (error=%d)\n", + __func__, ret); goto done; } @@ -696,7 +722,8 @@ static int dbpf_bstream_direct_read_op_svc(void *ptr, PVFS_hint hint) NULL); if(ret != 0) { - gossip_err("%s: failed to get bstream extents from offset/sizes: (error=%d)\n", __func__, ret); + gossip_err("%s: failed to get bstream extents from offset/sizes: " + "(error=%d)\n", __func__, ret); goto done; } @@ -717,7 +744,8 @@ static int dbpf_bstream_direct_read_op_svc(void *ptr, PVFS_hint hint) stream_extents); if(ret != 0) { - gossip_err("%s: failed to get bstream extents from offset/sizes: (error=%d)\n", __func__, ret); + gossip_err("%s: failed to get bstream extents from offset/sizes: " + "(error=%d)\n", __func__, ret); goto done; } @@ -732,7 +760,8 @@ static int dbpf_bstream_direct_read_op_svc(void *ptr, PVFS_hint hint) if(ret < 0) { ret = -trove_errno_to_trove_error(-ret); - gossip_err("%s: direct_locked_read failed: (error=%d)\n", __func__, ret); + gossip_err("%s: direct_locked_read failed: (error=%d)\n", __func__, + ret); goto done; } } @@ -777,7 +806,8 @@ static int dbpf_bstream_direct_write_op_svc(void *ptr, PVFS_hint hint) NULL); if(ret != 0) { - gossip_err("%s: failed to count extents from stream offset/sizes: (error=%d)\n", __func__, ret); + gossip_err("%s: failed to count extents from stream offset/sizes: " + "(error=%d)\n", __func__, ret); goto cache_put; } @@ -799,18 +829,54 @@ static int dbpf_bstream_direct_write_op_svc(void *ptr, PVFS_hint hint) stream_extents); if(ret != 0) { - gossip_err("%s: failed to get stream extents from stream offset/sizes: (error=%d)\n", __func__, ret); + gossip_err("%s: failed to get stream extents from stream offset/sizes: " + "(error=%d)\n", __func__, ret); goto cache_put; } + if( grow_bstream_table == NULL ) + { + ret = grow_bstream_handle_table_init( 1021 ); + if( ret != 0 ) + { + gossip_err("%s: failed to create grow_bstream_handle_table\n", + __func__); + goto cache_put; + } + } + + /* acquire a lock on this handle prior to getting the size to prevent + * a race condition between multiple writes getting the wrong size */ + grow_bstream_handle_acquire_lock( ref ); + ret = dbpf_dspace_attr_get(qop_p->op.coll_p, ref, &attr); if(ret != 0) { - gossip_err("%s: failed to get dspace attr for bstream: (error=%d)\n", __func__, ret); + gossip_err("%s: failed to get dspace attr for bstream: (error=%d)\n", + __func__, ret); + grow_bstream_handle_release_lock( ref ); goto cache_put; } + /* prior to writes see if we are growing the file, if not, release the + * lock for growing file size since we won't be updating the file size + * below */ + for(i = 0; i < extent_count; ++ i) + { + if(eor < stream_extents[i].offset + stream_extents[i].size) + { + eor = stream_extents[i].offset + stream_extents[i].size; + } + } + if(eor <= attr.u.datafile.b_size) + { + /* file size is not growing so we do not need to hold the lock + * since we won't update the size attribute below */ + grow_bstream_handle_release_lock( ref ); + } + *rw_op->out_size_p = 0; + for(i = 0; i < extent_count; ++ i) { ret = direct_locked_write(rw_op->open_ref.fd, @@ -821,15 +887,20 @@ static int dbpf_bstream_direct_write_op_svc(void *ptr, PVFS_hint hint) attr.u.datafile.b_size); if(ret < 0) { - gossip_err("%s: failed to perform direct locked write: (error=%d)\n", __func__, ret); + gossip_err("%s: failed to perform direct locked write: " + "(error=%d)\n", __func__, ret); + if(eor > attr.u.datafile.b_size) + { + grow_bstream_handle_release_lock( ref ); + } goto cache_put; } - - if(eor < stream_extents[i].offset + stream_extents[i].size) - { - eor = stream_extents[i].offset + stream_extents[i].size; - } - + /* did this calculation above + * if(eor < stream_extents[i].offset + stream_extents[i].size) + * { + * eor = stream_extents[i].offset + stream_extents[i].size; + * } + */ *rw_op->out_size_p += ret; } @@ -841,8 +912,10 @@ static int dbpf_bstream_direct_write_op_svc(void *ptr, PVFS_hint hint) ret = dbpf_dspace_attr_get(qop_p->op.coll_p, ref, &attr); if(ret != 0) { - gossip_err("%s: failed to get size from dspace attr: (error=%d)\n", __func__, ret); + gossip_err("%s: failed to get size from dspace attr: (error=%d)\n", + __func__, ret); gen_mutex_unlock(&dbpf_update_size_lock); + grow_bstream_handle_release_lock( ref ); goto cache_put; } @@ -853,8 +926,10 @@ static int dbpf_bstream_direct_write_op_svc(void *ptr, PVFS_hint hint) ret = dbpf_dspace_attr_set(qop_p->op.coll_p, ref, &attr); if(ret != 0) { - gossip_err("%s: failed to update size in dspace attr: (error=%d)\n", __func__, ret); + gossip_err("%s: failed to update size in dspace attr: " + "(error=%d)\n", __func__, ret); gen_mutex_unlock(&dbpf_update_size_lock); + grow_bstream_handle_release_lock( ref ); goto cache_put; } sync_required = 1; @@ -885,16 +960,41 @@ static int dbpf_bstream_direct_write_op_svc(void *ptr, PVFS_hint hint) ret = dbpf_sync_coalesce(qop_p, 0, &outcount); if(ret < 0) { - gossip_err("%s: failed to coalesce size update in dspace attr: (error=%d)\n", __func__, ret); + gossip_err("%s: failed to coalesce size update in dspace " + "attr: (error=%d)\n", __func__, ret); + grow_bstream_handle_release_lock( ref ); goto done; } + ret = grow_bstream_handle_release_lock( ref ); + if( ret != 0 ) + { + gossip_debug(GOSSIP_DIRECTIO_DEBUG, "%s: failed to release " + "grow_bstream_handle lock when not updating " + "file size\n", __func__ ); + } + ret = PINT_MGMT_OP_CONTINUE; goto done; } + else + { + /* still need to release the lock even thought we didn't update + * the size because the size calc prior to doing the writes told + * use we would */ + ret = grow_bstream_handle_release_lock( ref ); + if( ret != 0 ) + { + gossip_debug(GOSSIP_DIRECTIO_DEBUG, "%s: failed to release " + "grow_bstream_handle lock when not updating " + "file size\n", __func__ ); + } + } } + /* if we don't try to update the size then we already released the + * handle grow lock above */ - ret = PINT_MGMT_OP_COMPLETED; + ret = PINT_MGMT_OP_COMPLETED; cache_put: dbpf_open_cache_put(&rw_op->open_ref); @@ -916,7 +1016,7 @@ static int dbpf_bstream_direct_read_at(TROVE_coll_id coll_id, void *user_ptr, TROVE_context_id context_id, TROVE_op_id *out_op_id_p, - PVFS_hint hints) + PVFS_hint hints) { return -TROVE_ENOSYS; } @@ -931,7 +1031,7 @@ static int dbpf_bstream_direct_write_at(TROVE_coll_id coll_id, void *user_ptr, TROVE_context_id context_id, TROVE_op_id *out_op_id_p, - PVFS_hint hints) + PVFS_hint hints) { return -TROVE_ENOSYS; } @@ -961,7 +1061,8 @@ static int dbpf_bstream_direct_read_list(TROVE_coll_id coll_id, coll_p = dbpf_collection_find_registered(coll_id); if (coll_p == NULL) { - gossip_err("%s: failed to find collection with fsid %d\n", __func__, coll_id); + gossip_err("%s: failed to find collection with fsid %d\n", + __func__, coll_id); return -TROVE_EINVAL; } @@ -1018,7 +1119,8 @@ static int dbpf_bstream_direct_read_list(TROVE_coll_id coll_id, dbpf_bstream_direct_read_op_svc, op, NULL, io_queue_id); if(ret < 0) { - gossip_err("%s: failed to post direct read op: (error=%d)\n", __func__, ret); + gossip_err("%s: failed to post direct read op: (error=%d)\n", + __func__, ret); return ret; } @@ -1092,7 +1194,8 @@ static int dbpf_bstream_direct_write_list(TROVE_coll_id coll_id, *out_op_id_p = q_op_p->op.id; - gossip_debug(GOSSIP_DIRECTIO_DEBUG, "%s: queuing direct write operation\n", __func__); + gossip_debug(GOSSIP_DIRECTIO_DEBUG, "%s: queuing direct write operation\n", + __func__); PINT_manager_id_post( io_thread_mgr, q_op_p, &q_op_p->mgr_op_id, dbpf_bstream_direct_write_op_svc, op, NULL, io_queue_id); @@ -1387,6 +1490,179 @@ static int dbpf_bstream_get_extents( return 0; } +/* grow_bstream_handle_table_init() + * + * initialize the grow_bstream_table + * + * size: prime number of hash table size + */ +static int grow_bstream_handle_table_init( int size ) +{ + gen_mutex_lock( &grow_bstream_table_lock ); + if( grow_bstream_table == NULL ) + { + grow_bstream_table = qhash_init(hash_handle_compare, hash_handle, size); + if( grow_bstream_table == NULL ) + { + return -PVFS_ENOMEM; + } + } + gen_mutex_unlock( &grow_bstream_table_lock ); + return 0; +} + +/* obtains a per-handle lock by locking an existing entry in the + * grow_bstream_table or creating an entry and grabbing the lock. + * + * returns 0 on success and the handle lock held or an error + */ +static int grow_bstream_handle_acquire_lock( TROVE_object_ref ref ) +{ + struct qlist_head *hash_link = NULL; + struct grow_bstream_handle *grow_handle = NULL; + + gen_mutex_lock( &grow_bstream_table_lock ); + if( grow_bstream_table == NULL ) + { + gen_mutex_unlock( &grow_bstream_table_lock ); + return -PVFS_EINVAL; + } + + hash_link = qhash_search(grow_bstream_table, &(ref.handle) ); + if( hash_link ) + { + grow_handle = qlist_entry( hash_link, struct grow_bstream_handle, + hash_link); + } + else + { + grow_handle = calloc( 1, sizeof( struct grow_bstream_handle )); + if( grow_handle == NULL ) + { + gen_mutex_unlock( &grow_bstream_table_lock ); + gossip_err( "%s: failed to alloc memory\n", __func__); + return -PVFS_ENOMEM; + } + grow_handle->handle = ref.handle; + gen_mutex_init( &(grow_handle->handle_lock) ); + gen_mutex_init( &(grow_handle->refcount_lock) ); + + /* we're safe adding it and waiting on grabbing the lock because + * we still have the lock on the table so no one else + * should access this new member */ + qhash_add( grow_bstream_table, &(grow_handle->handle), + &(grow_handle->hash_link) ); + } + + /* increment the number of things using the hash member */ + gen_mutex_lock( &(grow_handle->refcount_lock) ); + grow_handle->refcount++; + gen_mutex_unlock( &(grow_handle->refcount_lock) ); + + gen_mutex_unlock( &grow_bstream_table_lock ); + + gen_mutex_lock( &(grow_handle->handle_lock)); + + return 0; +} + +static int grow_bstream_handle_release_lock( TROVE_object_ref ref ) +{ + struct qlist_head *hash_link = NULL; + struct grow_bstream_handle *grow_handle = NULL; + int rcount = 0; + + gen_mutex_lock( &grow_bstream_table_lock ); + if( grow_bstream_table == NULL ) + { + gen_mutex_unlock( &grow_bstream_table_lock ); + return -PVFS_EINVAL; + } + + hash_link = qhash_search(grow_bstream_table, &(ref.handle) ); + if( hash_link ) + { + grow_handle = qlist_entry(hash_link, struct grow_bstream_handle, + hash_link); + + gen_mutex_lock( &(grow_handle->refcount_lock) ); + rcount = --grow_handle->refcount; + gen_mutex_unlock( &(grow_handle->refcount_lock) ); + + /* if we're the last reference remove it from the hash and free the + * memory. may want to optimize this so we aren't continuously + * alloc/free for each read */ + if( rcount == 0 ) + { + gen_mutex_unlock( &(grow_handle->handle_lock)); + qhash_del(hash_link); + gen_mutex_destroy( &(grow_handle->handle_lock) ); + gen_mutex_destroy( &(grow_handle->refcount_lock) ); + free( grow_handle ); + } + else + { + gen_mutex_unlock( &(grow_handle->handle_lock)); + } + } + else + { + /* should have an entry, but if not just report it for debugging */ + gossip_debug(GOSSIP_DIRECTIO_DEBUG, "%s: no grow_handle entry when " + "trying to remove with refcount %d\n", __func__, rcount); + } + gen_mutex_unlock( &grow_bstream_table_lock ); + return 0; +} + +/* hash_handle() + * + * hash function for handles added to table + * taken from src/server/request-scheduler/request-scheduler.c + * + * returns integer offset into table + */ +static int hash_handle( + void *handle, + int table_size) +{ + /* TODO: update this later with a better hash function, + * depending on what handles look like, for now just modding + * + */ + unsigned long tmp = 0; + PVFS_handle *real_handle = handle; + + tmp += (*(real_handle)); + tmp = tmp % table_size; + + return ((int) tmp); +} + +/* hash_handle_compare() + * + * performs a comparison of a hash table entro to a given key + * (used for searching) + * taken from src/server/request-scheduler/request-scheduler.c + * + * returns 1 if match found, 0 otherwise + */ +static int hash_handle_compare( + void *key, + struct qlist_head *link) +{ + struct grow_bstream_handle *my_handle; + PVFS_handle *real_handle = key; + + my_handle = qlist_entry(link, struct grow_bstream_handle, hash_link); + if (my_handle->handle == *real_handle) + { + return (1); + } + + return (0); +} + #if 0 int dbpf_aligned_blocks_init(void) { @@ -1432,7 +1708,8 @@ void *dbpf_aligned_block_get(void) return NULL; } - ablock = qlist_entry(aligned_blocks_unused.next, struct aligned_block, link); + ablock = qlist_entry(aligned_blocks_unused.next, struct aligned_block, + link); qlist_del(&ablock->link); ptr = ablock->ptr; ablock->ptr = NULL; diff --git a/src/io/trove/trove-dbpf/dbpf-dspace.c b/src/io/trove/trove-dbpf/dbpf-dspace.c index 16d6390..d88f365 100644 --- a/src/io/trove/trove-dbpf/dbpf-dspace.c +++ b/src/io/trove/trove-dbpf/dbpf-dspace.c @@ -178,15 +178,16 @@ static int dbpf_dspace_create(TROVE_coll_id coll_id, memcpy(op_p->u.d_create.extent_array.extent_array, extent_array->extent_array, extent_array->extent_count * sizeof(TROVE_extent)); - op_p->u.d_create.out_handle_p = handle_p; op_p->u.d_create.type = type; PINT_perf_count(PINT_server_pc, PINT_PERF_METADATA_DSPACE_OPS, 1, PINT_PERF_ADD); - return dbpf_queue_or_service(op_p, q_op_p, coll_p, out_op_id_p, + ret = dbpf_queue_or_service(op_p, q_op_p, coll_p, out_op_id_p, event_type, event_id); + + return ret; } static int dbpf_dspace_create_op_svc(struct dbpf_op *op_p) @@ -236,7 +237,7 @@ static int dbpf_dspace_create_op_svc(struct dbpf_op *op_p) new_handle = trove_handle_alloc_from_range( op_p->coll_p->coll_id, &op_p->u.d_create.extent_array); } - + gossip_debug(GOSSIP_TROVE_DEBUG, "[%d extents] -- new_handle is %llu " "(cur_extent is %llu - %llu)\n", op_p->u.d_create.extent_array.extent_count, @@ -355,8 +356,9 @@ static int dbpf_dspace_create_list(TROVE_coll_id coll_id, PINT_perf_count(PINT_server_pc, PINT_PERF_METADATA_DSPACE_OPS, 1, PINT_PERF_ADD); - return dbpf_queue_or_service(op_p, q_op_p, coll_p, out_op_id_p, + ret = dbpf_queue_or_service(op_p, q_op_p, coll_p, out_op_id_p, event_type, event_id); + return ret; } static int dbpf_dspace_create_list_op_svc(struct dbpf_op *op_p) @@ -708,6 +710,7 @@ static int dbpf_dspace_iterate_handles_op_svc(struct dbpf_op *op_p) DBT key, data; void * multiples_buffer = NULL; TROVE_handle dummy_handle; + TROVE_handle aligned_handle; size_t sizeof_handle = 0, sizeof_attr = 0; int start_size; void *tmp_ptr; @@ -874,6 +877,7 @@ static int dbpf_dspace_iterate_handles_op_svc(struct dbpf_op *op_p) * pointer value of tmp_buffer actually changes, and it * must be derefenced to get the handle value. */ + DB_MULTIPLE_KEY_NEXT(tmp_ptr, &data, tmp_handle, sizeof_handle, tmp_attr, sizeof_attr); @@ -892,8 +896,17 @@ static int dbpf_dspace_iterate_handles_op_svc(struct dbpf_op *op_p) continue; } - op_p->u.d_iterate_handles.handle_array[i] = - *(TROVE_handle *)tmp_handle; + /* check for duplicates */ + memcpy(&aligned_handle, tmp_handle, sizeof(TROVE_handle)); + if(i > 0 && aligned_handle == op_p->u.d_iterate_handles.handle_array[i-1]) + { + gossip_err("Warning: got duplicate handle %llu.\n", llu(aligned_handle)); + gossip_err("Warning: skipping entry.\n"); + i--; + continue; + } + + op_p->u.d_iterate_handles.handle_array[i] = aligned_handle; } } @@ -923,10 +936,19 @@ static int dbpf_dspace_iterate_handles_op_svc(struct dbpf_op *op_p) { goto get_next; } + + memcpy(&aligned_handle, tmp_handle, sizeof(TROVE_handle)); + if(aligned_handle == op_p->u.d_iterate_handles.handle_array[*op_p->u.d_iterate_handles.count_p]) + { + gossip_err("Warning: found duplicate handle: %llu\n", llu(aligned_handle)); + gossip_err("Warning: skipping entry.\n"); + } + } while (sizeof_handle != sizeof(TROVE_handle) || - sizeof_attr != sizeof(attr)); + sizeof_attr != sizeof(attr) || + aligned_handle == op_p->u.d_iterate_handles.handle_array[*op_p->u.d_iterate_handles.count_p]); - *op_p->u.d_iterate_handles.position_p = *(TROVE_handle *)tmp_handle; + *op_p->u.d_iterate_handles.position_p = aligned_handle; goto return_ok; } @@ -956,6 +978,13 @@ static int dbpf_dspace_iterate_handles_op_svc(struct dbpf_op *op_p) "failure @ recno\n"); ret = -dbpf_db_error_to_trove_error(ret); } + if(*op_p->u.d_iterate_handles.count_p > 0 && + dummy_handle == op_p->u.d_iterate_handles.handle_array[*op_p->u.d_iterate_handles.count_p]) + { + gossip_err("Warning: found duplicate handle: %llu\n", llu(dummy_handle)); + gossip_err("Warning: skipping entry.\n"); + (*op_p->u.d_iterate_handles.count_p)--; + } *op_p->u.d_iterate_handles.position_p = dummy_handle; return_ok: @@ -2044,35 +2073,35 @@ static int dbpf_dspace_testsome( int PINT_trove_dbpf_ds_attr_compare_reversed( DB * dbp, const DBT * a, const DBT * b) { - const TROVE_handle * handle_a; - const TROVE_handle * handle_b; + TROVE_handle handle_a = 0; + TROVE_handle handle_b = 0; - handle_a = (const TROVE_handle *) a->data; - handle_b = (const TROVE_handle *) b->data; + memcpy(&handle_a, a->data, sizeof(TROVE_handle)); + memcpy(&handle_b, b->data, sizeof(TROVE_handle)); - if(*handle_a == *handle_b) + if(handle_a == handle_b) { return 0; } - return (*handle_a < *handle_b) ? -1 : 1; + return (handle_a < handle_b) ? -1 : 1; } int PINT_trove_dbpf_ds_attr_compare( DB * dbp, const DBT * a, const DBT * b) { - const TROVE_handle * handle_a; - const TROVE_handle * handle_b; + TROVE_handle handle_a = 0; + TROVE_handle handle_b = 0; - handle_a = (const TROVE_handle *) a->data; - handle_b = (const TROVE_handle *) b->data; + memcpy(&handle_a, a->data, sizeof(TROVE_handle)); + memcpy(&handle_b, b->data, sizeof(TROVE_handle)); - if(*handle_a == *handle_b) + if(handle_a == handle_b) { return 0; } - return (*handle_a > *handle_b) ? -1 : 1; + return (handle_a > handle_b) ? -1 : 1; } /* dbpf_dspace_create_store_handle() diff --git a/src/io/trove/trove-dbpf/dbpf-keyval.c b/src/io/trove/trove-dbpf/dbpf-keyval.c index 343ece5..6f1b4cb 100644 --- a/src/io/trove/trove-dbpf/dbpf-keyval.c +++ b/src/io/trove/trove-dbpf/dbpf-keyval.c @@ -2114,15 +2114,15 @@ static int dbpf_keyval_handle_info_ops(struct dbpf_op * op_p, int PINT_trove_dbpf_keyval_compare( DB * dbp, const DBT * a, const DBT * b) { - const struct dbpf_keyval_db_entry * db_entry_a; - const struct dbpf_keyval_db_entry * db_entry_b; + struct dbpf_keyval_db_entry db_entry_a; + struct dbpf_keyval_db_entry db_entry_b; - db_entry_a = (const struct dbpf_keyval_db_entry *) a->data; - db_entry_b = (const struct dbpf_keyval_db_entry *) b->data; + memcpy(&db_entry_a, a->data, sizeof(struct dbpf_keyval_db_entry)); + memcpy(&db_entry_b, b->data, sizeof(struct dbpf_keyval_db_entry)); - if(db_entry_a->handle != db_entry_b->handle) + if(db_entry_a.handle != db_entry_b.handle) { - return (db_entry_a->handle < db_entry_b->handle) ? -1 : 1; + return (db_entry_a.handle < db_entry_b.handle) ? -1 : 1; } if(a->size > b->size) @@ -2136,7 +2136,7 @@ int PINT_trove_dbpf_keyval_compare( } /* must be equal */ - return (memcmp(db_entry_a->key, db_entry_b->key, + return (memcmp(db_entry_a.key, db_entry_b.key, DBPF_KEYVAL_DB_ENTRY_KEY_SIZE(a->size))); } diff --git a/src/io/trove/trove-dbpf/dbpf-mgmt.c b/src/io/trove/trove-dbpf/dbpf-mgmt.c index 0513f04..98853b9 100644 --- a/src/io/trove/trove-dbpf/dbpf-mgmt.c +++ b/src/io/trove/trove-dbpf/dbpf-mgmt.c @@ -139,7 +139,7 @@ DB_ENV *dbpf_getdb_env(const char *path, unsigned int env_flags, int *error) retry: ret = db_env_create(&dbenv, 0); - if (ret != 0) + if (ret != 0 || dbenv == NULL) { gossip_err("dbpf_getdb_env: %s\n", db_strerror(ret)); *error = ret; @@ -864,34 +864,49 @@ int dbpf_finalize(void) if (my_storage_p) { - ret = my_storage_p->sto_attr_db->sync(my_storage_p->sto_attr_db, 0); - if (ret) + if( my_storage_p->sto_attr_db ) { - gossip_err("dbpf_finalize: %s\n", db_strerror(ret)); - return -dbpf_db_error_to_trove_error(ret); - } + ret = my_storage_p->sto_attr_db->sync(my_storage_p->sto_attr_db, 0); + if (ret) + { + gossip_err("dbpf_finalize attr sync: %s\n", db_strerror(ret)); + return -dbpf_db_error_to_trove_error(ret); + } - ret = db_close(my_storage_p->sto_attr_db); - if (ret) - { - gossip_err("dbpf_finalize: %s\n", db_strerror(ret)); - return -dbpf_db_error_to_trove_error(ret); + ret = db_close(my_storage_p->sto_attr_db); + if (ret) + { + gossip_err("dbpf_finalize attr close: %s\n", db_strerror(ret)); + return -dbpf_db_error_to_trove_error(ret); + } } - - ret = my_storage_p->coll_db->sync(my_storage_p->coll_db, 0); - if (ret) + else { - gossip_err("dbpf_finalize: %s\n", db_strerror(ret)); - return -dbpf_db_error_to_trove_error(ret); + gossip_err("dbpf_finalize: attribute database not defined\n"); } - ret = db_close(my_storage_p->coll_db); - if (ret) + if( my_storage_p->coll_db ) { - gossip_err("dbpf_finalize: %s\n", db_strerror(ret)); - return -dbpf_db_error_to_trove_error(ret); + ret = my_storage_p->coll_db->sync(my_storage_p->coll_db, 0); + if (ret) + { + gossip_err("dbpf_finalize collection sync: %s\n", + db_strerror(ret)); + return -dbpf_db_error_to_trove_error(ret); + } + + ret = db_close(my_storage_p->coll_db); + if (ret) + { + gossip_err("dbpf_finalize collection close: %s\n", + db_strerror(ret)); + return -dbpf_db_error_to_trove_error(ret); + } } - + else + { + gossip_err("dbpf_finalize: collections database not defined\n"); + } free(my_storage_p->data_path); free(my_storage_p->meta_path); free(my_storage_p); @@ -1312,7 +1327,7 @@ int dbpf_collection_remove(char *collname, ret = sto_p->coll_db->get(sto_p->coll_db, NULL, &key, &data, 0); if (ret != 0) { - sto_p->coll_db->err(sto_p->coll_db, ret, "DB->get"); + sto_p->coll_db->err(sto_p->coll_db, ret, "DB->get collection"); return -dbpf_db_error_to_trove_error(ret); } @@ -1528,7 +1543,7 @@ int dbpf_collection_iterate(TROVE_ds_position *inout_position_p, memset(&key, 0, sizeof(key)); key.data = name_array[0].buffer; key.ulen = name_array[0].buffer_sz; - *(db_recno_t *)key.data = *(db_recno_t *)inout_position_p; + *(db_recno_t *)key.data = (db_recno_t) *inout_position_p; key.size = sizeof(db_recno_t); key.flags |= DB_DBT_USERMEM; @@ -1659,37 +1674,52 @@ int dbpf_collection_clear(TROVE_coll_id coll_id) dbpf_collection_deregister(coll_p); - if ((ret = coll_p->coll_attr_db->sync(coll_p->coll_attr_db, 0)) != 0) + if( coll_p == NULL ) + { + gossip_err("Trove collection not defined.\n"); + return 0; + } + + if ( (coll_p->coll_attr_db != NULL ) && + (ret = coll_p->coll_attr_db->sync(coll_p->coll_attr_db, 0)) != 0) { gossip_err("db_sync(coll_attr_db): %s\n", db_strerror(ret)); } - if ((ret = db_close(coll_p->coll_attr_db)) != 0) + if ( (coll_p->coll_attr_db != NULL ) && + (ret = db_close(coll_p->coll_attr_db)) != 0) { gossip_lerr("db_close(coll_attr_db): %s\n", db_strerror(ret)); } - if ((ret = coll_p->ds_db->sync(coll_p->ds_db, 0)) != 0) + if ( (coll_p->ds_db != NULL ) && + (ret = coll_p->ds_db->sync(coll_p->ds_db, 0)) != 0) { gossip_err("db_sync(coll_ds_db): %s\n", db_strerror(ret)); } - if ((ret = db_close(coll_p->ds_db)) != 0) + if ( (coll_p->ds_db != NULL ) && + (ret = db_close(coll_p->ds_db)) != 0) { gossip_lerr("db_close(coll_ds_db): %s\n", db_strerror(ret)); } - if ((ret = coll_p->keyval_db->sync(coll_p->keyval_db, 0)) != 0) + if ( (coll_p->keyval_db != NULL ) && + (ret = coll_p->keyval_db->sync(coll_p->keyval_db, 0)) != 0) { gossip_err("db_sync(coll_keyval_db): %s\n", db_strerror(ret)); } - if ((ret = db_close(coll_p->keyval_db)) != 0) + if ( (coll_p->keyval_db != NULL ) && + (ret = db_close(coll_p->keyval_db)) != 0) { gossip_lerr("db_close(coll_keyval_db): %s\n", db_strerror(ret)); } - dbpf_putdb_env(coll_p->coll_env, coll_p->meta_path); + if( coll_p->coll_env != NULL ) + { + dbpf_putdb_env(coll_p->coll_env, coll_p->meta_path); + } free(coll_p->name); free(coll_p->data_path); free(coll_p->meta_path); @@ -1762,7 +1792,7 @@ int dbpf_collection_lookup(char *collname, } else if (ret != 0) { - sto_p->coll_db->err(sto_p->coll_db, ret, "DB->get"); + sto_p->coll_db->err(sto_p->coll_db, ret, "DB->get collection"); gossip_debug(GOSSIP_TROVE_DEBUG, "lookup got error (%d)\n", ret); return -dbpf_db_error_to_trove_error(ret); } @@ -2096,6 +2126,8 @@ struct dbpf_storage *dbpf_storage_lookup( free(sto_p->meta_path); free(sto_p->data_path); free(sto_p); + gossip_err("Failure opening attribute database\n"); + my_storage_p = NULL; return NULL; } @@ -2108,8 +2140,10 @@ struct dbpf_storage *dbpf_storage_lookup( { db_close(sto_p->sto_attr_db); free(sto_p->meta_path); - free(sto_p->data_path); + free(sto_p->data_path); free(sto_p); + gossip_err("Failure opening collection database\n"); + my_storage_p = NULL; return NULL; } diff --git a/src/io/trove/trove-dbpf/dbpf-op-queue.c b/src/io/trove/trove-dbpf/dbpf-op-queue.c index cbbb878..bd1ffb7 100644 --- a/src/io/trove/trove-dbpf/dbpf-op-queue.c +++ b/src/io/trove/trove-dbpf/dbpf-op-queue.c @@ -287,6 +287,7 @@ int dbpf_op_init_queued_or_immediate( flags, context_id, 0); + *op_pp = op_p; } else diff --git a/src/io/trove/trove-dbpf/dbpf-thread.c b/src/io/trove/trove-dbpf/dbpf-thread.c index ef84015..fee6cc5 100644 --- a/src/io/trove/trove-dbpf/dbpf-thread.c +++ b/src/io/trove/trove-dbpf/dbpf-thread.c @@ -138,6 +138,12 @@ void *dbpf_thread_function(void *ptr) ret = pthread_cond_timedwait(&dbpf_op_incoming_cond, &dbpf_op_queue_mutex, &wait_time); + if( ret == EINVAL || ret == EPERM ) + { + /* an error other than timeout occured */ + gossip_debug(GOSSIP_TROVE_DEBUG, "%s: pthread_cond_timedwait " + "returned an error\n", __func__); + } gen_mutex_unlock(&dbpf_op_queue_mutex); } } diff --git a/src/io/trove/trove-handle-mgmt/trove-extentlist.c b/src/io/trove/trove-handle-mgmt/trove-extentlist.c index 20653f6..cb9f9e2 100644 --- a/src/io/trove/trove-handle-mgmt/trove-extentlist.c +++ b/src/io/trove/trove-handle-mgmt/trove-extentlist.c @@ -347,7 +347,7 @@ TROVE_handle extentlist_get_from_extent( TROVE_extent *extent) { TROVE_handle handle = TROVE_HANDLE_NULL; - + handle = avltree_extent_search_in_range(elist->index, extent); if (handle == TROVE_HANDLE_NULL) { @@ -670,7 +670,7 @@ static TROVE_handle avltree_extent_search_in_range( { right = (struct TROVE_handle_extent *)n->right->d; } - + /* request matches at one edge or the other of an existing extent */ if ((req_extent->first == e->first) || (req_extent->first == e->last)) diff --git a/src/io/trove/trove-handle-mgmt/trove-handle-mgmt.c b/src/io/trove/trove-handle-mgmt/trove-handle-mgmt.c index f33d7e5..4197341 100644 --- a/src/io/trove/trove-handle-mgmt/trove-handle-mgmt.c +++ b/src/io/trove/trove-handle-mgmt/trove-handle-mgmt.c @@ -34,6 +34,7 @@ typedef struct } handle_ledger_t; static struct qhash_table *s_fsid_to_ledger_table = NULL; +static struct qhash_table *s_fsid_to_osd_ledger_table = NULL; /* these are based on code from src/server/request-scheduler.c */ static int hash_fsid(void *fsid, int table_size); @@ -57,6 +58,7 @@ static int trove_check_handle_ranges(TROVE_coll_id coll_id, PINT_llist *extent_list, struct handle_ledger *ledger) { + gossip_err("trove_check_handle_ranges\n"); int ret = -1, i = 0, count = 0, op_count = 0; TROVE_op_id op_id = 0; TROVE_ds_state state = 0; @@ -126,10 +128,9 @@ static int trove_check_handle_ranges(TROVE_coll_id coll_id, ret = trove_handle_remove(ledger, handles[i]); if (ret != 0) { - gossip_debug( - GOSSIP_TROVE_DEBUG, "could not remove " - "handle %llu\n", llu(handles[i])); - break; + gossip_err( + "WARNING: could not remove " + "handle %llu from ledger; continuing.\n", llu(handles[i])); } } ret = ((i == count) ? 0 : -1); @@ -142,6 +143,7 @@ static int trove_check_handle_ranges(TROVE_coll_id coll_id, static int trove_map_handle_ranges( PINT_llist *extent_list, struct handle_ledger *ledger) { + gossip_err("trove_map_handle_ranges\n"); int ret = -1; PINT_llist *cur = NULL; PVFS_handle_extent *cur_extent = NULL; @@ -177,6 +179,7 @@ static int trove_map_handle_ranges( PINT_llist *extent_list, static handle_ledger_t *get_or_add_handle_ledger(TROVE_coll_id coll_id) { + gossip_err("get_or_add_handle_ledger\n"); handle_ledger_t *ledger = NULL; struct qlist_head *hash_link = NULL; @@ -219,6 +222,7 @@ static handle_ledger_t *get_or_add_handle_ledger(TROVE_coll_id coll_id) */ static int hash_fsid(void *fsid, int table_size) { + gossip_err("hash_fsid\n"); /* TODO: update this later with a better hash function, * depending on what fsids look like, for now just modding * @@ -241,6 +245,7 @@ static int hash_fsid(void *fsid, int table_size) */ static int hash_fsid_compare(void *key, struct qlist_head *link) { + gossip_err("hash_fsid_compare\n"); handle_ledger_t *ledger = NULL; TROVE_coll_id *real_fsid = (TROVE_coll_id *)key; @@ -256,6 +261,7 @@ static int hash_fsid_compare(void *key, struct qlist_head *link) int trove_handle_mgmt_initialize() { + gossip_err("trove_handle_mgmt_initialize\n"); /* due to weird trove_initialize usages; this will always succeed unless the hash table initialization really fails. @@ -269,6 +275,7 @@ int trove_handle_mgmt_initialize() hash_fsid,67); ret = (s_fsid_to_ledger_table ? 0 : -1); } + gen_mutex_unlock(&trove_handle_mutex); return ret; } @@ -277,10 +284,11 @@ int trove_set_handle_ranges(TROVE_coll_id coll_id, TROVE_context_id context_id, char *handle_range_str) { + gossip_err("trove_set_handle_ranges\n"); int ret = -TROVE_EINVAL; PINT_llist *extent_list = NULL; handle_ledger_t *ledger = NULL; - + gen_mutex_lock(&trove_handle_mutex); if (handle_range_str) { @@ -334,6 +342,7 @@ int trove_set_handle_timeout(TROVE_coll_id coll_id, TROVE_context_id context_id, struct timeval *timeout) { + gossip_err("trove_set_handle_timeout\n"); int ret = -1; handle_ledger_t *ledger = NULL; @@ -363,6 +372,7 @@ int trove_set_handle_timeout(TROVE_coll_id coll_id, TROVE_handle trove_handle_alloc(TROVE_coll_id coll_id) { + gossip_err("trove_handle_alloc\n"); handle_ledger_t *ledger = NULL; struct qlist_head *hash_link = NULL; TROVE_handle handle = TROVE_HANDLE_NULL; @@ -385,11 +395,12 @@ TROVE_handle trove_handle_alloc_from_range( TROVE_coll_id coll_id, TROVE_handle_extent_array *extent_array) { + gossip_err("trove_handle_alloc_from_range\n"); handle_ledger_t *ledger = NULL; struct qlist_head *hash_link = NULL; TROVE_handle handle = TROVE_HANDLE_NULL; int i = 0; - + gen_mutex_lock(&trove_handle_mutex); hash_link = qhash_search(s_fsid_to_ledger_table, &(coll_id)); if (hash_link) @@ -418,6 +429,7 @@ int trove_handle_peek( int max_num_handles, int *returned_handle_count) { + gossip_err("trove_handle_peek\n"); int ret = -TROVE_EINVAL; handle_ledger_t *ledger = NULL; struct qlist_head *hash_link = NULL; @@ -450,6 +462,7 @@ int trove_handle_peek_from_range( int max_num_handles, int *returned_handle_count) { + gossip_err("trove_handle_peek_from_range\n"); int ret = -TROVE_EINVAL, i = 0; handle_ledger_t *ledger = NULL; struct qlist_head *hash_link = NULL; @@ -490,6 +503,7 @@ int trove_handle_peek_from_range( int trove_handle_set_used(TROVE_coll_id coll_id, TROVE_handle handle) { + gossip_err("trove_handle_set_used\n"); int ret = -1; handle_ledger_t *ledger = NULL; struct qlist_head *hash_link = NULL; @@ -510,6 +524,7 @@ int trove_handle_set_used(TROVE_coll_id coll_id, TROVE_handle handle) int trove_handle_free(TROVE_coll_id coll_id, TROVE_handle handle) { + gossip_err("trove_handle_free\n"); int ret = -1; handle_ledger_t *ledger = NULL; struct qlist_head *hash_link = NULL; @@ -537,6 +552,7 @@ int trove_handle_free(TROVE_coll_id coll_id, TROVE_handle handle) */ int trove_handle_get_statistics(TROVE_coll_id coll_id, uint64_t* free_count) { + gossip_err("trove_handle_get_statistics\n"); handle_ledger_t *ledger = NULL; struct qlist_head *hash_link = NULL; @@ -567,6 +583,7 @@ int trove_handle_get_statistics(TROVE_coll_id coll_id, uint64_t* free_count) int trove_handle_mgmt_finalize() { + gossip_err("trove_handle_mgmt_finalize\n"); int i; handle_ledger_t *ledger = NULL; struct qlist_head *hash_link = NULL; diff --git a/src/io/trove/trove-mgmt.c b/src/io/trove/trove-mgmt.c index d510816..77653b4 100644 --- a/src/io/trove/trove-mgmt.c +++ b/src/io/trove/trove-mgmt.c @@ -88,7 +88,7 @@ static int trove_init_status = 0; int trove_initialize(TROVE_method_id method_id, TROVE_method_callback method_callback, char *data_path, - char *meta_path, + char *meta_path, TROVE_ds_flags flags) { int ret = -TROVE_EALREADY; @@ -104,7 +104,7 @@ int trove_initialize(TROVE_method_id method_id, { return ret; } - + if(!method_callback) { global_trove_method_callback = TROVE_default_method; diff --git a/src/kernel/linux-2.6/acl.c b/src/kernel/linux-2.6/acl.c index b612994..4011b1d 100644 --- a/src/kernel/linux-2.6/acl.c +++ b/src/kernel/linux-2.6/acl.c @@ -711,7 +711,11 @@ int pvfs2_acl_chmod(struct inode *inode) return error; } -static int pvfs2_check_acl(struct inode *inode, int mask) +static int pvfs2_check_acl(struct inode *inode, int mask +#ifdef HAVE_THREE_PARAM_ACL_CHECK + , unsigned int flags +#endif /* HAVE_THREE_PARAM_ACL_CHECK */ + ) { struct posix_acl *acl = NULL; @@ -742,8 +746,13 @@ static int pvfs2_check_acl(struct inode *inode, int mask) #ifdef HAVE_TWO_PARAM_PERMISSION int pvfs2_permission(struct inode *inode, int mask) #else -int pvfs2_permission(struct inode *inode, int mask, struct nameidata *nd) -#endif +int pvfs2_permission(struct inode *inode, int mask, +#ifdef HAVE_THREE_PARAM_PERMISSION_WITH_FLAG +unsigned int flags) +#else +struct nameidata *nd) +#endif /* HAVE_THREE_PARAM_PERMISSION_WITH_FLAG */ +#endif /* HAVE_TWO_PARAM_PERMISSION */ { #ifdef HAVE_CURRENT_FSUID int fsuid = current_fsuid(); @@ -754,7 +763,11 @@ int pvfs2_permission(struct inode *inode, int mask, struct nameidata *nd) #ifdef HAVE_GENERIC_PERMISSION int ret; - ret = generic_permission(inode, mask, pvfs2_check_acl); + ret = generic_permission(inode, mask, +#ifdef HAVE_FOUR_PARAM_GENERIC_PERMISSION + 0, +#endif /* HAVE_FOUR_PARAM_GENERIC_PERMISSION */ + pvfs2_check_acl); if (ret != 0) { gossip_debug(GOSSIP_ACL_DEBUG, "pvfs2_permission failed: inode: %llu mask = %o" diff --git a/src/kernel/linux-2.6/dcache.c b/src/kernel/linux-2.6/dcache.c index e299c59..c1966a5 100644 --- a/src/kernel/linux-2.6/dcache.c +++ b/src/kernel/linux-2.6/dcache.c @@ -151,7 +151,12 @@ static int pvfs2_d_revalidate_common(struct dentry* dentry) return 0; } -static int pvfs2_d_delete (struct dentry * dentry) +static int pvfs2_d_delete ( +#ifdef HAVE_D_DELETE_CONST +const +#endif /* HAVE_D_DELETE_CONST */ +struct dentry * dentry +) { gossip_debug(GOSSIP_DCACHE_DEBUG, "%s: called on dentry %p.\n", __func__, dentry); @@ -191,7 +196,7 @@ static int pvfs2_d_revalidate( { if (nd && (nd->flags & LOOKUP_FOLLOW) && - ((!nd->flags) & LOOKUP_CREATE)) + ((!nd->flags) & (LOOKUP_CREATE)) ) { gossip_debug(GOSSIP_DCACHE_DEBUG, "\n%s: Trusting intent; skipping getattr\n", __func__); @@ -207,8 +212,15 @@ static int pvfs2_d_revalidate( link_path_walk to pass our error up */ static int pvfs2_d_hash( +#ifdef HAVE_THREE_PARAM_D_HASH + const struct dentry *parent, + const struct inode *inode, + struct qstr *hash +#else struct dentry *parent, - struct qstr *hash) + struct qstr *hash +#endif /* HAVE_THREE_PARAM_D_HASH */ + ) { /* gossip_debug(GOSSIP_DCACHE_DEBUG, "pvfs2: pvfs2_d_hash called " */ /* "(name: %s | len: %d | hash: %d)\n", */ @@ -216,6 +228,32 @@ static int pvfs2_d_hash( return 0; } +#ifdef HAVE_SEVEN_PARAM_D_COMPARE +static int pvfs2_d_compare( + const struct dentry *parent, + const struct inode * pinode, + const struct dentry *dentry, + const struct inode *inode, + unsigned int len, + const char *str, + const struct qstr *name) +{ + int i = 0; + gossip_debug(GOSSIP_DCACHE_DEBUG, "pvfs2_d_compare: " + "called on parent %p\n (name1: %s| name2: %s)\n", + parent, str, name->name); + + if( len != name->len ) + return 1; + + for( i=0; i < len; i++ ) + { + if( str[i] != name->name[i] ) + return 1; + } + return 0; +} +#else static int pvfs2_d_compare( struct dentry *parent, struct qstr *d_name, @@ -229,6 +267,8 @@ static int pvfs2_d_compare( (d_name->hash == name->hash) && (memcmp(d_name->name, name->name, d_name->len) == 0)); } +#endif /* HAVE_SEVEN_PARAM_D_COMPARE */ + /** PVFS2 implementation of VFS dentry operations */ struct dentry_operations pvfs2_dentry_operations = @@ -246,6 +286,7 @@ struct dentry_operations pvfs2_dentry_operations = */ static void __attribute__ ((unused)) print_dentry(struct dentry *entry, int ret) { + unsigned int local_count = 0; if(!entry) { printk("--- dentry %p: no entry, ret: %d\n", entry, ret); @@ -264,9 +305,17 @@ static void __attribute__ ((unused)) print_dentry(struct dentry *entry, int ret) return; } +#ifdef HAVE_DENTRY_D_COUNT_ATOMIC + local_count = atomic_read(&entry->d_count); +#else + spin_lock(&entry->d_lock); + local_count = entry->d_count; + spin_unlock(&entry->d_lock); +#endif /* HAVE_DENTRY_D_COUNT_ATOMIC */ + printk("--- dentry %p: d_count: %d, name: %s, parent: %p, parent name: %s, ret: %d\n", entry, - atomic_read(&entry->d_count), + local_count, entry->d_name.name, entry->d_parent, entry->d_parent->d_name.name, diff --git a/src/kernel/linux-2.6/devpvfs2-req.c b/src/kernel/linux-2.6/devpvfs2-req.c index ab91d11..b21c552 100644 --- a/src/kernel/linux-2.6/devpvfs2-req.c +++ b/src/kernel/linux-2.6/devpvfs2-req.c @@ -129,6 +129,7 @@ static ssize_t pvfs2_devreq_read( */ else { cur_op = op; + spin_lock(&cur_op->lock); list_del(&cur_op->list); cur_op->op_linger_tmp--; /* if there is a trailer, re-add it to the request list */ @@ -142,6 +143,7 @@ static ssize_t pvfs2_devreq_read( /* readd it to the head of the list */ list_add(&cur_op->list, &pvfs2_request_list); } + spin_unlock(&cur_op->lock); break; } } @@ -712,6 +714,8 @@ static long dispatch_ioctl_command(unsigned int command, unsigned long arg) int ret; dev_mask_info_t mask_info = {0}; + /* mtmoore: add locking here */ + switch(command) { case PVFS_DEV_GET_MAGIC: @@ -818,8 +822,12 @@ static long dispatch_ioctl_command(unsigned int command, unsigned long arg) return -ENOIOCTLCMD; } +#ifdef HAVE_UNLOCKED_IOCTL_HANDLER +static long pvfs2_devreq_ioctl( +#else static int pvfs2_devreq_ioctl( struct inode *inode, +#endif /* HAVE_UNLOCKED_IOCTL_HANDLER */ struct file *file, unsigned int command, unsigned long arg) @@ -1146,7 +1154,12 @@ struct file_operations pvfs2_devreq_file_operations = #endif .open = pvfs2_devreq_open, .release = pvfs2_devreq_release, +#ifdef HAVE_UNLOCKED_IOCTL_HANDLER + .unlocked_ioctl = pvfs2_devreq_ioctl, +#else .ioctl = pvfs2_devreq_ioctl, +#endif /* HAVE_UNLOCKED_IOCTL_HANDLER */ + #ifdef CONFIG_COMPAT #ifdef HAVE_COMPAT_IOCTL_HANDLER .compat_ioctl = pvfs2_devreq_compat_ioctl, diff --git a/src/kernel/linux-2.6/file.c b/src/kernel/linux-2.6/file.c index 473d3ac..e3edcda 100644 --- a/src/kernel/linux-2.6/file.c +++ b/src/kernel/linux-2.6/file.c @@ -1540,7 +1540,6 @@ static ssize_t pvfs2_file_write( { struct rw_options rw; struct iovec vec; - int ret; memset(&rw, 0, sizeof(rw)); rw.async = 0; @@ -1559,8 +1558,7 @@ static ssize_t pvfs2_file_write( rw.dest.address.nr_segs = 1; rw.off.io.offset = offset; g_pvfs2_stats.writes++; - ret = do_readv_writev(&rw); - return ret; + return do_readv_writev(&rw); } /* compat code, < 2.6.19 */ @@ -2202,9 +2200,6 @@ static ssize_t pvfs2_file_readx( { struct rw_options rw; - gossip_err("Executing pvfs2_file_readx. offset:NONE \ttotal length:%zd\n" - ,iov_length(iov,nr_segs)); - memset(&rw, 0, sizeof(rw)); rw.async = 0; rw.type = IO_READX; @@ -2436,7 +2431,9 @@ pvfs2_aio_cancel(struct kiocb *iocb, struct io_event *event) * htable_in_progress or from the req list * as the case may be. */ - clean_up_interrupted_operation(op); + gossip_debug(GOSSIP_WAIT_DEBUG, "*** %s: operation aio_cancel " + "(tag %lld, op %p)\n", __func__, lld(op->tag), op); + pvfs2_clean_up_interrupted_operation(op); /* * However, we need to make sure that * the client daemon is not transferring data @@ -2896,10 +2893,6 @@ static ssize_t pvfs2_file_aio_read_iovec(struct kiocb *iocb, { struct rw_options rw; - gossip_err("Executing pvfs2_file_aio_read_iovec. offset:%lld \ttotal length:%zd\n" - ,(long long)offset - ,iov_length(iov,nr_segs)); - memset(&rw, 0, sizeof(rw)); rw.async = !is_sync_kiocb(iocb); rw.type = IO_READ; @@ -2981,8 +2974,12 @@ pvfs2_file_aio_write(struct kiocb *iocb, const char __user *buffer, */ #ifdef HAVE_NO_FS_IOC_FLAGS +#ifdef HAVE_UNLOCKED_IOCTL_HANDLER +long pvfs2_ioctl( +#else int pvfs2_ioctl( struct inode *inode, +#endif /* HAVE_UNLOCKED_IOCTL_HANDLER */ struct file *file, unsigned int cmd, unsigned long arg) @@ -2991,8 +2988,12 @@ int pvfs2_ioctl( } #else +#ifdef HAVE_UNLOCKED_IOCTL_HANDLER +long pvfs2_ioctl( +#else int pvfs2_ioctl( struct inode *inode, +#endif /* HAVE_UNLOCKED_IOCTL_HANDLER */ struct file *file, unsigned int cmd, unsigned long arg) @@ -3013,7 +3014,7 @@ int pvfs2_ioctl( #ifdef HAVE_XATTR_HANDLER_GET_FIVE_PARAM file->f_dentry, #else - inode, + file->f_dentry->d_inode, #endif /* HAVE_XATTR_HANDLER_GET_FIVE_PARAM */ "user.pvfs2.meta_hint", &val, @@ -3062,7 +3063,7 @@ int pvfs2_ioctl( #ifdef HAVE_XATTR_HANDLER_SET_SIX_PARAM file->f_dentry, #else - inode, + file->f_dentry->d_inode, #endif /* HAVE_XATTR_HANDLER_SET_SIX_PARAM */ "user.pvfs2.meta_hint", &val, @@ -3416,7 +3417,11 @@ struct file_operations pvfs2_file_operations = .aio_write = pvfs2_file_aio_write, # endif #endif +#ifdef HAVE_UNLOCKED_IOCTL_HANDLER + .unlocked_ioctl = pvfs2_ioctl, +#else .ioctl = pvfs2_ioctl, +#endif /* HAVE_UNLOCKED_IOCTL_HANDLER */ .mmap = pvfs2_file_mmap, .open = pvfs2_file_open, .release = pvfs2_file_release, diff --git a/src/kernel/linux-2.6/inode.c b/src/kernel/linux-2.6/inode.c index 006fca5..3693ef1 100644 --- a/src/kernel/linux-2.6/inode.c +++ b/src/kernel/linux-2.6/inode.c @@ -93,6 +93,8 @@ static int pvfs2_readpages( list_del(&page->lru); if (!add_to_page_cache(page, mapping, page->index, GFP_KERNEL)) { ret = read_one_page(page); + gossip_debug(GOSSIP_INODE_DEBUG, "failure adding page to cache, " + "read_one_page returned: %d\n", ret); } else { page_cache_release(page); @@ -190,12 +192,29 @@ int pvfs2_setattr(struct dentry *dentry, struct iattr *iattr) int ret = -EINVAL; struct inode *inode = dentry->d_inode; - gossip_debug(GOSSIP_INODE_DEBUG, "pvfs2_setattr: called on %s\n", dentry->d_name.name); + gossip_debug(GOSSIP_INODE_DEBUG, "pvfs2_setattr: called on %s\n", + dentry->d_name.name); ret = inode_change_ok(inode, iattr); if (ret == 0) { + +#ifdef HAVE_INODE_SETATTR ret = inode_setattr(inode, iattr); +#else + if ((iattr->ia_valid & ATTR_SIZE) && + iattr->ia_size != i_size_read(inode)) + { + ret = vmtruncate(inode, iattr->ia_size); + if (ret) + return ret; + } + + setattr_copy(inode, iattr); + mark_inode_dirty(inode); + ret = 0; +#endif /* HAVE_INODE_SETATTR */ + gossip_debug(GOSSIP_INODE_DEBUG, "pvfs2_setattr: inode_setattr returned %d\n", ret); if (ret == 0) diff --git a/src/kernel/linux-2.6/namei.c b/src/kernel/linux-2.6/namei.c index 804ccdd..ce73cfd 100644 --- a/src/kernel/linux-2.6/namei.c +++ b/src/kernel/linux-2.6/namei.c @@ -394,15 +394,24 @@ static int pvfs2_rename( struct dentry *new_dentry) { int ret = -EINVAL, are_directories = 0; + unsigned int local_count = 0; pvfs2_inode_t *pvfs2_old_parent_inode = PVFS2_I(old_dir); pvfs2_inode_t *pvfs2_new_parent_inode = PVFS2_I(new_dir); pvfs2_kernel_op_t *new_op = NULL; struct super_block *sb = NULL; + +#ifdef HAVE_DENTRY_D_COUNT_ATOMIC + local_count = atomic_read(&new_dentry->d_count); +#else + spin_lock( &new_dentry->d_lock ); + local_count = new_dentry->d_count; + spin_unlock( &new_dentry->d_lock ); +#endif /* HAVE_DENTRY_D_COUNT_ATOMIC */ gossip_debug(GOSSIP_NAME_DEBUG, "pvfs2_rename: called (%s/%s => %s/%s) ct=%d\n", old_dentry->d_parent->d_name.name, old_dentry->d_name.name, new_dentry->d_parent->d_name.name, new_dentry->d_name.name, - atomic_read(&new_dentry->d_count)); + local_count); are_directories = S_ISDIR(old_dentry->d_inode->i_mode); #if 0 diff --git a/src/kernel/linux-2.6/pvfs2-bufmap.c b/src/kernel/linux-2.6/pvfs2-bufmap.c index 49e4193..514cd57 100644 --- a/src/kernel/linux-2.6/pvfs2-bufmap.c +++ b/src/kernel/linux-2.6/pvfs2-bufmap.c @@ -29,11 +29,19 @@ static struct page **bufmap_page_array = NULL; /* array to track usage of buffer descriptors */ static int *buffer_index_array = NULL; +#ifdef HAVE_SPIN_LOCK_UNLOCKED static spinlock_t buffer_index_lock = SPIN_LOCK_UNLOCKED; +#else +static DEFINE_SPINLOCK(buffer_index_lock); +#endif /* HAVE_SPIN_LOCK_UNLOCKED */ /* array to track usage of buffer descriptors for readdir/readdirplus */ static int readdir_index_array[PVFS2_READDIR_DEFAULT_DESC_COUNT] = {0}; +#ifdef HAVE_SPIN_LOCK_UNLOCKED static spinlock_t readdir_index_lock = SPIN_LOCK_UNLOCKED; +#else +static DEFINE_SPINLOCK(readdir_index_lock); +#endif /* HAVE_SPIN_LOCK_UNLOCKED */ static struct pvfs_bufmap_desc *desc_array = NULL; @@ -215,6 +223,9 @@ int pvfs_bufmap_initialize(struct PVFS_dev_map_desc *user_desc) setting PageReserved in 2.6.x seems to cause more trouble than it's worth. in 2.4.x, marking the pages does what's expected and doesn't try to swap out our pages + + since setting the page as reserved has problems in 2.6 these pages + need to be mlock() in the user space side */ for(i = 0; i < bufmap_page_count; i++) { @@ -312,7 +323,7 @@ static int wait_for_a_slot(struct slot_args *slargs, int *buffer_index) { set_current_state(TASK_INTERRUPTIBLE); - /* check for available desc */ + /* check for available desc, slot_lock is the appropriate index_lock */ spin_lock(slargs->slot_lock); for(i = 0; i < slargs->slot_count; i++) { @@ -340,7 +351,8 @@ static int wait_for_a_slot(struct slot_args *slargs, int *buffer_index) slot_timeout_secs); if (!schedule_timeout(timeout)) { - gossip_debug(GOSSIP_BUFMAP_DEBUG, "*** wait_for_a_slot timed out\n"); + gossip_debug(GOSSIP_BUFMAP_DEBUG, + "*** wait_for_a_slot timed out\n"); ret = -ETIMEDOUT; break; } @@ -349,7 +361,8 @@ static int wait_for_a_slot(struct slot_args *slargs, int *buffer_index) continue; } - gossip_debug(GOSSIP_BUFMAP_DEBUG, "pvfs2: wait_for_a_slot() interrupted.\n"); + gossip_debug(GOSSIP_BUFMAP_DEBUG, "pvfs2: %s interrupted.\n", + __func__); ret = -EINTR; break; } @@ -362,12 +375,15 @@ static int wait_for_a_slot(struct slot_args *slargs, int *buffer_index) static void put_back_slot(struct slot_args *slargs, int buffer_index) { + + /* slot_lock is the appropriate index_lock */ + spin_lock(slargs->slot_lock); if (buffer_index < 0 || buffer_index >= slargs->slot_count) { + spin_unlock(slargs->slot_lock); return; } /* put the desc back on the queue */ - spin_lock(slargs->slot_lock); slargs->slot_array[buffer_index] = 0; spin_unlock(slargs->slot_lock); @@ -483,7 +499,6 @@ void readdir_index_put(int buffer_index) return; } - slargs.slot_count = PVFS2_READDIR_DEFAULT_DESC_COUNT; slargs.slot_array = readdir_index_array; slargs.slot_lock = &readdir_index_lock; @@ -528,6 +543,7 @@ int pvfs_bufmap_copy_to_user(void __user *to, int buffer_index, size_t size) from_kaddr = pvfs2_kmap(from->page_array[from_page_index]); ret = copy_to_user(to_kaddr, from_kaddr, cur_copy_size); + /* not marking dirty, mapped page isn't changed */ pvfs2_kunmap(from->page_array[from_page_index]); if (ret) @@ -633,6 +649,9 @@ int pvfs_bufmap_copy_from_user(int buffer_index, void __user *from, size_t size) gossip_debug(GOSSIP_BUFMAP_DEBUG, "First character (integer value) in pvfs_bufmap_copy_from_user: %d\n", tmp_int); } + if( !PageReserved(to->page_array[to_page_index]) ) + SetPageDirty(to->page_array[to_page_index]); + pvfs2_kunmap(to->page_array[to_page_index]); if (ret) @@ -719,6 +738,11 @@ int pvfs_bufmap_copy_to_pages(int buffer_index, if (cur_copy_size < PAGE_SIZE) { memset(to_kaddr + cur_copy_size, 0, PAGE_SIZE - cur_copy_size); } + if( !PageReserved(page) ) + SetPageDirty(page); + if( !PageReserved(from->page_array[from_page_index]) ) + SetPageDirty(from->page_array[from_page_index]); + pvfs2_kunmap(page); pvfs2_kunmap(from->page_array[from_page_index]); @@ -790,6 +814,12 @@ int pvfs_bufmap_copy_from_pages(int buffer_index, to_kaddr, from_kaddr, cur_copy_size); #endif memcpy(to_kaddr, from_kaddr, cur_copy_size); + + if( !PageReserved(to->page_array[to_page_index]) ) + SetPageDirty(to->page_array[to_page_index]); + if( !PageReserved(page) ) + SetPageDirty(page); + pvfs2_kunmap(page); pvfs2_kunmap(to->page_array[to_page_index]); amt_copied += cur_copy_size; @@ -904,6 +934,9 @@ int pvfs_bufmap_copy_iovec_from_user( } to_kaddr = pvfs2_kmap(to->page_array[to_page_index]); ret = copy_from_user(to_kaddr + to_page_offset, from_addr, cur_copy_size); + if( !PageReserved(to->page_array[to_page_index]) ) + SetPageDirty(to->page_array[to_page_index]); + if (!tmp_printer) { tmp_printer = (char*)(to_kaddr + to_page_offset); @@ -1043,6 +1076,8 @@ int pvfs_bufmap_copy_iovec_from_kernel( } to_kaddr = pvfs2_kmap(to->page_array[to_page_index]); memcpy(to_kaddr + to_page_offset, from_kaddr, cur_copy_size); + if( !PageReserved(to->page_array[to_page_index]) ) + SetPageDirty(to->page_array[to_page_index]); pvfs2_kunmap(to->page_array[to_page_index]); #if 0 gossip_debug(GOSSIP_BUFMAP_DEBUG, "pvfs2_bufmap_copy_iovec_from_kernel: copying from kernel %p to kernel %p %zd bytes (to_kddr: %p,page_offset: %d)\n", @@ -1353,7 +1388,7 @@ size_t pvfs_bufmap_copy_to_user_task_iovec( struct mm_struct *mm = NULL; struct vm_area_struct *vma = NULL; struct page *page = NULL; - unsigned long to_addr = 0; + unsigned long to_addr = 0, copy_amt = 0; void *maddr = NULL; unsigned int to_offset = 0; unsigned int seg, from_page_offset = 0; @@ -1447,17 +1482,20 @@ size_t pvfs_bufmap_copy_to_user_task_iovec( ret = get_user_pages(tsk, mm, to_addr, 1,/* count */ 1,/* write */ - 1,/* force */ + 0,/* force */ &page, &vma); if (ret <= 0) break; to_offset = to_addr & (PAGE_SIZE - 1); maddr = pvfs2_kmap(page); from_kaddr = pvfs2_kmap(from->page_array[from_page_index]); - copy_to_user_page(vma, page, to_addr, - maddr + to_offset /* dst */, - from_kaddr + from_page_offset, /* src */ - cur_copy_size /* len */); + /* FIX */ + copy_amt = copy_to_user(maddr + to_offset, from_kaddr, cur_copy_size ); + if( copy_amt != 0 ) + { + gossip_err("%s: failure in copy_to_user, %lu could not be copied\n", + __func__, copy_amt); + } set_page_dirty_lock(page); pvfs2_kunmap(from->page_array[from_page_index]); pvfs2_kunmap(page); diff --git a/src/kernel/linux-2.6/pvfs2-cache.c b/src/kernel/linux-2.6/pvfs2-cache.c index 3733b13..3192d88 100644 --- a/src/kernel/linux-2.6/pvfs2-cache.c +++ b/src/kernel/linux-2.6/pvfs2-cache.c @@ -7,13 +7,21 @@ #include "pvfs2-kernel.h" /* A list of all allocated pvfs2 inode objects */ +#ifdef HAVE_SPIN_LOCK_UNLOCKED static spinlock_t pvfs2_inode_list_lock = SPIN_LOCK_UNLOCKED; +#else +static DEFINE_SPINLOCK(pvfs2_inode_list_lock); +#endif /* HAVE_SPIN_LOCK_UNLOCKED */ + static LIST_HEAD(pvfs2_inode_list); /* tags assigned to kernel upcall operations */ static uint64_t next_tag_value; +#ifdef HAVE_SPIN_LOCK_UNLOCKED static spinlock_t next_tag_value_lock = SPIN_LOCK_UNLOCKED; - +#else +static DEFINE_SPINLOCK(next_tag_value_lock); +#endif /* HAVE_SPIN_LOCK_UNLOCKED */ /* the pvfs2 memory caches */ #ifdef HAVE_STRUCT_KMEM_CACHE @@ -46,7 +54,6 @@ static int pvfs_kmem_cache_destroy(void *x) int op_cache_initialize(void) { - pvfs2_kernel_op_t *new_op = NULL; op_cache = kmem_cache_create( "pvfs2_op_cache", sizeof(pvfs2_kernel_op_t), 0, PVFS2_CACHE_CREATE_FLAGS, NULL @@ -55,8 +62,6 @@ int op_cache_initialize(void) #endif ); - new_op = kmem_cache_alloc(op_cache, PVFS2_CACHE_ALLOC_FLAGS); - if (!op_cache) { gossip_err("Cannot create pvfs2_op_cache\n"); @@ -144,8 +149,8 @@ char *get_opname_string(pvfs2_kernel_op_t *new_op) static pvfs2_kernel_op_t *op_alloc_common(int32_t op_linger, int32_t type) { pvfs2_kernel_op_t *new_op = NULL; - new_op = kmem_cache_alloc(op_cache, PVFS2_CACHE_ALLOC_FLAGS); + new_op = kmem_cache_alloc(op_cache, PVFS2_CACHE_ALLOC_FLAGS); if (new_op) { memset(new_op, 0, sizeof(pvfs2_kernel_op_t)); @@ -205,28 +210,11 @@ void op_release(pvfs2_kernel_op_t *pvfs2_op) } } - -static void dev_req_cache_ctor( -#if defined(HAVE_KMEM_CACHE_CREATE_CTOR_ONE_PARAM) - void *req -#elif defined(HAVE_KMEM_CACHE_CREATE_CTOR_TWO_PARAM) - struct kmem_cache *cachep, - void *req -#else - void *req, - pvfs2_kmem_cache_t * cachep, - unsigned long flags -#endif -) -{ - memset(req, 0, sizeof(MAX_ALIGNED_DEV_REQ_DOWNSIZE)); -} - int dev_req_cache_initialize(void) { dev_req_cache = kmem_cache_create( "pvfs2_devreqcache", MAX_ALIGNED_DEV_REQ_DOWNSIZE, 0, - PVFS2_CACHE_CREATE_FLAGS, dev_req_cache_ctor + PVFS2_CACHE_CREATE_FLAGS, NULL #ifdef HAVE_KMEM_CACHE_CREATE_DESTRUCTOR_PARAM , NULL #endif @@ -259,6 +247,10 @@ void *dev_req_alloc(void) { gossip_err("Failed to allocate from dev_req_cache\n"); } + else + { + memset(buffer, 0, sizeof(MAX_ALIGNED_DEV_REQ_DOWNSIZE)); + } return buffer; } @@ -290,9 +282,7 @@ static void pvfs2_inode_cache_ctor( { pvfs2_inode_t *pvfs2_inode = req; - memset(pvfs2_inode, 0, sizeof(pvfs2_inode_t)); ClearInitFlag(pvfs2_inode); - pvfs2_inode_initialize(pvfs2_inode); #ifndef PVFS2_LINUX_KERNEL_2_4 @@ -380,7 +370,10 @@ pvfs2_inode_t* pvfs2_inode_alloc(void) { gossip_err("Failed to allocate pvfs2_inode\n"); } - else { + else + { + ClearInitFlag(pvfs2_inode); + pvfs2_inode_initialize(pvfs2_inode); add_to_pinode_list(pvfs2_inode); } return pvfs2_inode; @@ -401,28 +394,11 @@ void pvfs2_inode_release(pvfs2_inode_t *pinode) #ifdef HAVE_AIO_VFS_SUPPORT -static void kiocb_ctor( -#if defined(HAVE_KMEM_CACHE_CREATE_CTOR_ONE_PARAM) - void *req -#elif defined(HAVE_KMEM_CACHE_CREATE_CTOR_TWO_PARAM) - struct kmem_cache *cachep, - void *req -#else - void *req, - pvfs2_kmem_cache_t * cachep, - unsigned long flags -#endif -) -{ - memset(req, 0, sizeof(pvfs2_kiocb)); -} - - int kiocb_cache_initialize(void) { pvfs2_kiocb_cache = kmem_cache_create( "pvfs2_kiocbcache", sizeof(pvfs2_kiocb), 0, - PVFS2_CACHE_CREATE_FLAGS, kiocb_ctor + PVFS2_CACHE_CREATE_FLAGS, NULL #ifdef HAVE_KMEM_CACHE_CREATE_DESTRUCTOR_PARAM , NULL #endif @@ -455,6 +431,10 @@ pvfs2_kiocb* kiocb_alloc(void) { gossip_err("kiocb_alloc: kmem_cache_alloc failed!\n"); } + else + { + memset(x, 0, sizeof(pvfs2_kiocb)); + } return x; } diff --git a/src/kernel/linux-2.6/pvfs2-kernel.h b/src/kernel/linux-2.6/pvfs2-kernel.h index a9344da..d2f89a9 100644 --- a/src/kernel/linux-2.6/pvfs2-kernel.h +++ b/src/kernel/linux-2.6/pvfs2-kernel.h @@ -23,6 +23,7 @@ #ifdef HAVE_NOWARNINGS_WHEN_INCLUDING_LINUX_CONFIG_H #include #endif +#include #ifdef PVFS2_LINUX_KERNEL_2_4 @@ -41,7 +42,6 @@ typedef unsigned long sector_t; #endif #else /* !(PVFS2_LINUX_KERNEL_2_4) */ - #include #include #include @@ -54,7 +54,6 @@ typedef unsigned long sector_t; #endif /* PVFS2_LINUX_KERNEL_2_4 */ -#include #include #include #include @@ -93,7 +92,9 @@ typedef unsigned long sector_t; #include #include #include +#ifdef HAVE_SMP_LOCK_H #include +#endif #include #include #include @@ -243,13 +244,8 @@ enum PVFS_async_io_type #define PVFS2_GFP_FLAGS (GFP_KERNEL) #define PVFS2_BUFMAP_GFP_FLAGS (GFP_KERNEL) -#ifdef CONFIG_HIGHMEM #define pvfs2_kmap(page) kmap(page) #define pvfs2_kunmap(page) kunmap(page) -#else -#define pvfs2_kmap(page) page_address(page) -#define pvfs2_kunmap(page) do {} while(0) -#endif /* CONFIG_HIGHMEM */ /* pvfs2 xattr and acl related defines */ #ifdef HAVE_XATTR @@ -773,7 +769,7 @@ int wait_for_matching_downcall( pvfs2_kernel_op_t * op); int wait_for_cancellation_downcall( pvfs2_kernel_op_t * op); -void clean_up_interrupted_operation( +void pvfs2_clean_up_interrupted_operation( pvfs2_kernel_op_t * op); void purge_waiting_ops(void); @@ -790,6 +786,11 @@ struct super_block* pvfs2_get_sb( void *data, int silent); #else +#ifdef HAVE_FSTYPE_MOUNT_ONLY +struct dentry *pvfs2_mount( + struct file_system_type *fst, int flags, + const char *devname, void *data); +#else #ifdef HAVE_VFSMOUNT_GETSB int pvfs2_get_sb( struct file_system_type *fst, int flags, @@ -799,7 +800,8 @@ int pvfs2_get_sb( struct super_block *pvfs2_get_sb( struct file_system_type *fst, int flags, const char *devname, void *data); -#endif +#endif /* HAVE_VFSMOUNT_GETSB */ +#endif /* HAVE_FSTYPE_MOUNT_ONLY */ #endif void pvfs2_read_inode( @@ -875,8 +877,12 @@ struct inode *pvfs2_iget_common( #if defined(PVFS2_LINUX_KERNEL_2_4) || defined(HAVE_TWO_PARAM_PERMISSION) int pvfs2_permission(struct inode *, int); #else -int pvfs2_permission(struct inode *inode, - int mask, struct nameidata *nd); +int pvfs2_permission(struct inode *, int mask, +#ifdef HAVE_THREE_PARAM_PERMISSION_WITH_FLAG + unsigned int flags); +#else + struct nameidata *nd); +#endif /* HAVE_THREE_PARAM_PERMISSION_WITH_FLAG */ #endif /***************************** diff --git a/src/kernel/linux-2.6/pvfs2-mod.c b/src/kernel/linux-2.6/pvfs2-mod.c index c0b11fb..abd6692 100644 --- a/src/kernel/linux-2.6/pvfs2-mod.c +++ b/src/kernel/linux-2.6/pvfs2-mod.c @@ -83,7 +83,12 @@ MODULE_PARM(slot_timeout_secs, "i"); struct file_system_type pvfs2_fs_type = { .name = "pvfs2", +/* only define mount if the kernel no longer supports get_sb */ +#ifdef HAVE_FSTYPE_MOUNT_ONLY + .mount = pvfs2_mount, +#else .get_sb = pvfs2_get_sb, +#endif /* HAVE_FSTYPE_MOUNT_ONLY */ .kill_sb = pvfs2_kill_sb, .owner = THIS_MODULE, /* @@ -120,7 +125,11 @@ struct qhash_table *htable_ops_in_progress = NULL; LIST_HEAD(pvfs2_request_list); /* used to protect the above pvfs2_request_list */ +#ifdef HAVE_SPIN_LOCK_UNLOCKED spinlock_t pvfs2_request_list_lock = SPIN_LOCK_UNLOCKED; +#else +DEFINE_SPINLOCK(pvfs2_request_list_lock); +#endif /* HAVE_SPIN_LOCK_UNLOCKED */ /* used for incoming request notification */ DECLARE_WAIT_QUEUE_HEAD(pvfs2_request_list_waitq); diff --git a/src/kernel/linux-2.6/pvfs2-proc.c b/src/kernel/linux-2.6/pvfs2-proc.c index d4ce42b..9824820 100644 --- a/src/kernel/linux-2.6/pvfs2-proc.c +++ b/src/kernel/linux-2.6/pvfs2-proc.c @@ -435,7 +435,7 @@ static int min_slot_timeout_secs[] = {0}, max_slot_timeout_secs[] = {INT_MAX}; * Modern kernels (up to 2.6.33) prefer to number the controls themselves. */ #ifdef CTL_UNNUMBERED -#define UNNUMBERED_OR_VAL(x) CTL_UNNUMBERED +#define UNNUMBERED_OR_VAL(x) ((x==CTL_NONE) ? CTL_NONE : CTL_UNNUMBERED) #else #define UNNUMBERED_OR_VAL(x) x #endif @@ -492,7 +492,7 @@ static ctl_table pvfs2_acache_table[] = { .proc_handler = &pvfs2_param_proc_handler, .extra1 = &acache_rec_extra, }, - { CTL_NAME(0) } + { CTL_NAME(CTL_NONE) } }; static ctl_table pvfs2_static_acache_table[] = { /* controls static acache timeout */ @@ -531,7 +531,7 @@ static ctl_table pvfs2_static_acache_table[] = { .proc_handler = &pvfs2_param_proc_handler, .extra1 = &static_acache_rec_extra, }, - { CTL_NAME(0) } + { CTL_NAME(CTL_NONE) } }; static ctl_table pvfs2_ncache_table[] = { @@ -571,7 +571,7 @@ static ctl_table pvfs2_ncache_table[] = { .proc_handler = &pvfs2_param_proc_handler, .extra1 = &ncache_rec_extra }, - { CTL_NAME(0) } + { CTL_NAME(CTL_NONE) } }; static int acache_perf_count = PVFS2_PERF_COUNT_REQUEST_ACACHE; static int static_acache_perf_count = PVFS2_PERF_COUNT_REQUEST_STATIC_ACACHE; @@ -601,7 +601,7 @@ static ctl_table pvfs2_pc_table[] = { .proc_handler = pvfs2_pc_proc_handler, .extra1 = &ncache_perf_count }, - { CTL_NAME(0) } + { CTL_NAME(CTL_NONE) } }; pvfs2_stats g_pvfs2_stats; @@ -639,7 +639,7 @@ static ctl_table pvfs2_stats_table[] = { .mode = 0444, .proc_handler = &proc_dointvec, }, - { CTL_NAME(0) } + { CTL_NAME(CTL_NONE) } }; @@ -762,7 +762,7 @@ static ctl_table pvfs2_table[] = { .mode = 0555, .child = pvfs2_stats_table }, - { CTL_NAME(0) } + { CTL_NAME(CTL_NONE) } }; static ctl_table fs_table[] = { { @@ -771,7 +771,7 @@ static ctl_table fs_table[] = { .mode = 0555, .child = pvfs2_table }, - { CTL_NAME(0) } + { CTL_NAME(CTL_NONE) } }; #endif diff --git a/src/kernel/linux-2.6/pvfs2-utils.c b/src/kernel/linux-2.6/pvfs2-utils.c index d3815e6..f12ddeb 100644 --- a/src/kernel/linux-2.6/pvfs2-utils.c +++ b/src/kernel/linux-2.6/pvfs2-utils.c @@ -2003,6 +2003,9 @@ int pvfs2_cancel_op_in_progress(unsigned long tag) return (ret); } +/* + We want to clear everything except for rw_semaphore and the vfs_inode +*/ void pvfs2_inode_initialize(pvfs2_inode_t *pvfs2_inode) { if (!InitFlag(pvfs2_inode)) @@ -2012,6 +2015,8 @@ void pvfs2_inode_initialize(pvfs2_inode_t *pvfs2_inode) pvfs2_inode->last_failed_block_index_read = 0; memset(pvfs2_inode->link_target, 0, sizeof(pvfs2_inode->link_target)); pvfs2_inode->error_code = 0; + pvfs2_inode->revalidate_failed = 0; + pvfs2_inode->pinode_flags = 0; SetInitFlag(pvfs2_inode); } } @@ -2029,14 +2034,19 @@ void pvfs2_inode_finalize(pvfs2_inode_t *pvfs2_inode) void pvfs2_op_initialize(pvfs2_kernel_op_t *op) { - op->io_completed = 0; + if( op ) + { + spin_lock( &op->lock ); + op->io_completed = 0; - op->upcall.type = PVFS2_VFS_OP_INVALID; - op->downcall.type = PVFS2_VFS_OP_INVALID; - op->downcall.status = -1; + op->upcall.type = PVFS2_VFS_OP_INVALID; + op->downcall.type = PVFS2_VFS_OP_INVALID; + op->downcall.status = -1; - op->op_state = OP_VFS_STATE_UNKNOWN; - op->tag = 0; + op->op_state = OP_VFS_STATE_UNKNOWN; + op->tag = 0; + spin_unlock( &op->lock ); + } } void pvfs2_make_bad_inode(struct inode *inode) diff --git a/src/kernel/linux-2.6/super.c b/src/kernel/linux-2.6/super.c index 83a106e..07329a8 100644 --- a/src/kernel/linux-2.6/super.c +++ b/src/kernel/linux-2.6/super.c @@ -13,7 +13,11 @@ LIST_HEAD(pvfs2_superblocks); /* used to protect the above superblock list */ +#ifdef HAVE_SPIN_LOCK_UNLOCKED spinlock_t pvfs2_superblocks_lock = SPIN_LOCK_UNLOCKED; +#else +DEFINE_SPINLOCK(pvfs2_superblocks_lock); +#endif /* HAVE_SPIN_LOCK_UNLOCKED */ #ifdef HAVE_GET_FS_KEY_SUPER_OPERATIONS static void pvfs2_sb_get_fs_key(struct super_block *sb, char **ppkey, int *keylen); @@ -890,7 +894,11 @@ void fsid_key_table_finalize(void) #endif /* Called whenever the VFS dirties the inode in response to atime updates */ -static void pvfs2_dirty_inode(struct inode *inode) +static void pvfs2_dirty_inode(struct inode *inode +#ifdef HAVE_DIRTY_INODE_FLAGS + ,int flags +#endif + ) { if (inode) { @@ -1296,7 +1304,13 @@ int pvfs2_fill_sb( sb->s_root = root_dentry; return 0; } - +#ifdef HAVE_FSTYPE_MOUNT_ONLY +struct dentry *pvfs2_mount( + struct file_system_type *fst, + int flags, + const char *devname, + void *data) +#else #ifdef HAVE_VFSMOUNT_GETSB int pvfs2_get_sb( struct file_system_type *fst, @@ -1310,12 +1324,16 @@ struct super_block *pvfs2_get_sb( int flags, const char *devname, void *data) -#endif +#endif /* HAVE_VFSMOUNT_GETSB */ +#endif /* HAVE_FSTYPE_MOUNT_ONLY */ { int ret = -EINVAL; struct super_block *sb = ERR_PTR(-EINVAL); pvfs2_kernel_op_t *new_op; pvfs2_mount_sb_info_t mount_sb_info; +#ifdef HAVE_FSTYPE_MOUNT_ONLY + struct dentry *mnt_sb_d = ERR_PTR(-EINVAL); +#endif gossip_debug(GOSSIP_SUPER_DEBUG, "pvfs2_get_sb: called with devname %s\n", devname); @@ -1325,7 +1343,7 @@ struct super_block *pvfs2_get_sb( if (!new_op) { ret = -ENOMEM; -#ifdef HAVE_VFSMOUNT_GETSB +#if defined(HAVE_VFSMOUNT_GETSB) && !defined(HAVE_FSTYPE_MOUNT_ONLY) return ret; #else return ERR_PTR(ret); @@ -1374,6 +1392,11 @@ struct super_block *pvfs2_get_sb( here. so we store it temporarily and pass all of the info to fill_sb where it's properly copied out */ + /* kernels beyond 2.6.38 no longer have get_sb_nodev in favor of + * mount_nodev. if the kernel still has get_sb_nodev use that in + * favor of mount_nodev to minimize changes for currently working + * kernels. */ +#ifdef HAVE_GETSB_NODEV #ifdef HAVE_VFSMOUNT_GETSB ret = get_sb_nodev( fst, flags, (void *)&mount_sb_info, pvfs2_fill_sb, mnt); @@ -1383,7 +1406,20 @@ struct super_block *pvfs2_get_sb( #else sb = get_sb_nodev( fst, flags, (void *)&mount_sb_info, pvfs2_fill_sb); -#endif +#endif /* HAVE_VFSMOUNT_GETSB */ +#else /* !HAVE_GETSB_NODEV */ + mnt_sb_d = mount_nodev( + fst, flags, (void *)&mount_sb_info, pvfs2_fill_sb); + if( !IS_ERR(mnt_sb_d) ) + { + sb = mnt_sb_d->d_sb; + } + else + { + sb = ERR_CAST(mnt_sb_d); + goto free_op; + } +#endif /* HAVE_GETSB_NODEV */ if (sb && !IS_ERR(sb) && (PVFS2_SB(sb))) { @@ -1422,17 +1458,22 @@ struct super_block *pvfs2_get_sb( { gossip_err("ERROR: device name not specified.\n"); } - +#ifdef HAVE_FSTYPE_MOUNT_ONLY + return mnt_sb_d; +#else #ifdef HAVE_VFSMOUNT_GETSB return ret; #else return sb; -#endif +#endif /* HAVE_VFSMOUNT_GETSB */ +#endif /* HAVE_FSTYPE_MOUNT_ONLY */ error_exit: if (ret || IS_ERR(sb)) { +#if !defined(HAVE_FSTYPE_MOUNT_ONLY) sb = ERR_PTR(ret); +#endif /* HAVE_FSTYPE_MOUNT_ONLY */ } #ifdef HAVE_VFSMOUNT_GETSB free_op: @@ -1448,9 +1489,13 @@ struct super_block *pvfs2_get_sb( { op_release(new_op); } -#ifdef HAVE_VFSMOUNT_GETSB +#if defined(HAVE_VFSMOUNT_GETSB) && !defined(HAVE_FSTYPE_MOUNT_ONLY) gossip_debug(GOSSIP_SUPER_DEBUG, "pvfs2_get_sb: returning %d\n", ret); return ret; +#elif defined(HAVE_FSTYPE_MOUNT_ONLY) + gossip_debug(GOSSIP_SUPER_DEBUG, "pvfs2_get_sb: returning dentry %p\n", + mnt_sb_d); + return mnt_sb_d; #else gossip_debug(GOSSIP_SUPER_DEBUG, "pvfs2_get_sb: returning sb %p\n", sb); return sb; diff --git a/src/kernel/linux-2.6/waitqueue.c b/src/kernel/linux-2.6/waitqueue.c index ec1fbe2..4af05ef 100644 --- a/src/kernel/linux-2.6/waitqueue.c +++ b/src/kernel/linux-2.6/waitqueue.c @@ -1,6 +1,7 @@ /* * (C) 2001 Clemson University and The University of Chicago - * + * (C) 2011 Omnibond Systems + * * Changes by Acxiom Corporation to implement generic service_operation() * function, Copyright © Acxiom Corporation, 2005. * @@ -28,8 +29,8 @@ void purge_waiting_ops(void) spin_lock(&pvfs2_request_list_lock); list_for_each_entry(op, &pvfs2_request_list, list) { - spin_lock(&op->lock); gossip_debug(GOSSIP_WAIT_DEBUG, "pvfs2-client-core: purging op tag %lld %s\n", lld(op->tag), get_opname_string(op)); + spin_lock(&op->lock); set_op_state_purged(op); spin_unlock(&op->lock); wake_up_interruptible(&op->waitq); @@ -161,7 +162,7 @@ int service_operation( return(ret); } -void clean_up_interrupted_operation( +void pvfs2_clean_up_interrupted_operation( pvfs2_kernel_op_t * op) { /* @@ -173,6 +174,23 @@ void clean_up_interrupted_operation( while holding the request_list lock. Here, we first lock the op and then lock the appropriate list. */ + if( !op ) + { + gossip_debug(GOSSIP_WAIT_DEBUG, "%s: op is null, ignoring\n", + __func__); + return; + } + + /* one more sanity check, make sure it's in one of the possible states + * or don't try to cancel it */ + if( ! (op_state_waiting(op) || op_state_in_progress(op) || + op_state_serviced(op) || op_state_purged(op)) ) + { + gossip_debug(GOSSIP_WAIT_DEBUG, "%s: op %p not in a valid state (%0x), " + "ignoring\n", __func__, op, op->op_state); + return; + } + spin_lock(&op->lock); if (op_state_waiting(op)) @@ -181,22 +199,24 @@ void clean_up_interrupted_operation( upcall hasn't been read; remove op from upcall request list. */ + spin_unlock(&op->lock); remove_op_from_request_list(op); gossip_debug(GOSSIP_WAIT_DEBUG, "Interrupted: Removed op %p from request_list\n", op); } else if (op_state_in_progress(op)) { /* op must be removed from the in progress htable */ + spin_unlock(&op->lock); remove_op_from_htable_ops_in_progress(op); gossip_debug(GOSSIP_WAIT_DEBUG, "Interrupted: Removed op %p from " "htable_ops_in_progress\n", op); } else if (!op_state_serviced(op)) { - gossip_err("interrupted operation is in a weird state 0x%x\n", + spin_unlock(&op->lock); + gossip_err("interrupted operation is in a weird state 0x%x\n", op->op_state); } - spin_unlock(&op->lock); } /** sleeps on waitqueue waiting for matching downcall. @@ -233,12 +253,13 @@ int wait_for_matching_downcall(pvfs2_kernel_op_t * op) ret = 0; break; } + spin_unlock(&op->lock); if (!signal_pending(current)) { - /* if this was our first attempt and client-core has not purged our operation, - * we are happy to simply wait - */ + /* if this was our first attempt and client-core has not purged our + * operation, we are happy to simply wait */ + spin_lock(&op->lock); if (op->attempts == 0 && !op_state_purged(op)) { spin_unlock(&op->lock); @@ -249,36 +270,38 @@ int wait_for_matching_downcall(pvfs2_kernel_op_t * op) /* subsequent attempts, we retry exactly once with timeouts */ if (!schedule_timeout(MSECS_TO_JIFFIES(1000 * op_timeout_secs))) { - gossip_debug(GOSSIP_WAIT_DEBUG, "*** operation timed out (tag %lld, %p, att %d)\n", - lld(op->tag), op, op->attempts); + gossip_debug(GOSSIP_WAIT_DEBUG, "*** %s: operation timed " + "out (tag %lld, %p, att %d)\n", __func__, + lld(op->tag), op, op->attempts); ret = -ETIMEDOUT; - clean_up_interrupted_operation(op); + pvfs2_clean_up_interrupted_operation(op); break; } } spin_lock(&op->lock); op->attempts++; - /* if the operation was purged in the meantime, it is better to requeue it afresh - * but ensure that we have not been purged repeatedly. This could happen if client-core - * crashes when an op is being serviced, so we requeue the op, client core crashes again - * so we requeue the op, client core starts, and so on...*/ + /* if the operation was purged in the meantime, it is better to + * requeue it afresh but ensure that we have not been purged + * repeatedly. This could happen if client-core crashes when an op + * is being serviced, so we requeue the op, client core crashes + * again so we requeue the op, client core starts, and so on...*/ if (op_state_purged(op)) { ret = (op->attempts < PVFS2_PURGE_RETRY_COUNT) ? -EAGAIN : -EIO; spin_unlock(&op->lock); - clean_up_interrupted_operation(op); + gossip_debug(GOSSIP_WAIT_DEBUG, "*** %s: operation purged " + "(tag %lld, %p, att %d)\n", __func__, lld(op->tag), + op, op->attempts); + pvfs2_clean_up_interrupted_operation(op); break; } spin_unlock(&op->lock); continue; } - else { - spin_unlock(&op->lock); - } - gossip_debug(GOSSIP_WAIT_DEBUG, "*** operation interrupted by a signal (tag %lld, op %p)\n", - lld(op->tag), op); - clean_up_interrupted_operation(op); + gossip_debug(GOSSIP_WAIT_DEBUG, "*** %s: operation interrupted by a " + "signal (tag %lld, op %p)\n", __func__, lld(op->tag), op); + pvfs2_clean_up_interrupted_operation(op); ret = -EINTR; break; } @@ -325,8 +348,9 @@ int wait_for_cancellation_downcall(pvfs2_kernel_op_t * op) if (!schedule_timeout (MSECS_TO_JIFFIES(1000 * op_timeout_secs))) { - gossip_debug(GOSSIP_WAIT_DEBUG, "*** operation timed out: %p\n", op); - clean_up_interrupted_operation(op); + gossip_debug(GOSSIP_WAIT_DEBUG, "*** %s: operation timed out: " + "(tag %lld, op %p)\n", __func__, lld(op->tag), op); + pvfs2_clean_up_interrupted_operation(op); ret = -ETIMEDOUT; break; } diff --git a/src/proto/PINT-le-bytefield.c b/src/proto/PINT-le-bytefield.c index 512ff2c..c12ff06 100644 --- a/src/proto/PINT-le-bytefield.c +++ b/src/proto/PINT-le-bytefield.c @@ -10,7 +10,7 @@ #include #include -#define __PINT_REQPROTO_ENCODE_FUNCS_C /* trigger actual definitions */ +#define __PINT_REQPROTO_ENCODE_FUNCS_C /** trigger actual definitions */ #include "endecode-funcs.h" #include "bmi.h" #include "bmi-byteswap.h" @@ -21,18 +21,18 @@ #include "pvfs2-req-proto.h" #include "PINT-reqproto-encode.h" #include "PINT-reqproto-module.h" -#include "src/io/description/pint-request.h" /* for PINT_Request */ -#include "src/io/description/pint-distribution.h" /* for PINT_dist_lookup */ +#include "src/io/description/pint-request.h" /** for PINT_Request */ +#include "src/io/description/pint-distribution.h" /** for PINT_dist_lookup */ #include "pvfs2-internal.h" #include "pint-hint.h" -/* defined later */ +/** defined later */ static int check_req_size(struct PVFS_server_req *req); static int check_resp_size(struct PVFS_server_resp *resp); static int initializing_sizes = 0; -/* an array of structs for storing precalculated maximum encoding sizes +/** an array of structs for storing precalculated maximum encoding sizes * for each type of server operation */ static struct { @@ -40,7 +40,7 @@ static struct { int resp; } *max_size_array = NULL; -/* lebf_initialize() +/** lebf_initialize() * * initializes the encoder module, calculates max sizes of each request type * in advance @@ -82,7 +82,7 @@ static void lebf_initialize(void) initializing_sizes = 1; - /* set number of hints in request to the max */ + /** set number of hints in request to the max */ for(i = 0; i < PVFS_HINT_MAX; ++i) { char name[PVFS_HINT_MAX_NAME_LENGTH] = {0}; @@ -101,7 +101,7 @@ static void lebf_initialize(void) case PVFS_SERV_PERF_UPDATE: case PVFS_SERV_PRECREATE_POOL_REFILLER: case PVFS_SERV_JOB_TIMER: - /* never used, skip initialization */ + /** never used, skip initialization */ continue; case PVFS_SERV_GETCONFIG: resp.u.getconfig.fs_config_buf = tmp_name; @@ -115,7 +115,7 @@ static void lebf_initialize(void) respsize = extra_size_PVFS_servresp_lookup_path; break; case PVFS_SERV_BATCH_CREATE: - /* can request a range of handles */ + /** can request a range of handles */ req.u.batch_create.handle_extent_array.extent_count = 0; req.u.batch_create.object_count = 0; resp.u.batch_create.handle_count = 0; @@ -123,7 +123,7 @@ static void lebf_initialize(void) respsize = extra_size_PVFS_servresp_batch_create; break; case PVFS_SERV_CREATE: - /* can request a range of handles */ + /** can request a range of handles */ reqsize = extra_size_PVFS_servreq_create; respsize = extra_size_PVFS_servresp_create; break; @@ -136,7 +136,7 @@ static void lebf_initialize(void) case PVFS_SERV_IMM_COPIES: break; case PVFS_SERV_REMOVE: - /* nothing special, let normal encoding work */ + /** nothing special, let normal encoding work */ break; case PVFS_SERV_BATCH_REMOVE: req.u.batch_remove.handles = NULL; @@ -144,7 +144,7 @@ static void lebf_initialize(void) reqsize = extra_size_PVFS_servreq_batch_remove; break; case PVFS_SERV_MGMT_REMOVE_OBJECT: - /* nothing special, let normal encoding work */ + /** nothing special, let normal encoding work */ break; case PVFS_SERV_MGMT_REMOVE_DIRENT: req.u.mgmt_remove_dirent.entry = tmp_name; @@ -191,7 +191,7 @@ static void lebf_initialize(void) reqsize = extra_size_PVFS_servreq_chdirent; break; case PVFS_SERV_TRUNCATE: - /* nothing special */ + /** nothing special */ break; case PVFS_SERV_MKDIR: req.u.mkdir.handle_extent_array.extent_count = 0; @@ -204,22 +204,22 @@ static void lebf_initialize(void) respsize = extra_size_PVFS_servresp_readdir; break; case PVFS_SERV_FLUSH: - /* nothing special */ + /** nothing special */ break; case PVFS_SERV_MGMT_SETPARAM: - /* nothing special */ + /** nothing special */ break; case PVFS_SERV_MGMT_NOOP: - /* nothing special */ + /** nothing special */ break; case PVFS_SERV_STATFS: - /* nothing special */ + /** nothing special */ break; case PVFS_SERV_MGMT_GET_DIRDATA_HANDLE: - /* nothing special */ + /** nothing special */ break; case PVFS_SERV_WRITE_COMPLETION: - /* only a response, but nothing special there */ + /** only a response, but nothing special there */ noreq = 1; break; case PVFS_SERV_MGMT_PERF_MON: @@ -241,7 +241,7 @@ static void lebf_initialize(void) respsize = extra_size_PVFS_servresp_mgmt_event_mon; break; case PVFS_SERV_PROTO_ERROR: - /* nothing special */ + /** nothing special */ break; case PVFS_SERV_GETEATTR: req.u.geteattr.nkey = 0; @@ -278,11 +278,15 @@ static void lebf_initialize(void) resp.u.tree_get_file_size.caller_handle_index = 0; respsize = extra_size_PVFS_servresp_tree_get_file_size; break; - case PVFS_SERV_NUM_OPS: /* sentinel, should not hit */ + case PVFS_SERV_MGMT_GET_UID: + resp.u.mgmt_get_uid.uid_info_array_count = 0; + respsize = extra_size_PVFS_servresp_mgmt_get_uid; + break; + case PVFS_SERV_NUM_OPS: /** sentinel, should not hit */ assert(0); break; } - /* since these take the max size when mallocing in the encode, + /** since these take the max size when mallocing in the encode, * give them a huge number, then later fix it. */ max_size_array[op_type].req = max_size_array[op_type].resp = init_big_size; @@ -304,7 +308,7 @@ static void lebf_initialize(void) max_size_array[op_type].resp = respsize; } - /* clean up stuff just used for initialization */ + /** clean up stuff just used for initialization */ PVFS_hint_free(req.hints); free(tmp_dist.dist_name); free(tmp_name); @@ -316,7 +320,7 @@ static void lebf_finalize(void) free(max_size_array); } -/* lebf_encode_calc_max_size() +/** lebf_encode_calc_max_size() * * reports the maximum allowed encoded size for the given request type * @@ -351,13 +355,13 @@ encode_common(struct PINT_encoded_msg *target_msg, int maxsize) void *buf = NULL; gossip_debug(GOSSIP_ENDECODE_DEBUG,"encode_common\n"); - /* this encoder always uses just one buffer */ + /** this encoder always uses just one buffer */ BF_ENCODE_TARGET_MSG_INIT(target_msg); gossip_debug(GOSSIP_ENDECODE_DEBUG,"\tmaxsize:%d\tinitializing_sizes:%d\n" ,maxsize,initializing_sizes); - /* allocate the max size buffer to avoid the work of calculating it */ + /** allocate the max size buffer to avoid the work of calculating it */ buf = (initializing_sizes ? malloc(maxsize) : BMI_memalloc(target_msg->dest, maxsize, BMI_SEND)); if (!buf) @@ -372,7 +376,7 @@ encode_common(struct PINT_encoded_msg *target_msg, int maxsize) target_msg->alloc_size_list[0] = maxsize; target_msg->ptr_current = buf; - /* generic header */ + /** generic header */ memcpy(target_msg->ptr_current, le_bytefield_table.generic_header, PINT_ENC_GENERIC_HEADER_SIZE); target_msg->ptr_current += PINT_ENC_GENERIC_HEADER_SIZE; @@ -381,7 +385,7 @@ encode_common(struct PINT_encoded_msg *target_msg, int maxsize) return ret; } -/* lebf_encode_req() +/** lebf_encode_req() * * encodes a request structure * @@ -403,7 +407,7 @@ static int lebf_encode_req( goto out; gossip_debug(GOSSIP_ENDECODE_DEBUG,"lebf_encode_req\n"); - /* every request has these fields */ + /** every request has these fields */ p = &target_msg->ptr_current; encode_PVFS_server_req(p, req); @@ -412,7 +416,7 @@ static int lebf_encode_req( switch (req->op) { - /* call standard function defined in headers */ + /** call standard function defined in headers */ CASE(PVFS_SERV_LOOKUP_PATH, lookup_path); CASE(PVFS_SERV_CREATE, create); CASE(PVFS_SERV_MIRROR, mirror); @@ -447,12 +451,13 @@ static int lebf_encode_req( CASE(PVFS_SERV_DELEATTR, deleattr); CASE(PVFS_SERV_LISTEATTR, listeattr); CASE(PVFS_SERV_LISTATTR, listattr); + CASE(PVFS_SERV_MGMT_GET_UID, mgmt_get_uid); case PVFS_SERV_GETCONFIG: case PVFS_SERV_MGMT_NOOP: case PVFS_SERV_PROTO_ERROR: case PVFS_SERV_IMM_COPIES: - /* nothing else */ + /** nothing else */ break; case PVFS_SERV_INVALID: @@ -460,7 +465,7 @@ static int lebf_encode_req( case PVFS_SERV_PERF_UPDATE: case PVFS_SERV_PRECREATE_POOL_REFILLER: case PVFS_SERV_JOB_TIMER: - case PVFS_SERV_NUM_OPS: /* sentinel */ + case PVFS_SERV_NUM_OPS: /** sentinel */ gossip_err("%s: invalid operation %d\n", __func__, req->op); ret = -PVFS_ENOSYS; break; @@ -468,7 +473,7 @@ static int lebf_encode_req( #undef CASE - /* although much more may have been allocated */ + /** although much more may have been allocated */ target_msg->total_size = target_msg->ptr_current - (char *) target_msg->buffer_list[0]; target_msg->size_list[0] = target_msg->total_size; @@ -486,7 +491,7 @@ static int lebf_encode_req( } -/* lebf_encode_resp() +/** lebf_encode_resp() * * encodes a response structure * @@ -504,7 +509,7 @@ static int lebf_encode_resp( goto out; gossip_debug(GOSSIP_ENDECODE_DEBUG,"lebf_encode_resp\n"); - /* every response has these fields */ + /** every response has these fields */ p = &target_msg->ptr_current; encode_PVFS_server_resp(p, resp); @@ -512,15 +517,15 @@ static int lebf_encode_resp( case tag: encode_PVFS_servresp_##var(p,&resp->u.var); break - /* we stand a good chance of segfaulting if we try to encode the response + /** we stand a good chance of segfaulting if we try to encode the response * after something bad happened reading data from disk. */ if (resp->status == 0) { - /* extra encoding rules for particular responses */ + /** extra encoding rules for particular responses */ switch (resp->op) { - /* call standard function defined in headers */ + /** call standard function defined in headers */ CASE(PVFS_SERV_GETCONFIG, getconfig); CASE(PVFS_SERV_LOOKUP_PATH, lookup_path); CASE(PVFS_SERV_CREATE, create); @@ -545,6 +550,7 @@ static int lebf_encode_resp( CASE(PVFS_SERV_LISTEATTR, listeattr); CASE(PVFS_SERV_LISTATTR, listattr); CASE(PVFS_SERV_TREE_GET_FILE_SIZE, tree_get_file_size); + CASE(PVFS_SERV_MGMT_GET_UID, mgmt_get_uid); case PVFS_SERV_REMOVE: case PVFS_SERV_MGMT_REMOVE_OBJECT: @@ -561,14 +567,14 @@ static int lebf_encode_resp( case PVFS_SERV_PROTO_ERROR: case PVFS_SERV_IMM_COPIES: case PVFS_SERV_MGMT_SETPARAM: - /* nothing else */ + /** nothing else */ break; case PVFS_SERV_INVALID: case PVFS_SERV_PERF_UPDATE: case PVFS_SERV_PRECREATE_POOL_REFILLER: case PVFS_SERV_JOB_TIMER: - case PVFS_SERV_NUM_OPS: /* sentinel */ + case PVFS_SERV_NUM_OPS: /** sentinel */ gossip_err("%s: invalid operation %d\n", __func__, resp->op); ret = -PVFS_ENOSYS; break; @@ -577,7 +583,7 @@ static int lebf_encode_resp( #undef CASE - /* although much more may have been allocated */ + /** although much more may have been allocated */ target_msg->total_size = target_msg->ptr_current - (char *) target_msg->buffer_list[0]; target_msg->size_list[0] = target_msg->total_size; @@ -593,7 +599,7 @@ static int lebf_encode_resp( return ret; } -/* lebf_decode_req() +/** lebf_decode_req() * * decodes a request message * @@ -615,7 +621,7 @@ static int lebf_decode_req( target_msg->buffer = req; - /* decode generic part of request (enough to get op number) */ + /** decode generic part of request (enough to get op number) */ decode_PVFS_server_req(p, req); gossip_debug(GOSSIP_ENDECODE_DEBUG,"lebf_decode_req\n"); @@ -624,7 +630,7 @@ static int lebf_decode_req( switch (req->op) { - /* call standard function defined in headers */ + /** call standard function defined in headers */ CASE(PVFS_SERV_LOOKUP_PATH, lookup_path); CASE(PVFS_SERV_CREATE, create); CASE(PVFS_SERV_MIRROR, mirror); @@ -659,11 +665,12 @@ static int lebf_decode_req( CASE(PVFS_SERV_DELEATTR, deleattr); CASE(PVFS_SERV_LISTEATTR, listeattr); CASE(PVFS_SERV_LISTATTR, listattr); + CASE(PVFS_SERV_MGMT_GET_UID, mgmt_get_uid); case PVFS_SERV_GETCONFIG: case PVFS_SERV_MGMT_NOOP: case PVFS_SERV_IMM_COPIES: - /* nothing else */ + /** nothing else */ break; case PVFS_SERV_INVALID: @@ -672,7 +679,7 @@ static int lebf_decode_req( case PVFS_SERV_PRECREATE_POOL_REFILLER: case PVFS_SERV_JOB_TIMER: case PVFS_SERV_PROTO_ERROR: - case PVFS_SERV_NUM_OPS: /* sentinel */ + case PVFS_SERV_NUM_OPS: /** sentinel */ gossip_lerr("%s: invalid operation %d.\n", __func__, req->op); ret = -PVFS_EPROTO; goto out; @@ -691,7 +698,7 @@ static int lebf_decode_req( return(ret); } -/* lebf_decode_resp() +/** lebf_decode_resp() * * decodes a response structure * @@ -710,7 +717,7 @@ static int lebf_decode_resp( target_msg->buffer = resp; - /* decode generic part of response (including op number) */ + /** decode generic part of response (including op number) */ decode_PVFS_server_resp(p, resp); gossip_debug(GOSSIP_ENDECODE_DEBUG,"lebf_decode_resp\n"); @@ -722,7 +729,7 @@ static int lebf_decode_resp( switch (resp->op) { - /* call standard function defined in headers */ + /** call standard function defined in headers */ CASE(PVFS_SERV_GETCONFIG, getconfig); CASE(PVFS_SERV_LOOKUP_PATH, lookup_path); CASE(PVFS_SERV_CREATE, create); @@ -747,6 +754,7 @@ static int lebf_decode_resp( CASE(PVFS_SERV_LISTEATTR, listeattr); CASE(PVFS_SERV_LISTATTR, listattr); CASE(PVFS_SERV_TREE_GET_FILE_SIZE, tree_get_file_size); + CASE(PVFS_SERV_MGMT_GET_UID, mgmt_get_uid); case PVFS_SERV_REMOVE: case PVFS_SERV_BATCH_REMOVE: @@ -763,14 +771,14 @@ static int lebf_decode_resp( case PVFS_SERV_PROTO_ERROR: case PVFS_SERV_IMM_COPIES: case PVFS_SERV_MGMT_SETPARAM: - /* nothing else */ + /** nothing else */ break; case PVFS_SERV_INVALID: case PVFS_SERV_PERF_UPDATE: case PVFS_SERV_PRECREATE_POOL_REFILLER: case PVFS_SERV_JOB_TIMER: - case PVFS_SERV_NUM_OPS: /* sentinel */ + case PVFS_SERV_NUM_OPS: /** sentinel */ gossip_lerr("%s: invalid operation %d.\n", __func__, resp->op); ret = -PVFS_EPROTO; goto out; @@ -789,7 +797,7 @@ static int lebf_decode_resp( return(ret); } -/* lebf_encode_rel() +/** lebf_encode_rel() * * releases resources consumed while encoding * @@ -800,7 +808,7 @@ static void lebf_encode_rel( enum PINT_encode_msg_type input_type) { gossip_debug(GOSSIP_ENDECODE_DEBUG,"lebf_encode_rel\n"); - /* just a single buffer to free */ + /** just a single buffer to free */ if (initializing_sizes) { free(msg->buffer_list[0]); @@ -812,7 +820,7 @@ static void lebf_encode_rel( } } -/* lebf_decode_rel() +/** lebf_decode_rel() * * releases resources consumed while decoding * @@ -913,6 +921,7 @@ static void lebf_decode_rel(struct PINT_decoded_msg *msg, case PVFS_SERV_MGMT_ITERATE_HANDLES: case PVFS_SERV_MGMT_PERF_MON: case PVFS_SERV_MGMT_EVENT_MON: + case PVFS_SERV_MGMT_GET_UID: case PVFS_SERV_DELEATTR: case PVFS_SERV_LISTEATTR: @@ -927,7 +936,7 @@ static void lebf_decode_rel(struct PINT_decoded_msg *msg, case PVFS_SERV_PRECREATE_POOL_REFILLER: case PVFS_SERV_JOB_TIMER: case PVFS_SERV_PROTO_ERROR: - case PVFS_SERV_NUM_OPS: /* sentinel */ + case PVFS_SERV_NUM_OPS: /** sentinel */ gossip_lerr("%s: invalid request operation %d.\n", __func__, req->op); break; @@ -1001,7 +1010,7 @@ static void lebf_decode_rel(struct PINT_decoded_msg *msg, break; case PVFS_SERV_GETEATTR: - /* need a loop here? WBL */ + /** need a loop here? WBL */ if (resp->u.geteattr.val) decode_free(resp->u.geteattr.val); break; @@ -1051,6 +1060,12 @@ static void lebf_decode_rel(struct PINT_decoded_msg *msg, break; } + case PVFS_SERV_MGMT_GET_UID: + { + decode_free(resp->u.mgmt_get_uid.uid_info_array); + break; + } + case PVFS_SERV_GETCONFIG: case PVFS_SERV_REMOVE: case PVFS_SERV_MGMT_REMOVE_OBJECT: @@ -1081,7 +1096,7 @@ static void lebf_decode_rel(struct PINT_decoded_msg *msg, case PVFS_SERV_PERF_UPDATE: case PVFS_SERV_PRECREATE_POOL_REFILLER: case PVFS_SERV_JOB_TIMER: - case PVFS_SERV_NUM_OPS: /* sentinel */ + case PVFS_SERV_NUM_OPS: /** sentinel */ gossip_lerr("%s: invalid response operation %d.\n", __func__, resp->op); break; diff --git a/src/proto/PINT-reqproto-encode.c b/src/proto/PINT-reqproto-encode.c index f2e2a9e..3e9d259 100644 --- a/src/proto/PINT-reqproto-encode.c +++ b/src/proto/PINT-reqproto-encode.c @@ -51,6 +51,7 @@ static PINT_encoding_table_values *PINT_encoding_table[ int PINT_encode_initialize(void) { int ret = -PVFS_EINVAL; + void *header = NULL; gossip_debug(GOSSIP_ENDECODE_DEBUG,"PINT_encode_initialize\n"); if (ENCODING_IS_SUPPORTED(ENCODING_LE_BFIELD)) @@ -60,10 +61,16 @@ int PINT_encode_initialize(void) le_bytefield_table.init_fun(); /* header prepended to all messages of this type */ - *((int32_t*)&(le_bytefield_table.generic_header[0])) = - htobmi32(PVFS2_PROTO_VERSION); - *((int32_t*)&(le_bytefield_table.generic_header[4])) = - htobmi32(ENCODING_LE_BFIELD); + header = &(le_bytefield_table.generic_header[0]); + *((int32_t *)header) = htobmi32(PVFS2_PROTO_VERSION); + + header = &(le_bytefield_table.generic_header[4]); + *((int32_t *)header) = htobmi32(ENCODING_LE_BFIELD); + + //*((int32_t*)&(le_bytefield_table.generic_header[0])) = + // htobmi32(PVFS2_PROTO_VERSION); + //*((int32_t*)&(le_bytefield_table.generic_header[4])) = + // htobmi32(ENCODING_LE_BFIELD); le_bytefield_table.enc_type = ENCODING_LE_BFIELD; ret = 0; diff --git a/src/proto/endecode-funcs.h b/src/proto/endecode-funcs.h index 0420ead..ca833db 100644 --- a/src/proto/endecode-funcs.h +++ b/src/proto/endecode-funcs.h @@ -14,6 +14,13 @@ #include "src/io/bmi/bmi-byteswap.h" #include +#ifdef WIN32 +typedef uint32_t u_int32_t; +typedef uint64_t u_int64_t; + +/* typeof not available on Windows */ +#define typeof(t) t +#endif #include /* @@ -87,30 +94,30 @@ #define encode_string(pptr,pbuf) do { \ u_int32_t len = 0; \ if (*pbuf) \ - len = strlen(*pbuf); \ + len = strlen(*pbuf); \ *(u_int32_t *) *(pptr) = htobmi32(len); \ if (len) { \ - memcpy(*(pptr)+4, *pbuf, len+1); \ - int pad = roundup8(4 + len + 1) - (4 + len + 1); \ - *(pptr) += roundup8(4 + len + 1); \ - memset(*(pptr)-pad, 0, pad); \ + memcpy(*(pptr)+4, *pbuf, len+1); \ + int pad = roundup8(4 + len + 1) - (4 + len + 1); \ + *(pptr) += roundup8(4 + len + 1); \ + memset(*(pptr)-pad, 0, pad); \ } else { \ - *(u_int32_t *) (*(pptr)+4) = 0; \ - *(pptr) += 8; \ + *(u_int32_t *) (*(pptr)+4) = 0; \ + *(pptr) += 8; \ } \ } while (0) #else #define encode_string(pptr,pbuf) do { \ u_int32_t len = 0; \ if (*pbuf) \ - len = strlen(*pbuf); \ + len = strlen(*pbuf); \ *(u_int32_t *) *(pptr) = htobmi32(len); \ if (len) { \ - memcpy(*(pptr)+4, *pbuf, len+1); \ - *(pptr) += roundup8(4 + len + 1); \ + memcpy(*(pptr)+4, *pbuf, len+1); \ + *(pptr) += roundup8(4 + len + 1); \ } else { \ - *(u_int32_t *) *(pptr) = 0; \ - *(pptr) += 8; \ + *(u_int32_t *) *(pptr) = 0; \ + *(pptr) += 8; \ } \ } while (0) #endif @@ -799,6 +806,17 @@ static inline void decode_##name(char **pptr, struct name *x) { int i; \ decode_##ta1(pptr, &(x)->a1[i]); \ } +#ifdef WIN32 +#define DEFINE_STATIC_ENDECODE_FUNCS(__name__, __type__) \ +static void encode_func_##__name__(char **pptr, void *x) \ +{ \ + encode_##__name__(pptr, (__type__ *)x); \ +}; \ +static void decode_func_##__name__(char **pptr, void *x) \ +{ \ + decode_##__name__(pptr, (__type__ *)x); \ +} +#else #define DEFINE_STATIC_ENDECODE_FUNCS(__name__, __type__) \ __attribute__((unused)) \ static void encode_func_##__name__(char **pptr, void *x) \ @@ -810,6 +828,7 @@ static void decode_func_##__name__(char **pptr, void *x) \ { \ decode_##__name__(pptr, (__type__ *)x); \ } +#endif #define encode_enum_union_2_struct(name, ename, uname, ut1, un1, en1, ut2, un2, en2) \ static inline void encode_##name(char **pptr, const struct name *x) \ @@ -833,5 +852,8 @@ static inline void decode_##name(char **pptr, struct name *x) \ } \ }; +#ifdef WIN32 +#endif + #endif /* __SRC_PROTO_ENDECODE_FUNCS_H */ diff --git a/src/proto/pvfs2-attr.h b/src/proto/pvfs2-attr.h index a861803..54e8563 100644 --- a/src/proto/pvfs2-attr.h +++ b/src/proto/pvfs2-attr.h @@ -28,11 +28,12 @@ #define PVFS_ATTR_COMMON_TYPE (1 << 6) #define PVFS_ATTR_COMMON_ATIME_SET (1 << 7) #define PVFS_ATTR_COMMON_MTIME_SET (1 << 8) +#define PVFS_ATTR_COMMON_CID (1 << 9) #define PVFS_ATTR_COMMON_ALL \ (PVFS_ATTR_COMMON_UID | PVFS_ATTR_COMMON_GID | \ PVFS_ATTR_COMMON_PERM | PVFS_ATTR_COMMON_ATIME | \ PVFS_ATTR_COMMON_CTIME | PVFS_ATTR_COMMON_MTIME | \ - PVFS_ATTR_COMMON_TYPE) + PVFS_ATTR_COMMON_TYPE | PVFS_ATTR_COMMON_CID) /* internal attribute masks for metadata objects */ #define PVFS_ATTR_META_DIST (1 << 10) @@ -220,6 +221,7 @@ struct PVFS_object_attr PVFS_time atime; PVFS_time mtime; PVFS_time ctime; + PVFS_handle cid; uint32_t mask; /* indicates which fields are currently valid */ PVFS_ds_type objtype; /* defined in pvfs2-types.h */ union @@ -236,6 +238,7 @@ typedef struct PVFS_object_attr PVFS_object_attr; #define encode_PVFS_object_attr(pptr,x) do { \ encode_PVFS_uid(pptr, &(x)->owner); \ encode_PVFS_gid(pptr, &(x)->group); \ + encode_PVFS_cid(pptr, &(x)->cid); \ encode_PVFS_permissions(pptr, &(x)->perms); \ encode_skip4(pptr,); \ encode_PVFS_time(pptr, &(x)->atime); \ @@ -266,6 +269,7 @@ typedef struct PVFS_object_attr PVFS_object_attr; #define decode_PVFS_object_attr(pptr,x) do { \ decode_PVFS_uid(pptr, &(x)->owner); \ decode_PVFS_gid(pptr, &(x)->group); \ + decode_PVFS_cid(pptr, &(x)->cid); \ decode_PVFS_permissions(pptr, &(x)->perms); \ decode_skip4(pptr,); \ decode_PVFS_time(pptr, &(x)->atime); \ diff --git a/src/proto/pvfs2-req-proto.h b/src/proto/pvfs2-req-proto.h index 7635154..0c4894f 100644 --- a/src/proto/pvfs2-req-proto.h +++ b/src/proto/pvfs2-req-proto.h @@ -18,6 +18,7 @@ #include "pint-request.h" #include "pvfs2-mgmt.h" #include "pint-hint.h" +#include "pint-uid-mgmt.h" /* update PVFS2_PROTO_MAJOR on wire protocol changes that break backwards * compatibility (such as changing the semantics or protocol fields for an @@ -26,8 +27,11 @@ #define PVFS2_PROTO_MAJOR 6 /* update PVFS2_PROTO_MINOR on wire protocol changes that preserve backwards * compatibility (such as adding a new request type) + * NOTE: Incrementing this will make clients unable to talk to older servers. + * Do not change until we have a new version policy. */ #define PVFS2_PROTO_MINOR 0 + #define PVFS2_PROTO_VERSION ((PVFS2_PROTO_MAJOR*1000)+(PVFS2_PROTO_MINOR)) /* we set the maximum possible size of a small I/O packed message as 64K. This @@ -83,6 +87,7 @@ enum PVFS_server_op PVFS_SERV_IMM_COPIES = 40, PVFS_SERV_TREE_REMOVE = 41, PVFS_SERV_TREE_GET_FILE_SIZE = 42, + PVFS_SERV_MGMT_GET_UID = 43, /* leave this entry last */ PVFS_SERV_NUM_OPS }; @@ -226,7 +231,7 @@ endecode_fields_2a_struct( PVFS_handle, datafile_handles); #define extra_size_PVFS_servresp_create \ (PVFS_REQ_LIMIT_HANDLES_COUNT * sizeof(PVFS_handle)) - + /* batch_create *********************************************************/ /* - used to create new multiple metafile and datafile objects */ @@ -419,20 +424,20 @@ endecode_fields_1a_struct( #define extra_size_PVFS_servreq_tree_remove \ (PVFS_REQ_LIMIT_HANDLES_COUNT * sizeof(PVFS_handle)) -#define PINT_SERVREQ_TREE_REMOVE_FILL(__req, \ - __creds, \ - __fsid, \ - __num_data_files, \ - __handle_array, \ - __hints) \ -do { \ - memset(&(__req), 0, sizeof(__req)); \ - (__req).op = PVFS_SERV_TREE_REMOVE; \ - (__req).hints = (__hints); \ - (__req).credentials = (__creds); \ - (__req).u.tree_remove.fs_id = (__fsid); \ - (__req).u.tree_remove.num_data_files = (__num_data_files); \ - (__req).u.tree_remove.handle_array = (__handle_array); \ +#define PINT_SERVREQ_TREE_REMOVE_FILL(__req, \ + __creds, \ + __fsid, \ + __num_data_files, \ + __handle_array, \ + __hints) \ +do { \ + memset(&(__req), 0, sizeof(__req)); \ + (__req).op = PVFS_SERV_TREE_REMOVE; \ + (__req).hints = (__hints); \ + (__req).credentials = (__creds); \ + (__req).u.tree_remove.fs_id = (__fsid); \ + (__req).u.tree_remove.num_data_files = (__num_data_files); \ + (__req).u.tree_remove.handle_array = (__handle_array); \ } while (0) struct PVFS_servreq_tree_get_file_size @@ -453,24 +458,26 @@ endecode_fields_3a_struct( #define extra_size_PVFS_servreq_tree_get_file_size \ (PVFS_REQ_LIMIT_HANDLES_COUNT * sizeof(PVFS_handle)) -#define PINT_SERVREQ_TREE_GET_FILE_SIZE_FILL(__req, \ - __creds, \ - __fsid, \ - __caller_handle_index, \ - __num_data_files, \ - __handle_array, \ - __retry_msgpair_at_leaf, \ - __hints) \ -do { \ - memset(&(__req), 0, sizeof(__req)); \ - (__req).op = PVFS_SERV_TREE_GET_FILE_SIZE; \ - (__req).hints = (__hints); \ - (__req).credentials = (__creds); \ - (__req).u.tree_get_file_size.fs_id = (__fsid); \ - (__req).u.tree_get_file_size.caller_handle_index = (__caller_handle_index); \ - (__req).u.tree_get_file_size.num_data_files = (__num_data_files); \ - (__req).u.tree_get_file_size.handle_array = (__handle_array); \ - (__req).u.tree_get_file_size.retry_msgpair_at_leaf = (__retry_msgpair_at_leaf);\ +#define PINT_SERVREQ_TREE_GET_FILE_SIZE_FILL(__req, \ + __creds, \ + __fsid, \ + __caller_handle_index, \ + __num_data_files, \ + __handle_array, \ + __retry_msgpair_at_leaf, \ + __hints) \ +do { \ + memset(&(__req), 0, sizeof(__req)); \ + (__req).op = PVFS_SERV_TREE_GET_FILE_SIZE; \ + (__req).hints = (__hints); \ + (__req).credentials = (__creds); \ + (__req).u.tree_get_file_size.fs_id = (__fsid); \ + (__req).u.tree_get_file_size.caller_handle_index = \ + (__caller_handle_index); \ + (__req).u.tree_get_file_size.num_data_files = (__num_data_files); \ + (__req).u.tree_get_file_size.handle_array = (__handle_array); \ + (__req).u.tree_get_file_size.retry_msgpair_at_leaf = \ + (__retry_msgpair_at_leaf);\ } while (0) struct PVFS_servresp_tree_get_file_size @@ -644,12 +651,13 @@ struct PVFS_servreq_setattr PVFS_handle handle; /* handle of target object */ PVFS_fs_id fs_id; /* file system */ PVFS_object_attr attr; /* new attributes */ + PVFS_handle cid; }; endecode_fields_4_struct( PVFS_servreq_setattr, PVFS_handle, handle, PVFS_fs_id, fs_id, - skip4,, + PVFS_handle, cid, PVFS_object_attr, attr); #define extra_size_PVFS_servreq_setattr \ extra_size_PVFS_object_attr @@ -669,6 +677,7 @@ do { \ (__req).hints = (__hints); \ (__req).u.setattr.fs_id = (__fsid); \ (__req).u.setattr.handle = (__handle); \ + (__req).u.setattr.cid = (__attr).cid; \ (__attr).objtype = (__objtype); \ (__attr).mask |= PVFS_ATTR_SYS_TYPE; \ PINT_CONVERT_ATTR(&(__req).u.setattr.attr, &(__attr), __extra_amask);\ @@ -1013,6 +1022,7 @@ struct PVFS_servreq_mirror #ifdef __PINT_REQPROTO_ENCODE_FUNCS_C #define encode_PVFS_servreq_mirror(pptr,x) do { \ + int i; \ encode_PVFS_handle(pptr,&(x)->src_handle); \ encode_PVFS_fs_id(pptr,&(x)->fs_id); \ encode_PINT_dist(pptr,&(x)->dist); \ @@ -1021,7 +1031,6 @@ struct PVFS_servreq_mirror encode_uint32_t(pptr,&(x)->dst_count); \ encode_enum(pptr,&(x)->flow_type); \ encode_enum(pptr,&(x)->encoding); \ - int i; \ for (i=0; i<(x)->dst_count; i++) \ { \ encode_PVFS_handle(pptr,&(x)->dst_handle[i]); \ @@ -1030,6 +1039,7 @@ struct PVFS_servreq_mirror } while (0) #define decode_PVFS_servreq_mirror(pptr,x) do { \ + int i; \ decode_PVFS_handle(pptr,&(x)->src_handle); \ decode_PVFS_fs_id(pptr,&(x)->fs_id); \ decode_PINT_dist(pptr,&(x)->dist); \ @@ -1042,7 +1052,6 @@ struct PVFS_servreq_mirror sizeof(PVFS_handle)); \ (x)->wcIndex = decode_malloc((x)->dst_count * \ sizeof(uint32_t)); \ - int i; \ for (i=0; i<(x)->dst_count; i++) \ { \ decode_PVFS_handle(pptr,&(x)->dst_handle[i]); \ @@ -1069,10 +1078,10 @@ struct PVFS_servresp_mirror #ifdef __PINT_REQPROTO_ENCODE_FUNCS_C #define encode_PVFS_servresp_mirror(pptr,x) do { \ + int i; \ encode_PVFS_handle(pptr,&(x)->src_handle); \ encode_uint32_t(pptr,&(x)->src_server_nr); \ encode_uint32_t(pptr,&(x)->dst_count); \ - int i; \ for (i=0; i<(x)->dst_count; i++) \ { \ encode_uint32_t(pptr,&(x)->bytes_written[i]); \ @@ -1081,6 +1090,7 @@ struct PVFS_servresp_mirror } while (0) #define decode_PVFS_servresp_mirror(pptr,x) do { \ + int i; \ decode_PVFS_handle(pptr,&(x)->src_handle); \ decode_uint32_t(pptr,&(x)->src_server_nr); \ decode_uint32_t(pptr,&(x)->dst_count); \ @@ -1088,7 +1098,6 @@ struct PVFS_servresp_mirror sizeof(uint32_t)); \ (x)->write_status_code = decode_malloc((x)->dst_count * \ sizeof(uint32_t)); \ - int i; \ for (i=0; i<(x)->dst_count; i++ ) \ { \ decode_uint32_t(pptr,&(x)->bytes_written[i]); \ @@ -1541,45 +1550,49 @@ do { \ struct PVFS_servreq_mgmt_perf_mon { uint32_t next_id; /* next time stamp id we want to retrieve */ + uint32_t key_count; /* how many counters per measurements we want */ uint32_t count; /* how many measurements we want */ }; -endecode_fields_2_struct( +endecode_fields_3_struct( PVFS_servreq_mgmt_perf_mon, uint32_t, next_id, + uint32_t, key_count, uint32_t, count); -#define PINT_SERVREQ_MGMT_PERF_MON_FILL(__req, \ - __creds, \ - __next_id,\ - __count, \ - __hints) \ -do { \ - memset(&(__req), 0, sizeof(__req)); \ - (__req).op = PVFS_SERV_MGMT_PERF_MON; \ - (__req).credentials = (__creds); \ - (__req).hints = (__hints); \ - (__req).u.mgmt_perf_mon.next_id = (__next_id);\ - (__req).u.mgmt_perf_mon.count = (__count); \ +#define PINT_SERVREQ_MGMT_PERF_MON_FILL(__req, \ + __creds, \ + __next_id, \ + __key_count, \ + __count, \ + __hints) \ +do { \ + memset(&(__req), 0, sizeof(__req)); \ + (__req).op = PVFS_SERV_MGMT_PERF_MON; \ + (__req).credentials = (__creds); \ + (__req).hints = (__hints); \ + (__req).u.mgmt_perf_mon.next_id = (__next_id); \ + (__req).u.mgmt_perf_mon.key_count = (__key_count);\ + (__req).u.mgmt_perf_mon.count = (__count); \ } while (0) struct PVFS_servresp_mgmt_perf_mon { - struct PVFS_mgmt_perf_stat* perf_array; /* array of statistics */ - uint32_t perf_array_count; /* size of above array */ - /* next id to pick up from this point */ - uint32_t suggested_next_id; - uint64_t end_time_ms; /* end time for final array entry */ - uint64_t cur_time_ms; /* current time according to svr */ + int64_t *perf_array; /* array of statistics */ + uint32_t perf_array_count; /* size of above array */ + uint32_t key_count; /* number of keys in each sample */ + uint32_t suggested_next_id; /* next id to pick up from this point */ + uint64_t end_time_ms; /* end time for final array entry */ + uint64_t cur_time_ms; /* current time according to svr */ }; endecode_fields_5a_struct( PVFS_servresp_mgmt_perf_mon, + uint32_t, key_count, uint32_t, suggested_next_id, - skip4,, uint64_t, end_time_ms, uint64_t, cur_time_ms, skip4,, uint32_t, perf_array_count, - PVFS_mgmt_perf_stat, perf_array); + int64_t, perf_array); #define extra_size_PVFS_servresp_mgmt_perf_mon \ (PVFS_REQ_LIMIT_IOREQ_BYTES) @@ -1910,6 +1923,43 @@ endecode_fields_2a_struct( #define extra_size_PVFS_servresp_listeattr \ (PVFS_REQ_LIMIT_EATTR_KEY_LEN * PVFS_REQ_LIMIT_EATTR_LIST) +/* mgmt_get_uid ****************************************************/ +/* retrieves uid managment history from server */ + +struct PVFS_servreq_mgmt_get_uid +{ + uint32_t history; /* number of seconds we want to go back + when retrieving the uid history */ +}; +endecode_fields_1_struct( + PVFS_servreq_mgmt_get_uid, + uint32_t, history); + +#define PINT_SERVREQ_MGMT_GET_UID_FILL(__req, \ + __creds, \ + __history, \ + __hints) \ +do { \ + memset(&(__req), 0, sizeof(__req)); \ + (__req).op = PVFS_SERV_MGMT_GET_UID; \ + (__req).credentials = (__creds); \ + (__req).hints = (__hints); \ + (__req).u.mgmt_get_uid.history = (__history); \ +} while (0) + +struct PVFS_servresp_mgmt_get_uid +{ + PVFS_uid_info_s *uid_info_array; /* array of uid info */ + uint32_t uid_info_array_count; /* size of above array */ +}; +endecode_fields_1a_struct( + PVFS_servresp_mgmt_get_uid, + skip4,, + uint32_t, uid_info_array_count, + PVFS_uid_info_s, uid_info_array); + +#define extra_size_PVFS_servresp_mgmt_get_uid \ + UID_MGMT_MAX_HISTORY * sizeof(PVFS_uid_info_s) /* server request *********************************************/ /* - generic request with union of all op specific structs */ @@ -1956,6 +2006,7 @@ struct PVFS_server_req struct PVFS_servreq_listattr listattr; struct PVFS_servreq_tree_remove tree_remove; struct PVFS_servreq_tree_get_file_size tree_get_file_size; + struct PVFS_servreq_mgmt_get_uid mgmt_get_uid; } u; }; #ifdef __PINT_REQPROTO_ENCODE_FUNCS_C @@ -2011,6 +2062,7 @@ struct PVFS_server_resp struct PVFS_servresp_small_io small_io; struct PVFS_servresp_listattr listattr; struct PVFS_servresp_tree_get_file_size tree_get_file_size; + struct PVFS_servresp_mgmt_get_uid mgmt_get_uid; } u; }; endecode_fields_2_struct( diff --git a/src/server/create-immutable-copies.sm b/src/server/create-immutable-copies.sm index deec471..1248aff 100644 --- a/src/server/create-immutable-copies.sm +++ b/src/server/create-immutable-copies.sm @@ -25,6 +25,7 @@ /*all bits turned on*/ static uint64_t UINT64_HIGH = 0xffffffffffffffffULL; + /*attribute keys used for the mirroring process*/ static char handle_key[] = USER_PVFS2_MIRROR_HANDLES; static char copy_count_key[] = USER_PVFS2_MIRROR_COPIES; @@ -61,9 +62,9 @@ enum { /*prototypes*/ static int mirror_comp_fn( - void *v_p - ,struct PVFS_server_resp *resp_p - ,int i); + void *v_p, + struct PVFS_server_resp *resp_p, + int i); static PVFS_handle *reorganize_copy_handles( struct PINT_server_create_copies_op *imm_p); @@ -160,10 +161,10 @@ nested machine pvfs2_create_immutable_copies_sm state store_mirror_info { run store_mirror_info; - /*default => replace_remote_datahandle_objects;*/ - /*If the write of the datahandle information fails, even though the */ - /*the copies actually exist, the metadata for the logical file will */ - /*NOT have knowledge of it. */ + /* default => replace_remote_datahandle_objects; + * If the write of the datahandle information fails, even though the + * the copies actually exist, the metadata for the logical file will + * NOT have knowledge of it. */ default => check_store_job; } @@ -196,15 +197,15 @@ nested machine pvfs2_create_immutable_copies_sm %% -/************************************************************************/ -/*Actions for pvfs2_create_immutable_copies_sm */ -/************************************************************************/ -static PINT_sm_action initialize_structures (struct PINT_smcb *smcb - ,job_status_s *js_p) +/* Actions for pvfs2_create_immutable_copies_sm */ +static PINT_sm_action initialize_structures ( struct PINT_smcb *smcb, + job_status_s *js_p) { - gossip_debug(GOSSIP_MIRROR_DEBUG,"Executing initialize_structures....\n"); - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tframe count is %d.\n",smcb->frame_count); - gossip_debug(GOSSIP_MIRROR_DEBUG,"\t base frame is %d.\n",smcb->base_frame); + gossip_debug(GOSSIP_MIRROR_DEBUG, "Executing initialize_structures....\n"); + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tframe count is %d.\n", + smcb->frame_count); + gossip_debug(GOSSIP_MIRROR_DEBUG, "\t base frame is %d.\n", + smcb->base_frame); struct PINT_server_op *s_op = PINT_sm_frame(smcb,PINT_FRAME_CURRENT); PINT_server_create_copies_op *imm_p = &(s_op->u.create_copies); @@ -213,139 +214,142 @@ static PINT_sm_action initialize_structures (struct PINT_smcb *smcb js_p->error_code = 0; - /* These values are generated by default when the prelude executes. */ - /* When seteattr executes, the prelude retrieves the common metadata info. */ + + + /* These values are generated by default when the prelude executes. + * When seteattr executes, the prelude retrieves the common metadata info. */ imm_p->dfile_count = s_op->target_object_attr->u.meta.dfile_count; imm_p->metadata_handle = s_op->target_handle; imm_p->fs_id = s_op->target_fs_id; /* Get the number of IO servers currently running for the given filesystem */ - ret = PINT_cached_config_get_num_io(imm_p->fs_id,&(imm_p->io_servers_count)); + ret = PINT_cached_config_get_num_io(imm_p->fs_id, + &(imm_p->io_servers_count)); if (ret) { js_p->error_code = ret; return SM_ACTION_COMPLETE; } - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tdfile_count: %d\tmetadata_handle: %llu" - "\tfs_id: %u" - "\tio_servers_count: %d\n" - ,imm_p->dfile_count - ,llu(imm_p->metadata_handle) - ,imm_p->fs_id - ,imm_p->io_servers_count ); - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tds_attr.b_size:%d\n" - ,(int)s_op->ds_attr.u.datafile.b_size); + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tdfile_count: %d\tmetadata_handle: %llu" + "\tfs_id: %u" + "\tio_servers_count: %d\n", + imm_p->dfile_count, + llu(imm_p->metadata_handle), + imm_p->fs_id, + imm_p->io_servers_count ); + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tds_attr.b_size:%d\n", + (int)s_op->ds_attr.u.datafile.b_size); return SM_ACTION_COMPLETE; -} /*end action initialize_structures*/ +} /* end action initialize_structures */ -static PINT_sm_action obtain_source_info (struct PINT_smcb *smcb - ,job_status_s *js_p) +static PINT_sm_action obtain_source_info (struct PINT_smcb *smcb, + job_status_s *js_p) { - /*In this state, we are retrieving the data handles, the number of */ - /*desired copies, and the mirroring mode for the given meta data handle.*/ - /*If the mirroring mode == NO_MIRRORING, then we will not perform the */ - /*mirror operation. */ - gossip_debug(GOSSIP_MIRROR_DEBUG,"Executing obtain_source_info....\n"); - - struct PINT_server_op *sm_p = PINT_sm_frame(smcb,PINT_FRAME_CURRENT); - PINT_server_create_copies_op *imm_p = &(sm_p->u.create_copies); - int keyval_count = 3; - job_id_t job_id; - int ret = 0,i; - - js_p->error_code = 0; - - /*allocate space to retrieve attributes from trove.*/ - sm_p->keyval_count = keyval_count; - - sm_p->key_a = malloc(sizeof(*sm_p->key_a) * sm_p->keyval_count); - sm_p->val_a = malloc(sizeof(*sm_p->val_a) * sm_p->keyval_count); - sm_p->error_a = malloc(sizeof(*sm_p->error_a) * sm_p->keyval_count); - if (!sm_p->key_a || !sm_p->val_a || !sm_p->error_a) + /* In this state, we are retrieving the data handles, the number of + * desired copies, and the mirroring mode for the given meta data handle. + * If the mirroring mode == NO_MIRRORING, then we will not perform the + * mirror operation. */ + gossip_debug(GOSSIP_MIRROR_DEBUG,"Executing obtain_source_info....\n"); + + struct PINT_server_op *sm_p = PINT_sm_frame(smcb,PINT_FRAME_CURRENT); + PINT_server_create_copies_op *imm_p = &(sm_p->u.create_copies); + int keyval_count = 3; + job_id_t job_id; + int ret = 0,i; + + js_p->error_code = 0; + + /* allocate space to retrieve attributes from trove. */ + sm_p->keyval_count = keyval_count; + + sm_p->key_a = malloc(sizeof(*sm_p->key_a) * sm_p->keyval_count); + sm_p->val_a = malloc(sizeof(*sm_p->val_a) * sm_p->keyval_count); + sm_p->error_a = malloc(sizeof(*sm_p->error_a) * sm_p->keyval_count); + if (!sm_p->key_a || !sm_p->val_a || !sm_p->error_a) goto error_exit; - memset(sm_p->key_a , 0, sizeof(*sm_p->key_a) * sm_p->keyval_count); - memset(sm_p->val_a , 0, sizeof(*sm_p->val_a) * sm_p->keyval_count); - memset(sm_p->error_a, 0, sizeof(*sm_p->error_a) * sm_p->keyval_count); - - /*setup key/val to retreive the mirroring mode*/ - i=0; assert(ikey_a[i].buffer = mode_key; - sm_p->key_a[i].buffer_sz = sizeof(mode_key); - - sm_p->val_a[i].buffer = &(imm_p->mirror_mode); - sm_p->val_a[i].buffer_sz = sizeof(imm_p->mirror_mode); - - - /*setup key/val to retreive the datahandles*/ - i++; assert(ikey_a[i].buffer = Trove_Common_Keys[METAFILE_HANDLES_KEY].key; - sm_p->key_a[i].buffer_sz = Trove_Common_Keys[METAFILE_HANDLES_KEY].size; - - imm_p->handle_array_base = malloc(imm_p->dfile_count * sizeof(PVFS_handle)); - if (!imm_p->handle_array_base) - goto error_exit; - sm_p->val_a[i].buffer = imm_p->handle_array_base; - sm_p->val_a[i].buffer_sz = (imm_p->dfile_count * sizeof(PVFS_handle)); - - /*setup key/val to retreive the number of copies*/ - i++; assert(ikey_a[i].buffer = copy_count_key; - sm_p->key_a[i].buffer_sz = sizeof(copy_count_key); - - sm_p->val_a[i].buffer = &(imm_p->copies); - sm_p->val_a[i].buffer_sz = sizeof(imm_p->copies); - - -/***** don't need to get file's distriubtion information, because we are */ -/***** copying each datahandle, as is, directly into a new datahandle. */ -/***** Distribution is only needed when you are modifying the logical */ -/***** file, not the individual data handles. However, we need to pro- */ -/***** vide a distribution value for the IO request, even though it won't*/ -/***** be used. So, instead of issuing a trove call to get the file's */ -/***** distribution information, we will be using just the "basic" dis- */ -/***** tribution. */ - - imm_p->dist = malloc(sizeof(PINT_dist)); - if (!imm_p->dist) - goto error_exit; - memset(imm_p->dist,0,sizeof(PINT_dist)); - - imm_p->dist->dist_name = malloc(PVFS_DIST_BASIC_NAME_SIZE); - if (!imm_p->dist->dist_name) - goto error_exit; - strcpy(imm_p->dist->dist_name,PVFS_DIST_BASIC_NAME); - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tdistribution name:%s\n" - ,imm_p->dist->dist_name); - - ret = PINT_dist_lookup(imm_p->dist); - if (ret) - { - gossip_lerr("Error looking up basic distribution:%d",ret); - js_p->error_code = ret; - goto error_exit; - } + memset(sm_p->key_a, 0, sizeof(*sm_p->key_a) * sm_p->keyval_count); + memset(sm_p->val_a, 0, sizeof(*sm_p->val_a) * sm_p->keyval_count); + memset(sm_p->error_a, 0, sizeof(*sm_p->error_a) * sm_p->keyval_count); + + /* setup key/val to retreive the mirroring mode */ + i=0; + assert(ikey_a[i].buffer = mode_key; + sm_p->key_a[i].buffer_sz = sizeof(mode_key); + + sm_p->val_a[i].buffer = &(imm_p->mirror_mode); + sm_p->val_a[i].buffer_sz = sizeof(imm_p->mirror_mode); + + /* setup key/val to retreive the datahandles */ + i++; assert(ikey_a[i].buffer = Trove_Common_Keys[METAFILE_HANDLES_KEY].key; + sm_p->key_a[i].buffer_sz = Trove_Common_Keys[METAFILE_HANDLES_KEY].size; + + imm_p->handle_array_base = malloc(imm_p->dfile_count * sizeof(PVFS_handle)); + if (!imm_p->handle_array_base) + goto error_exit; + sm_p->val_a[i].buffer = imm_p->handle_array_base; + sm_p->val_a[i].buffer_sz = (imm_p->dfile_count * sizeof(PVFS_handle)); + + /* setup key/val to retreive the number of copies */ + i++; assert(ikey_a[i].buffer = copy_count_key; + sm_p->key_a[i].buffer_sz = sizeof(copy_count_key); + + sm_p->val_a[i].buffer = &(imm_p->copies); + sm_p->val_a[i].buffer_sz = sizeof(imm_p->copies); + + + /* don't need to get file's distriubtion information, because we are + * copying each datahandle, as is, directly into a new datahandle. + * Distribution is only needed when you are modifying the logical + * file, not the individual data handles. However, we need to provide + * a distribution value for the IO request, even though it won't + * be used. So, instead of issuing a trove call to get the file's + * distribution information, we will be using just the "basic" + * distribution. */ + + imm_p->dist = malloc(sizeof(PINT_dist)); + if (!imm_p->dist) + goto error_exit; + memset(imm_p->dist,0,sizeof(PINT_dist)); + + imm_p->dist->dist_name = malloc(PVFS_DIST_BASIC_NAME_SIZE); + if (!imm_p->dist->dist_name) + goto error_exit; + strcpy(imm_p->dist->dist_name,PVFS_DIST_BASIC_NAME); + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tdistribution name:%s\n", + imm_p->dist->dist_name); + + ret = PINT_dist_lookup(imm_p->dist); + if (ret) + { + gossip_lerr("Error looking up basic distribution:%d", ret); + js_p->error_code = ret; + goto error_exit; + } - /*retrieve key/val pairs */ - ret = job_trove_keyval_read_list( imm_p->fs_id - ,imm_p->metadata_handle - ,sm_p->key_a - ,sm_p->val_a - ,sm_p->error_a - ,sm_p->keyval_count - ,0 - ,NULL - ,smcb - ,0 - ,js_p - ,&job_id - ,server_job_context - ,NULL ); + /* retrieve key/val pairs */ + ret = job_trove_keyval_read_list( imm_p->fs_id, + imm_p->metadata_handle, + sm_p->key_a, + sm_p->val_a, + sm_p->error_a, + sm_p->keyval_count, + 0, + NULL, + smcb, + 0, + js_p, + &job_id, + server_job_context, + NULL ); return (ret); error_exit: @@ -355,7 +359,7 @@ error_exit: free (sm_p->val_a); if (sm_p->error_a) free(sm_p->error_a); - sm_p->key_a = sm_p->val_a = NULL; + sm_p->key_a = sm_p->val_a = NULL; sm_p->error_a = NULL; if (imm_p->dist && imm_p->dist->dist_name) @@ -367,1746 +371,1744 @@ error_exit: if (js_p->error_code == 0) js_p->error_code = -PVFS_ENOMEM; return SM_ACTION_COMPLETE; -}/*end action obtain_source_info*/ - - - +} /* end action obtain_source_info */ -static PINT_sm_action inspect_source_info (struct PINT_smcb *smcb - ,job_status_s *js_p) +static PINT_sm_action inspect_source_info (struct PINT_smcb *smcb, + job_status_s *js_p) { - gossip_debug(GOSSIP_MIRROR_DEBUG,"Executing inspect_source_info....\n"); + gossip_debug(GOSSIP_MIRROR_DEBUG,"Executing inspect_source_info....\n"); - struct PINT_server_op *sm_p = PINT_sm_frame(smcb,PINT_FRAME_CURRENT); - PINT_server_create_copies_op *imm_p = &(sm_p->u.create_copies); - char server_name[SERVER_NAME_MAX] = {0}; - server_configuration_s *config = get_server_config_struct(); - int ret = 0; - int i,j; - - /*check error codes from previous trove read-list call. */ - for (i=0; ikeyval_count; i++) - { - /*if the mirroring mode has no entry, the mode=NO_MIRRORING, or the mode*/ - /*is not the expected mode, then there is nothing to do. */ - if (sm_p->key_a[i].buffer == mode_key) - { - if (PVFS_get_errno_mapping(sm_p->error_a[i]) == ENOENT) - { - js_p->error_code = NOTHING_TO_DO; - goto error_exit; - } - imm_p->mirror_mode = *(MIRROR_MODE *)sm_p->val_a[i].buffer; - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tRetrieved mirroring mode is %d.\n" - ,imm_p->mirror_mode); - if (imm_p->mirror_mode == NO_MIRRORING || - imm_p->mirror_mode != imm_p->expected_mirror_mode) - { - js_p->error_code = NOTHING_TO_DO; - goto error_exit; - } - } - - /*if the user hasn't set the number of copies, this code will */ - /*set a default (currently = 1). */ - if (sm_p->key_a[i].buffer == copy_count_key) - { - if (PVFS_get_errno_mapping(sm_p->error_a[i]) == ENOENT) - { - gossip_lerr("User-defined number of copies not found. " - "Defaulting number of copies to %d.\n" - ,DEFAULT_COPIES); - imm_p->copies = DEFAULT_COPIES; - continue; - } - } - - /*check for other types of errors.*/ - if (sm_p->error_a[i]) - { - gossip_lerr("Error retrieving value for '%s' : %s\n" - ,(char *)sm_p->key_a[i].buffer - ,strerror(PVFS_get_errno_mapping(-sm_p->error_a[i]))); - js_p->error_code = sm_p->error_a[i]; - goto error_exit; - } - }/*end for*/ - - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tRetrieved # of copies:%d\n" - ,imm_p->copies); - - /*If there is only one server running, then it makes no sense to create */ - /*copies on the same server. */ - if (imm_p->io_servers_count == 1) - { - gossip_lerr("Mirroring operation is not permitted when only one " - "I/O server is running.\n"); - js_p->error_code = -PVFS_EPERM; - return SM_ACTION_COMPLETE; - } + struct PINT_server_op *sm_p = PINT_sm_frame(smcb,PINT_FRAME_CURRENT); + PINT_server_create_copies_op *imm_p = &(sm_p->u.create_copies); + char server_name[SERVER_NAME_MAX] = {0}; + server_configuration_s *config = get_server_config_struct(); + int ret = 0; + int i; - /* We need at least (# of copies) + 1 I/O servers running in the system to */ - /* prevent duplicate data on any one server, while not exceeding the number*/ - /* of I/O servers in the system. If the number of copies requested by the */ - /* user is >= the number of I/O servers in the system, then we lower the */ - /* number of requested copies. We then set the number of I/O servers */ - /* required to meet this request with the (new value of copies) + 1. */ - /* At this point, if the number of I/O servers required is less than the */ - /* number of servers in this file's distribution, then set the number of */ - /* required I/O servers to the same number of servers in this file's dis- */ - /* tribution. */ - if (imm_p->copies >= imm_p->io_servers_count) - imm_p->copies = imm_p->io_servers_count - 1; - - imm_p->io_servers_required = imm_p->copies + 1; - - if (imm_p->io_servers_required < imm_p->dfile_count) - imm_p->io_servers_required = imm_p->dfile_count; - - /*allocate space for io_servers array. this array will contain the server */ - /*names which will be used as the valid destination remotes for the copies.*/ - imm_p->io_servers = malloc( imm_p->io_servers_required * sizeof(char *) ); - if ( !imm_p->io_servers ) - { - js_p->error_code = -PVFS_ENOMEM; - goto error_exit; - } - memset(imm_p->io_servers,0,imm_p->io_servers_required * sizeof(char *)); - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tAllocated char *:\n"); - for (i=0; iio_servers_required; i++) - gossip_debug(GOSSIP_MIRROR_DEBUG,"\t io_servers[%d] : %p " - "\t &io_servers[%d] : %p\n" - ,i,imm_p->io_servers[i] - ,i,&(imm_p->io_servers[i])); - imm_p->num_io_servers = imm_p->io_servers_required; - for (i=0;iio_servers_required;i++) - { - imm_p->io_servers[i] = malloc( sizeof(server_name) ); - if ( !imm_p->io_servers[i] ) - { - js_p->error_code = -PVFS_ENOMEM; - goto error_exit; - } - memset(imm_p->io_servers[i],0,sizeof(server_name)); - } - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tAllocated server_name..\n"); - for (i=0; iio_servers_required; i++) - gossip_debug(GOSSIP_MIRROR_DEBUG,"\t io_servers[%d] : %p " - "\t *io_servers[%d] : %s " - "\t &io_servers[%d] : %p\n" - ,i,imm_p->io_servers[i] - ,i,imm_p->io_servers[i] - ,i,&(imm_p->io_servers[i])); + /* check error codes from previous trove read-list call. */ + for (i=0; ikeyval_count; i++) + { + /* if the mirroring mode has no entry, the mode=NO_MIRRORING, or the + * mode is not the expected mode, then there is nothing to do. */ + if (sm_p->key_a[i].buffer == mode_key) + { + if (PVFS_get_errno_mapping(sm_p->error_a[i]) == ENOENT) + { + js_p->error_code = NOTHING_TO_DO; + goto error_exit; + } + imm_p->mirror_mode = *(MIRROR_MODE *)sm_p->val_a[i].buffer; + gossip_debug(GOSSIP_MIRROR_DEBUG, + "\tRetrieved mirroring mode is %d.\n", + imm_p->mirror_mode); + if (imm_p->mirror_mode == NO_MIRRORING || + imm_p->mirror_mode != imm_p->expected_mirror_mode) + { + js_p->error_code = NOTHING_TO_DO; + goto error_exit; + } + } + /* if the user hasn't set the number of copies, this code will + * set a default (currently = 1). */ + if (sm_p->key_a[i].buffer == copy_count_key) + { + if (PVFS_get_errno_mapping(sm_p->error_a[i]) == ENOENT) + { + gossip_lerr("User-defined number of copies not found. " + "Defaulting number of copies to %d.\n", + DEFAULT_COPIES); + imm_p->copies = DEFAULT_COPIES; + continue; + } + } + /* check for other types of errors. */ + if (sm_p->error_a[i]) + { + gossip_lerr("Error retrieving value for '%s' : %s\n", + (char *)sm_p->key_a[i].buffer, + strerror(PVFS_get_errno_mapping(-sm_p->error_a[i]))); + js_p->error_code = sm_p->error_a[i]; + goto error_exit; + } + } /* end for */ - /*allocate space for the local source handles*/ - imm_p->handle_array_base_local = - malloc(imm_p->dfile_count * sizeof(PVFS_handle)); - if (!imm_p->handle_array_base_local) - { - js_p->error_code = -PVFS_ENOMEM; - goto error_exit; - } - memset(imm_p->handle_array_base_local - ,0 - ,imm_p->dfile_count * sizeof(PVFS_handle)); - imm_p->handle_array_base_local_count = 0; - - - /*allocate space for the data handle copies array, which will hold a */ - /*combination of local and remote data handles used as destination handles */ - /*for the copies. The order of this array will mimmick the order of the */ - /*original data file array. Thus, handle_array_base[i] */ - /*and handle_array_copies[i] will hold handles for the same server number. */ - imm_p->handle_array_copies = malloc(imm_p->io_servers_required - * imm_p->copies - * sizeof(PVFS_handle)); - if ( !imm_p->handle_array_copies ) - { - js_p->error_code = -PVFS_ENOMEM; - goto error_exit; - } - memset(imm_p->handle_array_copies,0,imm_p->io_servers_required - * imm_p->copies - * sizeof(PVFS_handle)); - - /*allocate space for the local_io_servers array. this array contains the */ - /*server names for local data handles. */ - imm_p->local_io_servers = malloc( imm_p->io_servers_required - * sizeof(char *)); - if ( !imm_p->local_io_servers ) - { - js_p->error_code = -PVFS_ENOMEM; - goto error_exit; + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tRetrieved # of copies:%d\n", + imm_p->copies); - } - memset(imm_p->local_io_servers - ,0 - ,imm_p->io_servers_required * sizeof(char *)); - imm_p->local_io_servers_count = 0; + /* If there is only one server running, then it makes no sense to create + * copies on the same server. */ + if (imm_p->io_servers_count == 1) + { + gossip_lerr("Mirroring operation is not permitted when only one " + "I/O server is running.\n"); + js_p->error_code = -PVFS_EPERM; + return SM_ACTION_COMPLETE; + } + /* We need at least (# of copies) + 1 I/O servers running in the system to + * prevent duplicate data on any one server, while not exceeding the number + * of I/O servers in the system. If the number of copies requested by the + * user is >= the number of I/O servers in the system, then we lower the + * number of requested copies. We then set the number of I/O servers + * required to meet this request with the (new value of copies) + 1. + * At this point, if the number of I/O servers required is less than the + * number of servers in this file's distribution, then set the number of + * required I/O servers to the same number of servers in this file's + * distribution. */ + if (imm_p->copies >= imm_p->io_servers_count) + imm_p->copies = imm_p->io_servers_count - 1; + + imm_p->io_servers_required = imm_p->copies + 1; + + if (imm_p->io_servers_required < imm_p->dfile_count) + imm_p->io_servers_required = imm_p->dfile_count; + + /* allocate space for io_servers array. this array will contain the + * server names which will be used as the valid destination remotes for the + * copies. */ + imm_p->io_servers = malloc( imm_p->io_servers_required * sizeof(char *) ); + if ( !imm_p->io_servers ) + { + js_p->error_code = -PVFS_ENOMEM; + goto error_exit; + } + memset(imm_p->io_servers,0,imm_p->io_servers_required * sizeof(char *)); + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tAllocated char *:\n"); + for (i=0; iio_servers_required; i++) + { + gossip_debug(GOSSIP_MIRROR_DEBUG, "\t io_servers[%d] : %p " + "\t &io_servers[%d] : %p\n", + i, imm_p->io_servers[i], + i, &(imm_p->io_servers[i])); + } + imm_p->num_io_servers = imm_p->io_servers_required; + for (i=0;iio_servers_required;i++) + { + imm_p->io_servers[i] = malloc( sizeof(server_name) ); + if ( !imm_p->io_servers[i] ) + { + js_p->error_code = -PVFS_ENOMEM; + goto error_exit; + } + memset(imm_p->io_servers[i],0,sizeof(server_name)); + } + + gossip_debug(GOSSIP_MIRROR_DEBUG,"\tAllocated server_name..\n"); + for (i=0; iio_servers_required; i++) + gossip_debug(GOSSIP_MIRROR_DEBUG, "\t io_servers[%d] : %p " + "\t *io_servers[%d] : %s " + "\t &io_servers[%d] : %p\n", + i, imm_p->io_servers[i], + i, imm_p->io_servers[i], + i, &(imm_p->io_servers[i])); + + /* allocate space for the local source handles */ + imm_p->handle_array_base_local = + malloc(imm_p->dfile_count * sizeof(PVFS_handle)); + if (!imm_p->handle_array_base_local) + { + js_p->error_code = -PVFS_ENOMEM; + goto error_exit; + } + memset(imm_p->handle_array_base_local, 0 , + imm_p->dfile_count * sizeof(PVFS_handle)); + imm_p->handle_array_base_local_count = 0; + + /* allocate space for the data handle copies array, which will hold a + * combination of local and remote data handles used as destination handles + * for the copies. The order of this array will mimmick the order of the + * original data file array. Thus, handle_array_base[i] + * and handle_array_copies[i] will hold handles for the same server + * number. */ + imm_p->handle_array_copies = malloc(imm_p->io_servers_required * + imm_p->copies * + sizeof(PVFS_handle)); + if ( !imm_p->handle_array_copies ) + { + js_p->error_code = -PVFS_ENOMEM; + goto error_exit; + } + memset(imm_p->handle_array_copies,0,imm_p->io_servers_required * + imm_p->copies * sizeof(PVFS_handle)); + + /* allocate space for the local_io_servers array. this array contains the + * server names for local data handles. */ + imm_p->local_io_servers = malloc( imm_p->io_servers_required * + sizeof(char *)); + if ( !imm_p->local_io_servers ) + { + js_p->error_code = -PVFS_ENOMEM; + goto error_exit; + } - /*allocate space for the remote_io_servers array. this array contains the */ - /*server names for remote data handles. */ - imm_p->remote_io_servers = malloc( imm_p->io_servers_required - * sizeof(char*)); - if ( !imm_p->remote_io_servers ) - { - js_p->error_code = -PVFS_ENOMEM; - goto error_exit; - } - memset(imm_p->remote_io_servers - ,0 - ,imm_p->io_servers_required * sizeof(char*)); - imm_p->remote_io_servers_count = 0; - - /*populate the io_servers array with server_names: */ - /*Step 1: Always start by using the server names associated with the */ - /* original datahandles, keeping the order in tact. */ - /*Step 2: If additional servers are needed, then tap into the list of */ - /* servers running in the file system and grab those that are not */ - /* currently in the io_servers list. */ - - /*Step 1*/ - for (i=0; idfile_count; i++) - { - ret = PINT_cached_config_get_server_name( imm_p->io_servers[i], - sizeof(server_name)-1, - imm_p->handle_array_base[i], - imm_p->fs_id ); - if (ret) - { - js_p->error_code = ret; - goto error_exit; - } - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tValue of server_name is %s " - "for handle %llu\n" - ,imm_p->io_servers[i] - ,llu(imm_p->handle_array_base[i])); - }/*end for*/ - - /*Step 2*/ - if (imm_p->io_servers_required > imm_p->dfile_count) - { - ret = get_server_names(imm_p); - if (ret) - { - gossip_lerr("Unable to populate io_servers list.\n"); - js_p->error_code = ret; - goto error_exit; - } - } + memset(imm_p->local_io_servers, 0, + imm_p->io_servers_required * sizeof(char *)); + imm_p->local_io_servers_count = 0; + /* allocate space for the remote_io_servers array. this array contains the + * server names for remote data handles. */ + imm_p->remote_io_servers = malloc( imm_p->io_servers_required * + sizeof(char*)); + if ( !imm_p->remote_io_servers ) + { + js_p->error_code = -PVFS_ENOMEM; + goto error_exit; + } + memset(imm_p->remote_io_servers, 0, + imm_p->io_servers_required * sizeof(char*)); + imm_p->remote_io_servers_count = 0; + + /* populate the io_servers array with server_names: + * Step 1: Always start by using the server names associated with the + * original datahandles, keeping the order in tact. + * Step 2: If additional servers are needed, then tap into the list of + * servers running in the file system and grab those that are not + * currently in the io_servers list. */ + + /* Step 1 */ + for (i=0; idfile_count; i++) + { + ret = PINT_cached_config_get_server_name( imm_p->io_servers[i], + sizeof(server_name)-1, + imm_p->handle_array_base[i], + imm_p->fs_id ); + if (ret) + { + js_p->error_code = ret; + goto error_exit; + } + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tValue of server_name is %s " + "for handle %llu\n", + imm_p->io_servers[i], + llu(imm_p->handle_array_base[i])); + } /* end for */ + + /* Step 2 */ + if (imm_p->io_servers_required > imm_p->dfile_count) + { + ret = get_server_names(imm_p); + if (ret) + { + gossip_lerr("Unable to populate io_servers list.\n"); + js_p->error_code = ret; + goto error_exit; + } + } - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tconfig->host_id is %s.\n" - ,config->host_id); + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tconfig->host_id is %s.\n", + config->host_id); - gossip_debug(GOSSIP_MIRROR_DEBUG,"\timm_p->io_servers_required : %d\n" - ,imm_p->io_servers_required); - for (i=0,j=0; iio_servers_required; i++) - { - char *server_name = imm_p->io_servers[i]; - if (strncmp(server_name,config->host_id,SERVER_NAME_MAX-1) == 0) - {/*local*/ - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tprocessing local....\n"); - imm_p->local_io_servers[imm_p->handle_array_copies_local_count] = - malloc( SERVER_NAME_MAX ); - if ( !imm_p->local_io_servers[imm_p->handle_array_copies_local_count] ) - { - js_p->error_code = -PVFS_ENOMEM; - goto error_exit; - } - memset(imm_p->local_io_servers[imm_p->handle_array_copies_local_count] - ,0 - ,SERVER_NAME_MAX); - memcpy(imm_p->local_io_servers[imm_p->handle_array_copies_local_count], - server_name,SERVER_NAME_MAX-1); - if ( i < imm_p->dfile_count ) - { - imm_p->handle_array_base_local[imm_p->handle_array_base_local_count] - = - imm_p->handle_array_base[i]; - imm_p->handle_array_base_local_count++; - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tlocal source handle(%d):%llu\n" - ,imm_p->handle_array_base_local_count - ,llu(imm_p->handle_array_base_local[imm_p->handle_array_base_local_count])); - } - - imm_p->handle_array_copies_local_count++; - } - else - {/*remote*/ - imm_p->remote_io_servers[imm_p->handle_array_copies_remote_count] = - malloc( SERVER_NAME_MAX ); - if (!imm_p->remote_io_servers[imm_p->handle_array_copies_remote_count]) - { - js_p->error_code = -PVFS_ENOMEM; - goto error_exit; - } - memset(imm_p->remote_io_servers[imm_p->handle_array_copies_remote_count] - ,0 - ,SERVER_NAME_MAX); - memcpy(imm_p->remote_io_servers[imm_p->handle_array_copies_remote_count] - ,server_name,SERVER_NAME_MAX-1); - imm_p->handle_array_copies_remote_count++; - }/*end if*/ - }/*end for*/ - - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tLocal: %d\tRemote: %d\n" - ,imm_p->handle_array_copies_local_count - ,imm_p->handle_array_copies_remote_count); - - imm_p->local_io_servers_count = imm_p->handle_array_copies_local_count; - imm_p->remote_io_servers_count = imm_p->handle_array_copies_remote_count; - - for (i=0; ilocal_io_servers_count; i++) - { - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tlocal_io_servers[%d]: %s\n",i, - imm_p->local_io_servers[i]); - } - for (i=0; iremote_io_servers_count; i++) - { - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tremote_io_servers[%d]: %s\n",i, - imm_p->remote_io_servers[i]); - } + gossip_debug(GOSSIP_MIRROR_DEBUG, "\timm_p->io_servers_required : %d\n", + imm_p->io_servers_required); + for (i=0; iio_servers_required; i++) + { + char *server_name = imm_p->io_servers[i]; + if (strncmp(server_name, config->host_id, SERVER_NAME_MAX-1) == 0) + { /* local */ + gossip_debug(GOSSIP_MIRROR_DEBUG,"\tprocessing local....\n"); + imm_p->local_io_servers[imm_p->handle_array_copies_local_count] = + malloc( SERVER_NAME_MAX ); + if ( !imm_p->local_io_servers[ + imm_p->handle_array_copies_local_count] ) + { + js_p->error_code = -PVFS_ENOMEM; + goto error_exit; + } + memset( imm_p->local_io_servers[ + imm_p->handle_array_copies_local_count], + 0, + SERVER_NAME_MAX); + memcpy(imm_p->local_io_servers[ + imm_p->handle_array_copies_local_count], + server_name, SERVER_NAME_MAX-1); + if ( i < imm_p->dfile_count ) + { + imm_p->handle_array_base_local[ + imm_p->handle_array_base_local_count] + = imm_p->handle_array_base[i]; + imm_p->handle_array_base_local_count++; + gossip_debug(GOSSIP_MIRROR_DEBUG, + "\tlocal source handle(%d):%llu\n", + imm_p->handle_array_base_local_count, + llu(imm_p->handle_array_base_local[ + imm_p->handle_array_base_local_count])); + } + imm_p->handle_array_copies_local_count++; + } + else + { /*remote*/ + imm_p->remote_io_servers[imm_p->handle_array_copies_remote_count] = + malloc( SERVER_NAME_MAX ); + if ( ! imm_p->remote_io_servers[ + imm_p->handle_array_copies_remote_count]) + { + js_p->error_code = -PVFS_ENOMEM; + goto error_exit; + } + memset(imm_p->remote_io_servers[ + imm_p->handle_array_copies_remote_count], 0, SERVER_NAME_MAX); + memcpy(imm_p->remote_io_servers[ + imm_p->handle_array_copies_remote_count], + server_name, SERVER_NAME_MAX-1); + imm_p->handle_array_copies_remote_count++; + } /* end if */ + } /* end for */ + + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tLocal: %d\tRemote: %d\n", + imm_p->handle_array_copies_local_count, + imm_p->handle_array_copies_remote_count); + + imm_p->local_io_servers_count = imm_p->handle_array_copies_local_count; + imm_p->remote_io_servers_count = imm_p->handle_array_copies_remote_count; + + for (i=0; ilocal_io_servers_count; i++) + { + gossip_debug(GOSSIP_MIRROR_DEBUG,"\tlocal_io_servers[%d]: %s\n", i, + imm_p->local_io_servers[i]); + } + + for (i=0; iremote_io_servers_count; i++) + { + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tremote_io_servers[%d]: %s\n", i, + imm_p->remote_io_servers[i]); + } - /*allocate and initialize space for local and remote handle arrays*/ - if (imm_p->handle_array_copies_local_count) - { - imm_p->handle_array_copies_local = - malloc( imm_p->handle_array_copies_local_count * - imm_p->copies * sizeof(PVFS_handle)); - if ( !imm_p->handle_array_copies_local ) - { - js_p->error_code = -PVFS_ENOMEM; - goto error_exit; - } - } - if (imm_p->handle_array_copies_remote_count) - { - imm_p->handle_array_copies_remote = + /* allocate and initialize space for local and remote handle arrays */ + if (imm_p->handle_array_copies_local_count) + { + imm_p->handle_array_copies_local = + malloc( imm_p->handle_array_copies_local_count * + imm_p->copies * sizeof(PVFS_handle)); + if ( !imm_p->handle_array_copies_local ) + { + js_p->error_code = -PVFS_ENOMEM; + goto error_exit; + } + } + if (imm_p->handle_array_copies_remote_count) + { + imm_p->handle_array_copies_remote = malloc( imm_p->handle_array_copies_remote_count * imm_p->copies * sizeof(PVFS_handle)); - if ( !imm_p->handle_array_copies_remote ) - { - js_p->error_code = -PVFS_ENOMEM; - goto error_exit; - } - - }/*end if*/ + if ( !imm_p->handle_array_copies_remote ) + { + js_p->error_code = -PVFS_ENOMEM; + goto error_exit; + } + } /* end if */ - memset(imm_p->handle_array_copies_local - ,0 - ,imm_p->handle_array_copies_local_count * - imm_p->copies * sizeof(PVFS_handle)); - memset(imm_p->handle_array_copies_remote - ,0 - ,imm_p->handle_array_copies_remote_count * - imm_p->copies * sizeof(PVFS_handle)); + memset(imm_p->handle_array_copies_local, 0, + imm_p->handle_array_copies_local_count * + imm_p->copies * sizeof(PVFS_handle)); + memset(imm_p->handle_array_copies_remote, 0, + imm_p->handle_array_copies_remote_count * + imm_p->copies * sizeof(PVFS_handle)); error_exit: - /*all other memory will be freed in the "cleanup" action.*/ - free(sm_p->key_a); - free(sm_p->val_a); - free(sm_p->error_a); - sm_p->key_a = sm_p->val_a = NULL; - sm_p->error_a = NULL; + /* all other memory will be freed in the "cleanup" action. */ + free(sm_p->key_a); + free(sm_p->val_a); + free(sm_p->error_a); + sm_p->key_a = sm_p->val_a = NULL; + sm_p->error_a = NULL; - return SM_ACTION_COMPLETE; -}/*end action inspect_source_info*/ + return SM_ACTION_COMPLETE; +} /* end action inspect_source_info */ -/*We must get the bstream size for any datahandles that reside on this server.*/ -/*This scenario occurs when a metadata and i/o server are one of the same or */ -/*a metadata server and i/o server are running on the same machine. I think */ -/*this is outdated now, but I check for it anyway. */ -static PINT_sm_action obtain_local_handle_sizes(struct PINT_smcb *smcb - ,job_status_s *js_p) +/* We must get the bstream size for any datahandles that reside on this server. + * This scenario occurs when a metadata and i/o server are one of the same or + * a metadata server and i/o server are running on the same machine. I think + * this is outdated now, but I check for it anyway. */ +static PINT_sm_action obtain_local_handle_sizes(struct PINT_smcb *smcb, + job_status_s *js_p) { - gossip_debug(GOSSIP_MIRROR_DEBUG,"Executing obtain_local_handle_sizes....\n"); - - struct PINT_server_op *sm_p = PINT_sm_frame(smcb,PINT_FRAME_CURRENT); - PINT_server_create_copies_op *imm_p = &(sm_p->u.create_copies); - job_id_t job_id; - int ret = 0; + gossip_debug(GOSSIP_MIRROR_DEBUG, + "Executing obtain_local_handle_sizes....\n"); - js_p->error_code = 0; + struct PINT_server_op *sm_p = PINT_sm_frame(smcb,PINT_FRAME_CURRENT); + PINT_server_create_copies_op *imm_p = &(sm_p->u.create_copies); + job_id_t job_id; + int ret = 0; + js_p->error_code = 0; - /*Do we have any local handles?*/ - if (imm_p->handle_array_copies_local_count == 0) - return SM_ACTION_COMPLETE; + /* Do we have any local handles? */ + if (imm_p->handle_array_copies_local_count == 0) + return SM_ACTION_COMPLETE; - sm_p->error_a = malloc(imm_p->handle_array_base_local_count * + sm_p->error_a = malloc(imm_p->handle_array_base_local_count * sizeof(PVFS_error) ); - if (!sm_p->error_a) - { - js_p->error_code = -PVFS_ENOMEM; - goto error_exit; - } + if (!sm_p->error_a) + { + js_p->error_code = -PVFS_ENOMEM; + goto error_exit; + } - imm_p->ds_attr_a = malloc(imm_p->handle_array_base_local_count * - sizeof(PVFS_ds_attributes)); - if (!imm_p->ds_attr_a) - { - js_p->error_code = -PVFS_ENOMEM; - goto error_exit; - } + imm_p->ds_attr_a = malloc(imm_p->handle_array_base_local_count * + sizeof(PVFS_ds_attributes)); + if (!imm_p->ds_attr_a) + { + js_p->error_code = -PVFS_ENOMEM; + goto error_exit; + } - ret = job_trove_dspace_getattr_list(imm_p->fs_id - ,imm_p->handle_array_base_local_count - ,imm_p->handle_array_base_local - ,smcb - ,sm_p->error_a - ,imm_p->ds_attr_a - ,0 - ,js_p - ,&job_id - ,server_job_context - ,NULL); - return ret; + ret = job_trove_dspace_getattr_list(imm_p->fs_id, + imm_p->handle_array_base_local_count, + imm_p->handle_array_base_local, + smcb, + sm_p->error_a, + imm_p->ds_attr_a, + 0, + js_p, + &job_id, + server_job_context, + NULL); + return ret; error_exit: - if (sm_p->error_a) - free(sm_p->error_a); - sm_p->error_a = NULL; + if (sm_p->error_a) + free(sm_p->error_a); + sm_p->error_a = NULL; - return SM_ACTION_COMPLETE; -}/*end action obtain_local_handle_sizes*/ + return SM_ACTION_COMPLETE; +}/* end action obtain_local_handle_sizes */ -static PINT_sm_action inspect_local_handle_sizes(struct PINT_smcb *smcb - ,job_status_s *js_p) +static PINT_sm_action inspect_local_handle_sizes(struct PINT_smcb *smcb, + job_status_s *js_p) { - gossip_debug(GOSSIP_MIRROR_DEBUG,"Executing inspect_local_handle_sizes..\n"); - - struct PINT_server_op *sm_p = PINT_sm_frame(smcb,PINT_FRAME_CURRENT); - PINT_server_create_copies_op *imm_p = &(sm_p->u.create_copies); - int i,j; + gossip_debug(GOSSIP_MIRROR_DEBUG, + "Executing inspect_local_handle_sizes..\n"); + struct PINT_server_op *sm_p = PINT_sm_frame(smcb,PINT_FRAME_CURRENT); + PINT_server_create_copies_op *imm_p = &(sm_p->u.create_copies); + int i,j; - /*Do we have any local handles?*/ - if (imm_p->handle_array_copies_local_count == 0) - return SM_ACTION_COMPLETE; + /* Do we have any local handles? */ + if (imm_p->handle_array_copies_local_count == 0) + return SM_ACTION_COMPLETE; - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tchecking for errors....\n"); - /*check for errors*/ - for (i=0; ihandle_array_base_local_count; i++) - { - if (sm_p->error_a[i]) - { - js_p->error_code = sm_p->error_a[i]; - free(sm_p->error_a); - sm_p->error_a = NULL; - return SM_ACTION_COMPLETE; - } - }/*end for*/ - js_p->error_code = 0; + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tchecking for errors....\n"); + + /* check for errors */ + for (i=0; ihandle_array_base_local_count; i++) + { + if (sm_p->error_a[i]) + { + js_p->error_code = sm_p->error_a[i]; + free(sm_p->error_a); + sm_p->error_a = NULL; + return SM_ACTION_COMPLETE; + } + } /* end for */ + js_p->error_code = 0; - imm_p->bstream_array_base_local = malloc(imm_p->dfile_count * - sizeof(PVFS_size)); - if (!imm_p->bstream_array_base_local) - { - js_p->error_code = -PVFS_ENOMEM; - free(sm_p->error_a); - sm_p->error_a = NULL; - return SM_ACTION_COMPLETE; - } - memset(imm_p->bstream_array_base_local - ,0 - ,imm_p->dfile_count * sizeof(PVFS_size)); + imm_p->bstream_array_base_local = malloc(imm_p->dfile_count * + sizeof(PVFS_size)); + if (!imm_p->bstream_array_base_local) + { + js_p->error_code = -PVFS_ENOMEM; + free(sm_p->error_a); + sm_p->error_a = NULL; + return SM_ACTION_COMPLETE; + } + memset(imm_p->bstream_array_base_local, 0, + imm_p->dfile_count * sizeof(PVFS_size)); - gossip_debug(GOSSIP_MIRROR_DEBUG - ,"\tpopulating bstream_array_base_local...\n"); + gossip_debug(GOSSIP_MIRROR_DEBUG, + "\tpopulating bstream_array_base_local...\n"); - gossip_debug(GOSSIP_MIRROR_DEBUG,"\thandle_array_base_local_count:%d\n" - ,imm_p->handle_array_base_local_count); - /*populate bstream_array_base_local*/ - for (i=0; ihandle_array_base_local_count; i++) - { - for (j=0; jdfile_count; j++) - { - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tlocal handle(%d):%llu" - "\tbase handle(%d):%llu\n" - ,i,llu(imm_p->handle_array_base_local[i]) - ,j,llu(imm_p->handle_array_base[j]) ); - if (imm_p->handle_array_base_local[i] == imm_p->handle_array_base[j]) + gossip_debug(GOSSIP_MIRROR_DEBUG,"\thandle_array_base_local_count:%d\n", + imm_p->handle_array_base_local_count); + /* populate bstream_array_base_local */ + for (i=0; ihandle_array_base_local_count; i++) + { + for (j=0; jdfile_count; j++) + { + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tlocal handle(%d):%llu" + "\tbase handle(%d):%llu\n", + i, llu(imm_p->handle_array_base_local[i]), + j, llu(imm_p->handle_array_base[j]) ); + if (imm_p->handle_array_base_local[i] == + imm_p->handle_array_base[j]) { imm_p->bstream_array_base_local[j] = - imm_p->ds_attr_a[i].u.datafile.b_size; - gossip_debug(GOSSIP_MIRROR_DEBUG,"\thandle:%llu\tsize:%d\n" - ,llu(imm_p->handle_array_base_local[i]) - ,(int)imm_p->bstream_array_base_local[j] ); + imm_p->ds_attr_a[i].u.datafile.b_size; + gossip_debug(GOSSIP_MIRROR_DEBUG, "\thandle:%llu\tsize:%d\n", + llu(imm_p->handle_array_base_local[i]), + (int)imm_p->bstream_array_base_local[j] ); } - }/*end for*/ - }/*end for*/ + } /* end for */ + } /* end for */ free(sm_p->error_a); sm_p->error_a = NULL; return SM_ACTION_COMPLETE; -}/*end action inspect_local_handle_sizes*/ +} /* end action inspect_local_handle_sizes */ -static PINT_sm_action create_local_datahandles (struct PINT_smcb *smcb - ,job_status_s *js_p) +static PINT_sm_action create_local_datahandles (struct PINT_smcb *smcb, + job_status_s *js_p) { - gossip_debug(GOSSIP_MIRROR_DEBUG,"Executing create_local_datahandles....\n"); - - struct PINT_server_op *sm_p = PINT_sm_frame(smcb,PINT_FRAME_CURRENT); - PINT_server_create_copies_op *imm_p = &(sm_p->u.create_copies); - job_id_t job_id; - int ret = 0; - int i; - - PVFS_handle_extent_array data_handle_ext_array; - server_configuration_s *config = get_server_config_struct(); - - - js_p->error_code = 0; - - /*Do we have any local handles?*/ - if (imm_p->handle_array_copies_local_count == 0) - return SM_ACTION_COMPLETE; - - - gossip_debug(GOSSIP_MIRROR_DEBUG,"Target handle: %llu\tTarget FS ID: %d\n" - ,llu(imm_p->metadata_handle),imm_p->fs_id); - gossip_debug(GOSSIP_MIRROR_DEBUG,"dfile count: %d\n",imm_p->dfile_count); - gossip_debug(GOSSIP_MIRROR_DEBUG,"stuffed size: %d\n" - ,sm_p->target_object_attr->u.meta.stuffed_size); - gossip_debug(GOSSIP_MIRROR_DEBUG,"hint.flags: %llu\n" - ,llu(sm_p->target_object_attr->u.meta.hint.flags)); - gossip_debug(GOSSIP_MIRROR_DEBUG,"dfile array P: %p\n" - ,sm_p->target_object_attr->u.meta.dfile_array); - - /*find local IO extent array for this file system for metadata host*/ - ret = PINT_cached_config_get_server( imm_p->fs_id - ,config->host_id - ,PINT_SERVER_TYPE_IO - ,&data_handle_ext_array ); - if (ret) - { - js_p->error_code = ret; - return SM_ACTION_COMPLETE; - } - for (i=0;icopies,&imm_p->copies); - - - /*create local datahandles - will be used as destination handles for copies*/ - ret = job_trove_dspace_create_list( imm_p->fs_id - ,&data_handle_ext_array - ,imm_p->handle_array_copies_local - ,imm_p->handle_array_copies_local_count * - imm_p->copies - ,PVFS_TYPE_DATAFILE - ,NULL - ,TROVE_SYNC - ,smcb - ,0 - ,js_p - ,&job_id - ,server_job_context - ,NULL ); - return ret; -} /*end action create_local_datahandles*/ - - - + gossip_debug(GOSSIP_MIRROR_DEBUG, + "Executing create_local_datahandles....\n"); + + struct PINT_server_op *sm_p = PINT_sm_frame(smcb,PINT_FRAME_CURRENT); + PINT_server_create_copies_op *imm_p = &(sm_p->u.create_copies); + job_id_t job_id; + int ret = 0; + int i; + + PVFS_handle_extent_array data_handle_ext_array; + server_configuration_s *config = get_server_config_struct(); + + js_p->error_code = 0; + + /* Do we have any local handles? */ + if (imm_p->handle_array_copies_local_count == 0) + return SM_ACTION_COMPLETE; + + gossip_debug(GOSSIP_MIRROR_DEBUG, "Target handle: %llu\tTarget FS ID: %d\n", + llu(imm_p->metadata_handle),imm_p->fs_id); + gossip_debug(GOSSIP_MIRROR_DEBUG, "dfile count: %d\n",imm_p->dfile_count); + gossip_debug(GOSSIP_MIRROR_DEBUG, "stuffed size: %d\n", + sm_p->target_object_attr->u.meta.stuffed_size); + gossip_debug(GOSSIP_MIRROR_DEBUG,"hint.flags: %llu\n", + llu(sm_p->target_object_attr->u.meta.hint.flags)); + gossip_debug(GOSSIP_MIRROR_DEBUG,"dfile array P: %p\n", + sm_p->target_object_attr->u.meta.dfile_array); + + /* find local IO extent array for this file system for metadata host */ + ret = PINT_cached_config_get_server( imm_p->fs_id, + config->host_id, + PINT_SERVER_TYPE_IO, + &data_handle_ext_array ); + if (ret) + { + js_p->error_code = ret; + return SM_ACTION_COMPLETE; + } + for (i=0;icopies,&imm_p->copies); + + + /*i create local datahandles - will be used as destination handles for + * copies*/ + ret = job_trove_dspace_create_list( imm_p->fs_id, + &data_handle_ext_array, + imm_p->handle_array_copies_local, + imm_p->handle_array_copies_local_count * + imm_p->copies, + PVFS_TYPE_DATAFILE, + NULL, + TROVE_SYNC, + smcb, + 0, + js_p, + &job_id, + server_job_context, + NULL ); + return ret; +} /* end action create_local_datahandles */ + + +static PINT_sm_action create_remote_datahandles (struct PINT_smcb *smcb, + job_status_s *js_p) { - gossip_debug(GOSSIP_MIRROR_DEBUG,"Executing create_remote_datahandles...\n"); - struct PINT_server_op *sm_p = PINT_sm_frame(smcb,PINT_FRAME_CURRENT); - PINT_server_create_copies_op *imm_p = &(sm_p->u.create_copies); - int ret = 0,i; - job_id_t job_id; - - js_p->error_code = 0; + gossip_debug(GOSSIP_MIRROR_DEBUG, + "Executing create_remote_datahandles...\n"); + struct PINT_server_op *sm_p = PINT_sm_frame(smcb,PINT_FRAME_CURRENT); + PINT_server_create_copies_op *imm_p = &(sm_p->u.create_copies); + int ret = 0,i; + job_id_t job_id; + js_p->error_code = 0; - if (imm_p->handle_array_copies_remote_count == 0) - return SM_ACTION_COMPLETE; - - int rows = imm_p->copies; - int cols = imm_p->handle_array_copies_remote_count; - - imm_p->my_remote_servers = malloc(sizeof(char *) * rows * cols); - if (!imm_p->my_remote_servers) - { - gossip_lerr("Error allocating imm_p->my_remote_servers.\n"); - js_p->error_code = -PVFS_ENOMEM; - return SM_ACTION_COMPLETE; - } - memset(imm_p->my_remote_servers,0,sizeof(char *) * rows * cols); - - /*setup my_remote_servers[copy,remote#] = remote server name. This will */ - /*allow job_precreate_pool to return handle_array_copies_remote where */ - /*[copy,remote#] = remote handle. We end up with a list of remotes for */ - /*each copy in original distribution order. */ - for (i=0; i<(rows*cols); i++) - { - imm_p->my_remote_servers[i] = imm_p->remote_io_servers[i%cols]; - gossip_debug(GOSSIP_MIRROR_DEBUG,"\t\tremote_io_servers[%d]:%s " - "my_remote_servers[%d]:%s\n" - ,(i%cols) - ,imm_p->remote_io_servers[i%cols] - ,i - ,imm_p->my_remote_servers[i]); - } - - ret = job_precreate_pool_get_handles(imm_p->fs_id - ,rows*cols, - PVFS_TYPE_DATAFILE, - (const char **)imm_p->my_remote_servers - ,imm_p->handle_array_copies_remote - ,0 - ,smcb - ,0 - ,js_p - ,&job_id - ,server_job_context - ,NULL); - return ret; -}/*end action create_remote_datahandles*/ + if (imm_p->handle_array_copies_remote_count == 0) + return SM_ACTION_COMPLETE; + int rows = imm_p->copies; + int cols = imm_p->handle_array_copies_remote_count; + imm_p->my_remote_servers = malloc(sizeof(char *) * rows * cols); + if (!imm_p->my_remote_servers) + { + gossip_lerr("Error allocating imm_p->my_remote_servers.\n"); + js_p->error_code = -PVFS_ENOMEM; + return SM_ACTION_COMPLETE; + } + memset(imm_p->my_remote_servers,0,sizeof(char *) * rows * cols); + /* setup my_remote_servers[copy,remote#] = remote server name. This will + * allow job_precreate_pool to return handle_array_copies_remote where + * [copy,remote#] = remote handle. We end up with a list of remotes for + * each copy in original distribution order. */ + for (i=0; i<(rows*cols); i++) + { + imm_p->my_remote_servers[i] = imm_p->remote_io_servers[i%cols]; + gossip_debug(GOSSIP_MIRROR_DEBUG, "\t\tremote_io_servers[%d]:%s " + "my_remote_servers[%d]:%s\n", + (i%cols), + imm_p->remote_io_servers[i%cols], + i, + imm_p->my_remote_servers[i]); + } -static PINT_sm_action setup_datahandle_copies (struct PINT_smcb *smcb - ,job_status_s *js_p) + ret = job_precreate_pool_get_handles(imm_p->fs_id, + rows*cols, + PVFS_TYPE_DATAFILE, + (const char **) + imm_p->my_remote_servers, + imm_p->handle_array_copies_remote, + 0, + smcb, + 0, + js_p, + &job_id, + server_job_context, + NULL); + return ret; +} /* end action create_remote_datahandles */ + + +static PINT_sm_action setup_datahandle_copies (struct PINT_smcb *smcb, + job_status_s *js_p) { - gossip_debug(GOSSIP_MIRROR_DEBUG,"Executing setup_datahandle_copies...\n"); - struct PINT_server_op *sm_p = PINT_sm_frame(smcb,PINT_FRAME_CURRENT); - PINT_server_create_copies_op *imm_p = &(sm_p->u.create_copies); - server_configuration_s *config = get_server_config_struct(); - int i,j,k; - - - js_p->error_code = 0; - - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tRemote destination handles:\n"); - int rows = imm_p->copies; - int cols = imm_p->handle_array_copies_remote_count; - for (i=0; i<(rows*cols); i++) - { - gossip_debug(GOSSIP_MIRROR_DEBUG,"\t\tRemote handle(%d):%llu\n" - ,i - ,llu(imm_p->handle_array_copies_remote[i])); - } + gossip_debug(GOSSIP_MIRROR_DEBUG, "Executing setup_datahandle_copies...\n"); + struct PINT_server_op *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); + PINT_server_create_copies_op *imm_p = &(sm_p->u.create_copies); + server_configuration_s *config = get_server_config_struct(); + int i, j, k; + + js_p->error_code = 0; + + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tRemote destination handles:\n"); + int rows = imm_p->copies; + int cols = imm_p->handle_array_copies_remote_count; + for (i=0; i<(rows*cols); i++) + { + gossip_debug(GOSSIP_MIRROR_DEBUG, "\t\tRemote handle(%d):%llu\n", + i, + llu(imm_p-> + handle_array_copies_remote[i])); + } - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tLocal destination handles:\n"); - cols = imm_p->handle_array_copies_local_count; - for (i=0; i<(rows*cols); i++) - { - gossip_debug(GOSSIP_MIRROR_DEBUG,"\t\tLocal handle(%d):%llu\n" - ,i - ,llu(imm_p->handle_array_copies_local[i])); - } + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tLocal destination handles:\n"); + cols = imm_p->handle_array_copies_local_count; + for (i=0; i<(rows*cols); i++) + { + gossip_debug(GOSSIP_MIRROR_DEBUG, "\t\tLocal handle(%d):%llu\n", + i, + llu(imm_p-> + handle_array_copies_local[i])); + } - for (i=0,j=0,k=0; i<(imm_p->io_servers_required * imm_p->copies); i++) - { - if ( strncmp(imm_p->io_servers[i%imm_p->io_servers_required] - ,config->host_id,SERVER_NAME_MAX-1) == 0 ) - {/*local*/ - memcpy(&imm_p->handle_array_copies[i] - ,&imm_p->handle_array_copies_local[j],sizeof(PVFS_handle)); - j++; - } - else - {/*remote*/ - memcpy(&imm_p->handle_array_copies[i] - ,&imm_p->handle_array_copies_remote[k],sizeof(PVFS_handle)); - k++; - } - }/*end for*/ - - for (i=0; i<(imm_p->io_servers_required * imm_p->copies); i++) - gossip_debug(GOSSIP_MIRROR_DEBUG,"\thandle_array_copies[%d]: %llu.\n" - ,i - ,llu(imm_p->handle_array_copies[i])); - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tnumber of io servers required: %d\n" - ,imm_p->io_servers_required); - - /*create and initialize the writes_completed array*/ - imm_p->writes_completed = malloc(sizeof(PVFS_handle) * imm_p->dfile_count - * imm_p->copies); - if (!imm_p->writes_completed) - { - gossip_lerr("Unable to allocate imm_p->writes_completed.\n"); - js_p->error_code = -PVFS_ENOMEM; - return SM_ACTION_COMPLETE; - } - memset(imm_p->writes_completed,UINT64_HIGH,sizeof(PVFS_handle) - * imm_p->dfile_count - * imm_p->copies); + for (i=0, j=0, k=0; i < (imm_p->io_servers_required * imm_p->copies); i++) + { + if ( strncmp(imm_p->io_servers[i%imm_p->io_servers_required], + config->host_id,SERVER_NAME_MAX-1) == 0 ) + { /* local */ + memcpy(&imm_p->handle_array_copies[i], + &imm_p->handle_array_copies_local[j],sizeof(PVFS_handle)); + j++; + } + else + { /* remote */ + memcpy(&imm_p->handle_array_copies[i], + &imm_p->handle_array_copies_remote[k],sizeof(PVFS_handle)); + k++; + } + } /* end for */ + + for (i=0; i<(imm_p->io_servers_required * imm_p->copies); i++) + { + gossip_debug(GOSSIP_MIRROR_DEBUG, "\thandle_array_copies[%d]: %llu.\n", + i, + llu(imm_p->handle_array_copies[i])); + } + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tnumber of io servers required: %d\n", + imm_p->io_servers_required); + + /* create and initialize the writes_completed array */ + imm_p->writes_completed = malloc(sizeof(PVFS_handle) * imm_p->dfile_count + * imm_p->copies); + if (!imm_p->writes_completed) + { + gossip_lerr("Unable to allocate imm_p->writes_completed.\n"); + js_p->error_code = -PVFS_ENOMEM; + return SM_ACTION_COMPLETE; + } + memset(imm_p->writes_completed, UINT64_HIGH, sizeof(PVFS_handle) * + imm_p->dfile_count * imm_p->copies); - /*the retry count is used to monitor how many times we retry a write. */ - /*this value is incremented in the check_for_retries state. */ - imm_p->retry_count = 0; + /* the retry count is used to monitor how many times we retry a write. + * this value is incremented in the check_for_retries state. */ + imm_p->retry_count = 0; - return SM_ACTION_COMPLETE; -}/*end action setup_datahandle_copies*/ + return SM_ACTION_COMPLETE; +} /* end action setup_datahandle_copies */ static PINT_sm_action copy_data (struct PINT_smcb *smcb, job_status_s *js_p) { - gossip_debug(GOSSIP_MIRROR_DEBUG,"Executing copy_data....\n"); - struct PINT_server_op *sm_p = PINT_sm_frame(smcb,PINT_FRAME_CURRENT); - PINT_server_create_copies_op *imm_p = &(sm_p->u.create_copies); - server_configuration_s *config = get_server_config_struct(); - filesystem_configuration_s *fs = - PINT_config_find_fs_id(config,imm_p->fs_id); - int ret = 0; - int src,row,cols,i,index,wc; - - /*this variable helps to understand the logic better. it is a redeclara- */ - /*tion of the one dimensional imm_p->handle_array_copies and can be ac- */ - /*cessed as handle_array_copies[copies,dfile_count]. */ - PVFS_handle *handle_array_copies[imm_p->copies]; - memset(handle_array_copies,0,sizeof(PVFS_handle) * imm_p->copies); - ONE_DIM_TO_TWO_DIMS(imm_p->handle_array_copies - ,handle_array_copies - ,imm_p->copies,imm_p->io_servers_required - ,PVFS_handle); - - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tone dim to two dims:\n"); - for (row=0; rowcopies; row++) - { - for (cols=0; colsio_servers_required; cols++) - gossip_debug(GOSSIP_MIRROR_DEBUG,"\t\thandle_array_copies[%d][%d] : " - "%llu\n" - ,row,cols - ,llu(handle_array_copies[row][cols])); - } + gossip_debug(GOSSIP_MIRROR_DEBUG, "Executing copy_data....\n"); + struct PINT_server_op *sm_p = PINT_sm_frame(smcb,PINT_FRAME_CURRENT); + PINT_server_create_copies_op *imm_p = &(sm_p->u.create_copies); + server_configuration_s *config = get_server_config_struct(); + filesystem_configuration_s *fs = PINT_config_find_fs_id( config, + imm_p->fs_id); + int ret = 0; + int src, row, cols, i, index, wc; + + /* this variable helps to understand the logic better. it is a + * redeclaration of the one dimensional imm_p->handle_array_copies and can + * be accessed as handle_array_copies[copies,dfile_count]. */ + PVFS_handle *handle_array_copies[imm_p->copies]; + memset(handle_array_copies,0,sizeof(PVFS_handle) * imm_p->copies); + ONE_DIM_TO_TWO_DIMS(imm_p->handle_array_copies, + handle_array_copies, + imm_p->copies,imm_p->io_servers_required, + PVFS_handle); + + gossip_debug(GOSSIP_MIRROR_DEBUG,"\tone dim to two dims:\n"); + for (row=0; rowcopies; row++) + { + for (cols=0; colsio_servers_required; cols++) + gossip_debug(GOSSIP_MIRROR_DEBUG, "\t\thandle_array_copies[%d][%d] : " + "%llu\n", + row,cols, + llu(handle_array_copies[row][cols])); + } - js_p->error_code = 0; + js_p->error_code = 0; - /*for each source handle[src], create a MIRROR request containing a set of */ - /*destination handles. */ - for (src=0; srcdfile_count; src++) - { - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tWorking on src #%d\n",src); - - /* writes_completed indicates the status of each copy for each source: */ - /* 0 ==> completed, + ==> incomplete, UINT64_HIGH ==> initial state. */ - /* If incomplete, the value stored in the array is the destination */ - /* handle. */ - for (row=src,cols=0; colscopies; cols++) - { - index = (imm_p->copies * row) + cols; - /*this will capture UINT64_HIGH or handle*/ - if ( imm_p->writes_completed[index] > 0 - || imm_p->writes_completed[index] == UINT64_HIGH) - break; - } - - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tValue of cols is %d\n",cols); - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tValue of imm_p->copies is %d.\n" - ,imm_p->copies); + /* for each source handle[src], create a MIRROR request containing a set + * of destination handles. */ + for (src=0; srcdfile_count; src++) + { + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tWorking on src #%d\n",src); + + /* writes_completed indicates the status of each copy for each source: + * 0 ==> completed, + ==> incomplete, UINT64_HIGH ==> initial state. + * If incomplete, the value stored in the array is the destination + * handle. */ + for (row=src,cols=0; colscopies; cols++) + { + index = (imm_p->copies * row) + cols; + /* this will capture UINT64_HIGH or handle */ + if ( imm_p->writes_completed[index] > 0 + || imm_p->writes_completed[index] == UINT64_HIGH) + break; + } + + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tValue of cols is %d\n",cols); + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tValue of imm_p->copies is %d.\n", + imm_p->copies); - /*if all copies for this source are zero ==> process next source.*/ - if (cols==imm_p->copies) - { - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tThis source[%d] has all " - "complete writes.\n" - ,src); - continue; - } - - struct PVFS_server_req *req = malloc(sizeof(struct PVFS_server_req)); - if (!req) - { - gossip_lerr("Unable to allocate PVFS_server_req.\n"); - js_p->error_code = -PVFS_ENOMEM; - return SM_ACTION_COMPLETE; - } - memset(req,0,sizeof(struct PVFS_server_req)); - - req->u.mirror.dst_handle = malloc(sizeof(PVFS_handle) * imm_p->copies); - if ( !req->u.mirror.dst_handle) - { + /* if all copies for this source are zero ==> process next source. */ + if (cols==imm_p->copies) + { + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tThis source[%d] has all " + "complete writes.\n", src); + continue; + } + + struct PVFS_server_req *req = malloc(sizeof(struct PVFS_server_req)); + if (!req) + { + gossip_lerr("Unable to allocate PVFS_server_req.\n"); + js_p->error_code = -PVFS_ENOMEM; + return SM_ACTION_COMPLETE; + } + memset(req,0,sizeof(struct PVFS_server_req)); + + req->u.mirror.dst_handle = malloc(sizeof(PVFS_handle) * imm_p->copies); + if ( !req->u.mirror.dst_handle) + { gossip_lerr("Unable to allocate mirror.dst_handle.\n"); js_p->error_code = -PVFS_ENOMEM; return SM_ACTION_COMPLETE; - } - memset(req->u.mirror.dst_handle,0,sizeof(PVFS_handle) * imm_p->copies); + } + memset(req->u.mirror.dst_handle, 0, + sizeof(PVFS_handle) * imm_p->copies); - /*index into the writes_completed array for each destination handle*/ - req->u.mirror.wcIndex = malloc(sizeof(uint32_t) * imm_p->copies); - if ( !req->u.mirror.wcIndex ) - { + /* index into the writes_completed array for each destination handle */ + req->u.mirror.wcIndex = malloc(sizeof(uint32_t) * imm_p->copies); + if ( !req->u.mirror.wcIndex ) + { gossip_lerr("Unable to allocate mirror.wcIndex.\n"); js_p->error_code = -PVFS_ENOMEM; return SM_ACTION_COMPLETE; - } - memset(req->u.mirror.wcIndex,0,sizeof(uint32_t) * imm_p->copies); + } + memset(req->u.mirror.wcIndex,0,sizeof(uint32_t) * imm_p->copies); - req->op = PVFS_SERV_MIRROR; - req->credentials = sm_p->req->credentials; + req->op = PVFS_SERV_MIRROR; + req->credentials = sm_p->req->credentials; - req->u.mirror.src_handle = imm_p->handle_array_base[src]; + req->u.mirror.src_handle = imm_p->handle_array_base[src]; - /* In the initial state or when all writes have failed, get destination*/ - /* handles from handle_array_copies array. Otherwise, use the handles */ - /* stored in the writes_completed array. */ - index = imm_p->copies*src; /*first copy for this source*/ - if (imm_p->writes_completed[index] == UINT64_HIGH) - { - /*handle_array_copies[copy,server#] is accessed as a two-dimensional*/ - /*array where a row represents a copy and columns represent the */ - /*destination handles,in order of the original file distribution. We*/ - /*map the source handle[i], which is also in distribution order, */ - /*to handle_arrray_copies[0,i+1],[1,i+2],..,[n-1,(i+y)-1], where n */ - /*is the number of copies and y is the number of handles in one copy*/ - for (wc=0,row=0,cols=(src+1)%imm_p->io_servers_required; + /* In the initial state or when all writes have failed, get destination + * handles from handle_array_copies array. Otherwise, use the handles + * stored in the writes_completed array. */ + index = imm_p->copies*src; /* first copy for this source */ + if (imm_p->writes_completed[index] == UINT64_HIGH) + { + /* handle_array_copies[copy,server#] is accessed as a + * two-dimensional array where a row represents a copy and columns + * represent the destination handles,in order of the original file + * distribution. We map the source handle[i], which is also in + * distribution order, to + * handle_arrray_copies[0,i+1],[1,i+2],..,[n-1,(i+y)-1], where n + * is the number of copies and y is the number of handles in one + * copy */ + for (wc=0,row=0,cols=(src+1)%imm_p->io_servers_required; row < imm_p->copies; wc++,row++,cols=(cols+1)%imm_p->io_servers_required) - { - req->u.mirror.dst_handle[row] = handle_array_copies[row][cols]; - req->u.mirror.wcIndex[row] = index + wc; - req->u.mirror.dst_count++; - } - } else { - for (row=src,cols=0,i=0; colscopies; cols++,i++) - { - index = (imm_p->copies*row) + cols; - if (imm_p->writes_completed[index] > 0) - { - req->u.mirror.dst_handle[i] = imm_p->writes_completed[index]; - req->u.mirror.wcIndex[i] = index; - req->u.mirror.dst_count++; - } - } - } - req->u.mirror.fs_id = imm_p->fs_id; - req->u.mirror.dist = imm_p->dist; - req->u.mirror.src_server_nr = src; - req->u.mirror.flow_type = fs->flowproto; - req->u.mirror.encoding = fs->encoding; - - gossip_debug(GOSSIP_MIRROR_DEBUG,"\treq->: src:%llu\tfs_id:%d" - "\tdist name:%s\tsrc server_nr:%d\n" - ,llu(req->u.mirror.src_handle) - ,req->u.mirror.fs_id - ,req->u.mirror.dist->dist_name - ,req->u.mirror.src_server_nr ); - for (i=0; iu.mirror.dst_count; i++) - gossip_debug(GOSSIP_MIRROR_DEBUG,"\treq->dst_handle[%d] : %llu\n" - ,i - ,llu(req->u.mirror.dst_handle[i])); - - struct PINT_server_op *mirror_op = - malloc(sizeof(struct PINT_server_op)); - if (!mirror_op) - { - gossip_lerr("Error allocating mirror_op"); - js_p->error_code = -PVFS_ENOMEM; - return SM_ACTION_COMPLETE; - } - memset(mirror_op,0,sizeof(struct PINT_server_op)); - - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tabout to allocate mirror_op...\n"); - - if (imm_p->bstream_array_base_local) - req->u.mirror.bsize = imm_p->bstream_array_base_local[src]; - mirror_op->req = req; - mirror_op->op = req->op; - mirror_op->addr = sm_p->addr;/*get addr for this server*/ - - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tmirror_op->req(%p)\n" - ,mirror_op->req); - - if ( strncmp(imm_p->io_servers[src] - ,config->host_id - ,SERVER_NAME_MAX-1) == 0 ) - { - - gossip_debug(GOSSIP_MIRROR_DEBUG,"Above SRC is local.\n"); - PINT_sm_push_frame(smcb, LOCAL_SRC, mirror_op); - } - else - { - /*setup msgpairarray call. This msgpair represents a connection */ - /*between the meta server and a remote IO server. The request */ - /*for the remote IO server is PVFS_SERV_MIRROR, which will read */ - /*data residing on that server and write it to a destination */ - /*handle specified in the request. The response returned from */ - /*this msgpair will indicate if the copy was successful. */ - gossip_debug(GOSSIP_MIRROR_DEBUG,"Above SRC is remote.\n"); - - PINT_sm_msgarray_op *msgarray_op = &(mirror_op->msgarray_op); - - memset(msgarray_op,0,sizeof(PINT_sm_msgarray_op)); - msgarray_op->msgarray = &msgarray_op->msgpair; - msgarray_op->count = 1; - PINT_sm_msgpair_state *msg_p = &msgarray_op->msgpair; - - msg_p->req = *req; - msg_p->fs_id = req->u.mirror.fs_id; - msg_p->handle = req->u.mirror.src_handle; - msg_p->retry_flag = PVFS_MSGPAIR_RETRY; - msg_p->comp_fn = mirror_comp_fn; - - /*setup msgarray parameters*/ - PINT_serv_init_msgarray_params(mirror_op,req->u.mirror.fs_id); - - /*determine the BMI svr address for the source handle*/ - ret = PINT_cached_config_map_to_server(&msg_p->svr_addr - ,msg_p->handle - ,msg_p->fs_id ); - if (ret) - { - gossip_err("Failed to map address\n"); - js_p->error_code = -1; - return SM_ACTION_COMPLETE; - } - - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tmsg_p->req.op:%d" - "\tmsg_p->fs_id:%d" - "\tmsg_p->handle:%llu\n" - ,msg_p->req.op - ,msg_p->fs_id - ,llu(msg_p->handle) ); - - PINT_sm_push_frame(smcb, REMOTE_SRC, mirror_op); - } - }/*end for (src)*/ - - - return SM_ACTION_COMPLETE; -}/*end action copy_data*/ - - + { + req->u.mirror.dst_handle[row] = handle_array_copies[row][cols]; + req->u.mirror.wcIndex[row] = index + wc; + req->u.mirror.dst_count++; + } + } + else + { + for (row=src,cols=0,i=0; colscopies; cols++,i++) + { + index = (imm_p->copies*row) + cols; + if (imm_p->writes_completed[index] > 0) + { + req->u.mirror.dst_handle[i] = + imm_p->writes_completed[index]; + req->u.mirror.wcIndex[i] = index; + req->u.mirror.dst_count++; + } + } + } + req->u.mirror.fs_id = imm_p->fs_id; + req->u.mirror.dist = imm_p->dist; + req->u.mirror.src_server_nr = src; + req->u.mirror.flow_type = fs->flowproto; + req->u.mirror.encoding = fs->encoding; + + gossip_debug(GOSSIP_MIRROR_DEBUG, "\treq->: src:%llu\tfs_id:%d" + "\tdist name:%s\tsrc server_nr:%d\n", + llu(req->u.mirror.src_handle), + req->u.mirror.fs_id, + req->u.mirror.dist->dist_name, + req->u.mirror.src_server_nr ); + for (i=0; iu.mirror.dst_count; i++) + gossip_debug(GOSSIP_MIRROR_DEBUG, "\treq->dst_handle[%d] : %llu\n", + i, + llu(req->u.mirror.dst_handle[i])); + + struct PINT_server_op *mirror_op = + malloc(sizeof(struct PINT_server_op)); + if (!mirror_op) + { + gossip_lerr("Error allocating mirror_op"); + js_p->error_code = -PVFS_ENOMEM; + return SM_ACTION_COMPLETE; + } + memset(mirror_op, 0, sizeof(struct PINT_server_op)); + gossip_debug(GOSSIP_MIRROR_DEBUG,"\tabout to allocate mirror_op...\n"); -static PINT_sm_action check_copy_results (struct PINT_smcb *smcb - ,job_status_s *js_p) -{ - gossip_debug(GOSSIP_MIRROR_DEBUG,"Executing check_copy_results....\n"); - struct PINT_server_op *sm_p = PINT_sm_frame(smcb,PINT_FRAME_CURRENT); - PINT_server_create_copies_op *imm_p = &(sm_p->u.create_copies); - int task_id, error_code, remaining, i, j, index; - struct PINT_server_op *mirror_op = NULL; - struct PVFS_servresp_mirror *respmir = NULL; - struct PVFS_servreq_mirror *reqmir = NULL; - - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tjs_p->error_code:%d\n" - ,js_p->error_code); - js_p->error_code = 0; + if (imm_p->bstream_array_base_local) + { + req->u.mirror.bsize = imm_p->bstream_array_base_local[src]; + } - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tsm_p->op:%d\n",sm_p->op); - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tsmcb->base_frame:%d" - "\tsmcb->frame_count:%d\n" - ,smcb->base_frame,smcb->frame_count); - - /*the pjmp should have pushed at least one frame*/ - assert(smcb->frame_count > (smcb->base_frame+1)); - - do { - mirror_op=PINT_sm_pop_frame(smcb, &task_id, &error_code, &remaining); - respmir = &(mirror_op->resp.u.mirror); - reqmir = &(mirror_op->req->u.mirror); - - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tmirror_op->op:%d" - "\ttask_id:%d" - "\terror_code:%d(%0x)" - "\tremaining:%d\n" - ,mirror_op->op - ,task_id - ,error_code,error_code - ,remaining); - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tresp.src_handle:%llu " - "\tresp.src_server_nr:%d\n" - ,llu(respmir->src_handle) - ,respmir->src_server_nr ); - for (i=0; idst_count; i++) - { - gossip_debug(GOSSIP_MIRROR_DEBUG - ,"\t\tbytes_written[%d]:%d\n" - "\t\twrite_status_codde[%d]:%d\n" - ,i - ,respmir->bytes_written[i] - ,i - ,respmir->write_status_code[i]); - } - - /*if error_code != 0, then NONE of the writes requested in this msgpair*/ - /*array executed, so we do not need to check the individual status */ - /*codes. */ - if (error_code) - { - js_p->error_code = error_code; /*respmir has no valid data in it.*/ - } else { - /*check the write status for each destination associated with this */ - /*particular source handle. */ - for (i=0; idst_count; i++) - { - if (js_p->error_code) - { - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tStatus already " - "established:%d(0x%0x)\n" - ,js_p->error_code - ,js_p->error_code); - } - else if (respmir->write_status_code[i]) - { - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tStatus came from error_" - "code %d(0x%0x)\n" - ,error_code - ,error_code); - js_p->error_code = respmir->write_status_code[i]; - } - else - { - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tStatus is still zero(%d)" - "\n" - ,js_p->error_code); - } - }/*end for*/ - }/*end if*/ - - - for (i=0; idst_count; i++) - { - index = reqmir->wcIndex[i]; - if ( error_code == 0 /*this will short circuit if false*/ - && respmir->write_status_code[i] == 0) - { - imm_p->writes_completed[index] = 0; - } else if (error_code == 0) - { - imm_p->writes_completed[index] = reqmir->dst_handle[i]; - } else - { - imm_p->writes_completed[index] = UINT64_HIGH; - } - } - - switch(task_id) - { - case LOCAL_SRC: - { - gossip_debug(GOSSIP_MIRROR_DEBUG, - "\tReturning from LOCAL call...\n"); - break; - } - case REMOTE_SRC: - { - /*the destory can be moved into cleanup_msgpairarray, if none of*/ - /*its values are needed in this function. */ - PINT_msgpairarray_destroy(&(mirror_op->msgarray_op)); - gossip_debug(GOSSIP_MIRROR_DEBUG, - "\tReturning from REMOTE call .\n"); - break; - } - }/*end switch*/ - - /*cleanup request/response allocations for mirror request*/ - if (reqmir->dst_handle) - free(reqmir->dst_handle); - if (reqmir->wcIndex) - free(reqmir->wcIndex); - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tmirror_op->req(%p)\n" - ,mirror_op->req); - free(mirror_op->req); - - if (respmir->bytes_written) - free(respmir->bytes_written); - if (respmir->write_status_code) - free(respmir->write_status_code); - - free(mirror_op); - } while (remaining > (smcb->base_frame+1)); - - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tfinal value of js_p->error_code:%d(%0x)\n" - ,js_p->error_code, js_p->error_code); - - /*if one of the writes failed, js_p->error_code will contain an error.*/ - - gossip_debug(GOSSIP_MIRROR_DEBUG,"\twrites_completed array[src,server#]:\n"); - for (i=0; idfile_count; i++) - { - for (j=0; jcopies; j++) - { - index = (imm_p->dfile_count * i) + j; - gossip_debug(GOSSIP_MIRROR_DEBUG,"\t\t[%d][%d]:%llu\n" - ,i,j - ,llu(imm_p->writes_completed[index])); - } - } + mirror_op->req = req; + mirror_op->op = req->op; + mirror_op->addr = sm_p->addr; /* get addr for this server */ - return SM_ACTION_COMPLETE; -}/*end action check_copy_results*/ + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tmirror_op->req(%p)\n", + mirror_op->req); + if ( strncmp(imm_p->io_servers[src], config->host_id, + SERVER_NAME_MAX-1) == 0 ) + { + gossip_debug(GOSSIP_MIRROR_DEBUG,"Above SRC is local.\n"); + PINT_sm_push_frame(smcb, LOCAL_SRC, mirror_op); + } + else + { + /* setup msgpairarray call. This msgpair represents a connection + * between the meta server and a remote IO server. The request + * for the remote IO server is PVFS_SERV_MIRROR, which will read + * data residing on that server and write it to a destination + * handle specified in the request. The response returned from + * this msgpair will indicate if the copy was successful. */ + gossip_debug(GOSSIP_MIRROR_DEBUG,"Above SRC is remote.\n"); + + PINT_sm_msgarray_op *msgarray_op = &(mirror_op->msgarray_op); + + memset(msgarray_op,0,sizeof(PINT_sm_msgarray_op)); + msgarray_op->msgarray = &msgarray_op->msgpair; + msgarray_op->count = 1; + PINT_sm_msgpair_state *msg_p = &msgarray_op->msgpair; + + msg_p->req = *req; + msg_p->fs_id = req->u.mirror.fs_id; + msg_p->handle = req->u.mirror.src_handle; + msg_p->retry_flag = PVFS_MSGPAIR_RETRY; + msg_p->comp_fn = mirror_comp_fn; + + /* setup msgarray parameters */ + PINT_serv_init_msgarray_params(mirror_op,req->u.mirror.fs_id); + + /* determine the BMI svr address for the source handle */ + ret = PINT_cached_config_map_to_server(&msg_p->svr_addr, + msg_p->handle, + msg_p->fs_id ); + if (ret) + { + gossip_err("Failed to map address\n"); + js_p->error_code = -1; + return SM_ACTION_COMPLETE; + } -static PINT_sm_action check_for_retries (struct PINT_smcb *smcb - ,job_status_s *js_p) -{ - gossip_debug(GOSSIP_MIRROR_DEBUG,"Executing check_for_retries....\n"); - struct PINT_server_op *sm_p = PINT_sm_frame(smcb,PINT_FRAME_CURRENT); - PINT_server_create_copies_op *imm_p = &(sm_p->u.create_copies); - int i; + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tmsg_p->req.op:%d" + "\tmsg_p->fs_id:%d" + "\tmsg_p->handle:%llu\n", + msg_p->req.op, + msg_p->fs_id, + llu(msg_p->handle) ); - imm_p->retry_count++; + PINT_sm_push_frame(smcb, REMOTE_SRC, mirror_op); + } + } /* end for (src) */ - /*Have we hit the retry limit?*/ - if (imm_p->retry_count >= WRITE_RETRY_LIMIT) - { - js_p->error_code = 0; - return SM_ACTION_COMPLETE; - } - /*Are there any writes to retry?*/ - for (i=0; i<(imm_p->dfile_count * imm_p->copies); i++) - { - gossip_debug(GOSSIP_MIRROR_DEBUG,"\twrites_complete[%d]:%llu\n" - ,i,llu(imm_p->writes_completed[i])); - if (imm_p->writes_completed[i] != 0) - { - js_p->error_code = RETRY; - return SM_ACTION_COMPLETE; - } - } - - js_p->error_code = 0; return SM_ACTION_COMPLETE; -}/*end state check_for_retries*/ - +} /* end action copy_data */ -static PINT_sm_action store_mirror_info (struct PINT_smcb *smcb - ,job_status_s *js_p) +static PINT_sm_action check_copy_results (struct PINT_smcb *smcb, + job_status_s *js_p) { - gossip_debug(GOSSIP_MIRROR_DEBUG,"Executing store_mirror_info....\n"); - struct PINT_server_op *sm_p = PINT_sm_frame(smcb,PINT_FRAME_CURRENT); - PINT_server_create_copies_op *imm_p = &(sm_p->u.create_copies); - PVFS_handle *reorg_handles = NULL; - int key_count = 3; - int ret = 0,i,j; - job_id_t job_id; - - js_p->error_code = 0; + gossip_debug(GOSSIP_MIRROR_DEBUG,"Executing check_copy_results....\n"); + struct PINT_server_op *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); + PINT_server_create_copies_op *imm_p = &(sm_p->u.create_copies); + int task_id, error_code, remaining, i, j, index; + struct PINT_server_op *mirror_op = NULL; + struct PVFS_servresp_mirror *respmir = NULL; + struct PVFS_servreq_mirror *reqmir = NULL; + + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tjs_p->error_code:%d\n", + js_p->error_code); + js_p->error_code = 0; + + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tsm_p->op:%d\n",sm_p->op); + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tsmcb->base_frame:%d" + "\tsmcb->frame_count:%d\n", + smcb->base_frame,smcb->frame_count); + + /* the pjmp should have pushed at least one frame */ + assert(smcb->frame_count > (smcb->base_frame+1)); + + do + { + mirror_op = PINT_sm_pop_frame(smcb, &task_id, &error_code, &remaining); + respmir = &(mirror_op->resp.u.mirror); + reqmir = &(mirror_op->req->u.mirror); + + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tmirror_op->op:%d" + "\ttask_id:%d" + "\terror_code:%d(%0x)" + "\tremaining:%d\n", + mirror_op->op, + task_id, + error_code, error_code, + remaining); + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tresp.src_handle:%llu " + "\tresp.src_server_nr:%d\n", + llu(respmir->src_handle), + respmir->src_server_nr ); + for (i=0; idst_count; i++) + { + gossip_debug(GOSSIP_MIRROR_DEBUG, "\t\tbytes_written[%d]:%d\n" + "\t\twrite_status_codde[%d]:%d\n", + i, + respmir->bytes_written[i], + i, + respmir->write_status_code[i]); + } - /*put copy handles in proper distribution order*/ - reorg_handles = reorganize_copy_handles(imm_p); - if (!reorg_handles) - { - gossip_lerr("Unable to create reorg_handles array.\n"); - js_p->error_code = -PVFS_ENOMEM; - return SM_ACTION_COMPLETE; - } + /* if error_code != 0, then NONE of the writes requested in this + * msgpair + * array executed, so we do not need to check the individual status + * codes. */ + if (error_code) + { + js_p->error_code = error_code; /* respmir has no valid data in it.*/ + } + else + { + /* check the write status for each destination associated with + * this particular source handle. */ + for (i=0; idst_count; i++) + { + if (js_p->error_code) + { + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tStatus already " + "established:%d(0x%0x)\n", + js_p->error_code, js_p->error_code); + } + else if (respmir->write_status_code[i]) + { + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tStatus came from " + "error_code %d(0x%0x)\n", + error_code, + error_code); + js_p->error_code = respmir->write_status_code[i]; + } + else + { + gossip_debug(GOSSIP_MIRROR_DEBUG,"\tStatus is still " + "zero(%d)\n", js_p->error_code); + } + } /* end for */ + } /* end if */ + + + for (i=0; idst_count; i++) + { + index = reqmir->wcIndex[i]; + if ( error_code == 0 /* this will short circuit if false */ + && respmir->write_status_code[i] == 0 ) + { + imm_p->writes_completed[index] = 0; + } + else if (error_code == 0) + { + imm_p->writes_completed[index] = reqmir->dst_handle[i]; + } + else + { + imm_p->writes_completed[index] = UINT64_HIGH; + } + } - /*setup key/val pairs*/ - sm_p->keyval_count = key_count; - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tvalue of copies:%d \tlocation:%p\n" - ,imm_p->copies,&imm_p->copies); + switch(task_id) + { + case LOCAL_SRC: + { + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tReturning from LOCAL " + "call...\n"); + break; + } + case REMOTE_SRC: + { + /* the destory can be moved into cleanup_msgpairarray, if + * none of its values are needed in this function. */ + PINT_msgpairarray_destroy(&(mirror_op->msgarray_op)); + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tReturning from REMOTE " + "call .\n"); + break; + } + } /* end switch */ + + /* cleanup request/response allocations for mirror request */ + if (reqmir->dst_handle) + free(reqmir->dst_handle); + if (reqmir->wcIndex) + free(reqmir->wcIndex); + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tmirror_op->req(%p)\n", + mirror_op->req); + free(mirror_op->req); + + if (respmir->bytes_written) + free(respmir->bytes_written); + if (respmir->write_status_code) + free(respmir->write_status_code); + + free(mirror_op); + } while (remaining > (smcb->base_frame+1)); + + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tfinal value of js_p->error_code: " + "%d(%0x)\n", js_p->error_code, + js_p->error_code); + + /* if one of the writes failed, js_p->error_code will contain an error. */ + gossip_debug(GOSSIP_MIRROR_DEBUG, "\twrites_completed array[src,server#]" + ":\n"); + for (i=0; idfile_count; i++) + { + for (j=0; jcopies; j++) + { + index = (imm_p->dfile_count * i) + j; + gossip_debug(GOSSIP_MIRROR_DEBUG,"\t\t[%d][%d]:%llu\n", i, j, + llu(imm_p->writes_completed[index])); + } + } - sm_p->key_a = malloc(sizeof(PVFS_ds_keyval) * sm_p->keyval_count); - sm_p->val_a = malloc(sizeof(PVFS_ds_keyval) * sm_p->keyval_count); + return SM_ACTION_COMPLETE; +} /* end action check_copy_results */ - if (!sm_p->key_a || !sm_p->val_a) - goto error_exit; - memset(sm_p->key_a,0,sizeof(PVFS_ds_keyval) * sm_p->keyval_count); - memset(sm_p->val_a,0,sizeof(PVFS_ds_keyval) * sm_p->keyval_count); +static PINT_sm_action check_for_retries (struct PINT_smcb *smcb, + job_status_s *js_p) +{ + gossip_debug(GOSSIP_MIRROR_DEBUG,"Executing check_for_retries....\n"); + struct PINT_server_op *sm_p = PINT_sm_frame(smcb,PINT_FRAME_CURRENT); + PINT_server_create_copies_op *imm_p = &(sm_p->u.create_copies); + int i; - /*setup user.pvfs2.mirror.handles*/ - i=0; assert(ikey_a[i].buffer = malloc(sizeof(handle_key)); - if (!sm_p->key_a[i].buffer) - goto error_exit; - strcpy(sm_p->key_a[i].buffer,handle_key); - sm_p->key_a[i].buffer_sz = sizeof(handle_key); + imm_p->retry_count++; - sm_p->val_a[i].buffer = reorg_handles; - sm_p->val_a[i].buffer_sz = sizeof(PVFS_handle) * imm_p->dfile_count - * imm_p->copies; + /* Have we hit the retry limit? */ + if (imm_p->retry_count >= WRITE_RETRY_LIMIT) + { + js_p->error_code = 0; + return SM_ACTION_COMPLETE; + } - /*setup user.pvfs2.mirror.copies*/ - i++; assert(ikey_a[i].buffer = malloc(sizeof(copy_count_key)); - if (!sm_p->key_a[i].buffer) - goto error_exit; - strcpy(sm_p->key_a[i].buffer,copy_count_key); - sm_p->key_a[i].buffer_sz = sizeof(copy_count_key); + /* Are there any writes to retry? */ + for (i=0; i<(imm_p->dfile_count * imm_p->copies); i++) + { + gossip_debug(GOSSIP_MIRROR_DEBUG, "\twrites_complete[%d]:%llu\n", + i,llu(imm_p->writes_completed[i])); + if (imm_p->writes_completed[i] != 0) + { + js_p->error_code = RETRY; + return SM_ACTION_COMPLETE; + } + } + + js_p->error_code = 0; + return SM_ACTION_COMPLETE; +} /* end state check_for_retries */ - sm_p->val_a[i].buffer = malloc(sizeof(imm_p->copies)); - if (!sm_p->val_a[i].buffer) - goto error_exit; - sm_p->val_a[i].buffer_sz = sizeof(imm_p->copies); - memcpy(sm_p->val_a[i].buffer,&(imm_p->copies),sm_p->val_a[i].buffer_sz); - /*setup user.pvfs2.mirror.status*/ - i++; assert(ikey_a[i].buffer = malloc(sizeof(status_key)); - if (!sm_p->key_a[i].buffer) - goto error_exit; - strcpy(sm_p->key_a[i].buffer,status_key); - sm_p->key_a[i].buffer_sz = sizeof(status_key); +static PINT_sm_action store_mirror_info (struct PINT_smcb *smcb, + job_status_s *js_p) +{ + gossip_debug(GOSSIP_MIRROR_DEBUG, "Executing store_mirror_info....\n"); + struct PINT_server_op *sm_p = PINT_sm_frame(smcb,PINT_FRAME_CURRENT); + PINT_server_create_copies_op *imm_p = &(sm_p->u.create_copies); + PVFS_handle *reorg_handles = NULL; + int key_count = 3; + int ret = 0,i,j; + job_id_t job_id; + + js_p->error_code = 0; + + /* put copy handles in proper distribution order */ + reorg_handles = reorganize_copy_handles(imm_p); + if (!reorg_handles) + { + gossip_lerr("Unable to create reorg_handles array.\n"); + js_p->error_code = -PVFS_ENOMEM; + return SM_ACTION_COMPLETE; + } - sm_p->val_a[i].buffer = malloc(sizeof(PVFS_handle) * imm_p->dfile_count - * imm_p->copies); - if (!sm_p->val_a[i].buffer) + /* setup key/val pairs */ + sm_p->keyval_count = key_count; + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tvalue of copies:%d \tlocation:%p\n", + imm_p->copies,&imm_p->copies); + + sm_p->key_a = malloc(sizeof(PVFS_ds_keyval) * sm_p->keyval_count); + sm_p->val_a = malloc(sizeof(PVFS_ds_keyval) * sm_p->keyval_count); + + if (!sm_p->key_a || !sm_p->val_a) + goto error_exit; + + memset(sm_p->key_a, 0, sizeof(PVFS_ds_keyval) * sm_p->keyval_count); + memset(sm_p->val_a, 0, sizeof(PVFS_ds_keyval) * sm_p->keyval_count); + + /* setup user.pvfs2.mirror.handles */ + i=0; + assert(ikey_a[i].buffer = malloc(sizeof(handle_key)); + if (!sm_p->key_a[i].buffer) + goto error_exit; + strcpy(sm_p->key_a[i].buffer, handle_key); + sm_p->key_a[i].buffer_sz = sizeof(handle_key); + + sm_p->val_a[i].buffer = reorg_handles; + sm_p->val_a[i].buffer_sz = + sizeof(PVFS_handle) * imm_p->dfile_count * imm_p->copies; + + /* setup user.pvfs2.mirror.copies */ + i++; + assert(ikey_a[i].buffer = malloc(sizeof(copy_count_key)); + if (!sm_p->key_a[i].buffer) + goto error_exit; + + strcpy(sm_p->key_a[i].buffer,copy_count_key); + sm_p->key_a[i].buffer_sz = sizeof(copy_count_key); + + sm_p->val_a[i].buffer = malloc(sizeof(imm_p->copies)); + if (!sm_p->val_a[i].buffer) goto error_exit; - sm_p->val_a[i].buffer_sz = sizeof(PVFS_handle) * imm_p->dfile_count - * imm_p->copies; - memcpy(sm_p->val_a[i].buffer,imm_p->writes_completed - ,sm_p->val_a[i].buffer_sz); - /*verify inputs*/ - i=0; assert(ikey_a[i].buffer); - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tsize of buffer : %d\n" - ,sm_p->key_a[i].buffer_sz); - PVFS_handle *myHandle = (PVFS_handle *)sm_p->val_a[i].buffer; - for (j=0; j<(imm_p->dfile_count*imm_p->copies); j++) - { - gossip_debug(GOSSIP_MIRROR_DEBUG,"\t\thandle(%d):%llu\n" - ,j - ,llu(myHandle[j])); - } + sm_p->val_a[i].buffer_sz = sizeof(imm_p->copies); + memcpy(sm_p->val_a[i].buffer ,&(imm_p->copies), sm_p->val_a[i].buffer_sz); + + /* setup user.pvfs2.mirror.status */ + i++; + assert(ikey_a[i].buffer = malloc(sizeof(status_key)); + if (!sm_p->key_a[i].buffer) + goto error_exit; + + strcpy(sm_p->key_a[i].buffer,status_key); + sm_p->key_a[i].buffer_sz = sizeof(status_key); + + sm_p->val_a[i].buffer = + malloc(sizeof(PVFS_handle) * imm_p->dfile_count * imm_p->copies); + if (!sm_p->val_a[i].buffer) + goto error_exit; + sm_p->val_a[i].buffer_sz = + sizeof(PVFS_handle) * imm_p->dfile_count * imm_p->copies; + memcpy(sm_p->val_a[i].buffer,imm_p->writes_completed, + sm_p->val_a[i].buffer_sz); + + /* verify inputs */ + i=0; + assert(ikey_a[i].buffer); + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tsize of buffer : %d\n", + sm_p->key_a[i].buffer_sz); + PVFS_handle *myHandle = (PVFS_handle *)sm_p->val_a[i].buffer; + for (j=0; j<(imm_p->dfile_count*imm_p->copies); j++) + { + gossip_debug(GOSSIP_MIRROR_DEBUG,"\t\thandle(%d):%llu\n", j, + llu(myHandle[j])); + } - i++; assert(ival_a[i].buffer; - sm_p->val_a[i].buffer_sz = sizeof(int); - gossip_debug(GOSSIP_MIRROR_DEBUG,"\t%s:%d \tpointer:%p \tbuffer size:%d\n" - ,(char *)sm_p->key_a[i].buffer - ,*myCount,myCount - ,sm_p->val_a[i].buffer_sz); - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tkey count:%d\n" - ,sm_p->keyval_count); - - i++; assert(ival_a[i].buffer; - for (j=0; j<(imm_p->dfile_count * imm_p->copies); j++) - { - gossip_debug(GOSSIP_MIRROR_DEBUG,"\thandle(%d):status(%llu)\n" - ,j - ,llu(myStatus[j])); - } + i++; + assert(ival_a[i].buffer; + sm_p->val_a[i].buffer_sz = sizeof(int); + gossip_debug(GOSSIP_MIRROR_DEBUG, "\t%s:%d \tpointer:%p \tbuffer size:%d\n", + (char *)sm_p->key_a[i].buffer, + *myCount,myCount, + sm_p->val_a[i].buffer_sz); + gossip_debug(GOSSIP_MIRROR_DEBUG,"\tkey count:%d\n", sm_p->keyval_count); + + i++; + assert(ival_a[i].buffer; + for (j=0; j<(imm_p->dfile_count * imm_p->copies); j++) + { + gossip_debug(GOSSIP_MIRROR_DEBUG, "\thandle(%d):status(%llu)\n", + j, llu(myStatus[j])); + } - /*store keys*/ - ret = job_trove_keyval_write_list( imm_p->fs_id - ,imm_p->metadata_handle - ,sm_p->key_a - ,sm_p->val_a - ,sm_p->keyval_count - ,TROVE_SYNC /*trove flags*/ - ,NULL - ,smcb - ,0 - ,js_p - ,&job_id - ,server_job_context - ,NULL); - - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tvalue of ret from call to trove : %d\n" - ,ret); - - i=0; assert(ikey_a[i].buffer); - for (j=0; j<(imm_p->dfile_count * imm_p->copies); j++) - { - PVFS_handle *myHandle = (PVFS_handle *)sm_p->val_a[i].buffer; - gossip_debug(GOSSIP_MIRROR_DEBUG,"\t\thandle(%d):%llu\n" - ,j - ,llu(myHandle[j])); - } + /* store keys */ + ret = job_trove_keyval_write_list( imm_p->fs_id, + imm_p->metadata_handle, + sm_p->key_a, + sm_p->val_a, + sm_p->keyval_count, + TROVE_SYNC, /*trove flags*/ + NULL, + smcb, + 0, + js_p, + &job_id, + server_job_context, + NULL); + + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tvalue of ret from call to trove : " + "%d\n", ret); + + i=0; + assert(ikey_a[i].buffer); + for (j=0; j<(imm_p->dfile_count * imm_p->copies); j++) + { + PVFS_handle *myHandle = (PVFS_handle *)sm_p->val_a[i].buffer; + gossip_debug(GOSSIP_MIRROR_DEBUG,"\t\thandle(%d):%llu\n", j, + llu(myHandle[j])); + } - i++; assert(ival_a[i].buffer; - gossip_debug(GOSSIP_MIRROR_DEBUG,"\t%s:%d \tpointer:%p\n" - ,(char *)sm_p->key_a[i].buffer - ,*myCount - ,sm_p->val_a[i].buffer); + i++; + assert(ival_a[i].buffer; + gossip_debug(GOSSIP_MIRROR_DEBUG, "\t%s:%d \tpointer:%p\n", + (char *)sm_p->key_a[i].buffer, + *myCount, + sm_p->val_a[i].buffer); - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tvalue of ret from trove call : %d\n" - ,ret); - return (ret); + gossip_debug(GOSSIP_MIRROR_DEBUG,"\tvalue of ret from trove call : %d\n", + ret); + return (ret); error_exit: - for (i=0; ikeyval_count; i++) - { - if (sm_p->key_a && sm_p->key_a[i].buffer) - free(sm_p->key_a[i].buffer); - if (sm_p->val_a && sm_p->val_a[i].buffer) - free(sm_p->val_a[i].buffer); - } - - if (sm_p->key_a) - free(sm_p->key_a); - if (sm_p->val_a) - free(sm_p->val_a); + for (i=0; ikeyval_count; i++) + { + if (sm_p->key_a && sm_p->key_a[i].buffer) + free(sm_p->key_a[i].buffer); + if (sm_p->val_a && sm_p->val_a[i].buffer) + free(sm_p->val_a[i].buffer); + } - js_p->error_code = -PVFS_ENOMEM; - return SM_ACTION_COMPLETE; -}/*end action store_mirror_info*/ + if (sm_p->key_a) + free(sm_p->key_a); + if (sm_p->val_a) + free(sm_p->val_a); + js_p->error_code = -PVFS_ENOMEM; + return SM_ACTION_COMPLETE; +} /* end action store_mirror_info */ -static PINT_sm_action check_store_job (struct PINT_smcb *smcb - ,job_status_s *js_p) +static PINT_sm_action check_store_job (struct PINT_smcb *smcb, + job_status_s *js_p) { - gossip_debug(GOSSIP_MIRROR_DEBUG, - "Executing check_store_job....\n"); - struct PINT_server_op *sm_p = PINT_sm_frame(smcb,PINT_FRAME_CURRENT); - PINT_server_create_copies_op *imm_p = &(sm_p->u.create_copies); - int i; - - - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tjs_p->error_code:%d\n" - ,js_p->error_code); - - if (js_p->error_code) - { - gossip_err("Unable to store datahandles and number of copies for this " - "mirror operation.\n"); - gossip_err("\tMeta data handle is %llu\n",llu(imm_p->metadata_handle)); - return SM_ACTION_COMPLETE; - } + gossip_debug(GOSSIP_MIRROR_DEBUG, "Executing check_store_job....\n"); + struct PINT_server_op *sm_p = PINT_sm_frame(smcb,PINT_FRAME_CURRENT); + PINT_server_create_copies_op *imm_p = &(sm_p->u.create_copies); + int i; - /*release memory used in previous job call*/ - for (i=0; ikeyval_count; i++) - { - free(sm_p->key_a[i].buffer); - free(sm_p->val_a[i].buffer); - } - free(sm_p->key_a); - free(sm_p->val_a); - sm_p->key_a = sm_p->val_a = NULL; - sm_p->keyval_count = 0; + gossip_debug(GOSSIP_MIRROR_DEBUG,"\tjs_p->error_code:%d\n", + js_p->error_code); - js_p->error_code = 0; + if (js_p->error_code) + { + gossip_err("Unable to store datahandles and number of copies for this " + "mirror operation.\n"); + gossip_err("\tMeta data handle is %llu\n",llu(imm_p->metadata_handle)); + return SM_ACTION_COMPLETE; + } - return SM_ACTION_COMPLETE; -}/*end state check_store_job*/ + /* release memory used in previous job call */ + for (i=0; ikeyval_count; i++) + { + free(sm_p->key_a[i].buffer); + free(sm_p->val_a[i].buffer); + } + free(sm_p->key_a); + free(sm_p->val_a); + sm_p->key_a = sm_p->val_a = NULL; + sm_p->keyval_count = 0; + js_p->error_code = 0; + return SM_ACTION_COMPLETE; +} /* end state check_store_job */ -static PINT_sm_action replace_remote_datahandle_objects(struct PINT_smcb *smcb - ,job_status_s *js_p) +static PINT_sm_action replace_remote_datahandle_objects(struct PINT_smcb *smcb, + job_status_s *js_p) { - gossip_debug(GOSSIP_MIRROR_DEBUG, - "Executing replace_remote_datahandle_objects....\n"); + gossip_debug(GOSSIP_MIRROR_DEBUG, "Executing replace_remote_datahandle_" + "objects....\n"); - struct PINT_server_op *sm_p = PINT_sm_frame(smcb,PINT_FRAME_CURRENT); - PINT_server_create_copies_op *imm_p = &(sm_p->u.create_copies); - job_id_t job_id; - int ret; - int tmpindex; - PVFS_handle pool_handle; + struct PINT_server_op *sm_p = PINT_sm_frame(smcb,PINT_FRAME_CURRENT); + PINT_server_create_copies_op *imm_p = &(sm_p->u.create_copies); + job_id_t job_id; + int ret; + int tmpindex; + PVFS_handle pool_handle; - js_p->error_code = 0; - - if (!imm_p->handle_array_copies_remote) - { - gossip_debug(GOSSIP_MIRROR_DEBUG,"handle_array_copies_remote is " - "null: %p\n" - ,imm_p->handle_array_copies_remote); - js_p->error_code = REPLACE_DONE; - return SM_ACTION_COMPLETE; - } + js_p->error_code = 0; - imm_p->handle_array_copies_remote_count--; - if (imm_p->handle_array_copies_remote_count < 0) - { - js_p->error_code = REPLACE_DONE; - return SM_ACTION_COMPLETE; - } + if (!imm_p->handle_array_copies_remote) + { + gossip_debug(GOSSIP_MIRROR_DEBUG, "handle_array_copies_remote is " + "null: %p\n", + imm_p->handle_array_copies_remote); + js_p->error_code = REPLACE_DONE; + return SM_ACTION_COMPLETE; + } - tmpindex = imm_p->handle_array_copies_remote_count; + imm_p->handle_array_copies_remote_count--; + if (imm_p->handle_array_copies_remote_count < 0) + { + js_p->error_code = REPLACE_DONE; + return SM_ACTION_COMPLETE; + } - /* find the pool that this handle belongs to */ - ret = job_precreate_pool_lookup_server( imm_p->remote_io_servers[tmpindex], - PVFS_TYPE_DATAFILE, - imm_p->fs_id - ,&pool_handle ); - if (ret < 0) - { - imm_p->handle_array_copies_remote_count++; - js_p->error_code = ret; - return SM_ACTION_COMPLETE; - } + tmpindex = imm_p->handle_array_copies_remote_count; - ret = job_precreate_pool_fill( pool_handle - ,imm_p->fs_id - ,&(imm_p->handle_array_copies_remote[tmpindex]) - ,1 - ,smcb - ,0 - ,js_p - ,&job_id - ,server_job_context - ,NULL ); + /* find the pool that this handle belongs to */ + ret = job_precreate_pool_lookup_server( imm_p->remote_io_servers[tmpindex], + PVFS_TYPE_DATAFILE, + imm_p->fs_id, + &pool_handle ); + if (ret < 0) + { + imm_p->handle_array_copies_remote_count++; + js_p->error_code = ret; + return SM_ACTION_COMPLETE; + } - return ret; -}/*end action replace_remote_datahandle_objects*/ + ret = job_precreate_pool_fill( pool_handle, + imm_p->fs_id, + &(imm_p->handle_array_copies_remote + [tmpindex]), + 1, + smcb, + 0, + js_p, + &job_id, + server_job_context, + NULL ); + return ret; +} /* end action replace_remote_datahandle_objects */ -static PINT_sm_action remove_local_datahandle_objects(struct PINT_smcb *smcb - ,job_status_s *js_p) +static PINT_sm_action remove_local_datahandle_objects(struct PINT_smcb *smcb, + job_status_s *js_p) { - gossip_debug(GOSSIP_MIRROR_DEBUG, - "Executing remove_local_datahandle_objects....\n"); + gossip_debug(GOSSIP_MIRROR_DEBUG, "Executing remove_local_datahandle_" + "objects....\n"); - struct PINT_server_op *sm_p = PINT_sm_frame(smcb,PINT_FRAME_CURRENT); - PINT_server_create_copies_op *imm_p = &(sm_p->u.create_copies); - job_id_t job_id; - int ret; + struct PINT_server_op *sm_p = PINT_sm_frame(smcb,PINT_FRAME_CURRENT); + PINT_server_create_copies_op *imm_p = &(sm_p->u.create_copies); + job_id_t job_id; + int ret; - if (js_p->error_code) - imm_p->saved_error_code = js_p->error_code; + if (js_p->error_code) + imm_p->saved_error_code = js_p->error_code; - js_p->error_code = 0; - - if (!imm_p->handle_array_copies_local) - return SM_ACTION_COMPLETE; - - - ret = job_trove_dspace_remove_list( imm_p->fs_id - ,imm_p->handle_array_copies_local - ,NULL - ,imm_p->handle_array_copies_local_count - ,TROVE_SYNC - ,smcb - ,0 - ,js_p - ,&job_id - ,server_job_context - ,NULL ); + js_p->error_code = 0; - return ret; -}/*end action remove_local_datahandle_objects*/ + if (!imm_p->handle_array_copies_local) + return SM_ACTION_COMPLETE; + ret = job_trove_dspace_remove_list( imm_p->fs_id, + imm_p->handle_array_copies_local, + NULL, + imm_p->handle_array_copies_local_count, + TROVE_SYNC, + smcb, + 0, + js_p, + &job_id, + server_job_context, + NULL ); + return ret; +} /* end action remove_local_datahandle_objects */ static PINT_sm_action cleanup (struct PINT_smcb *smcb, job_status_s *js_p) { - gossip_debug(GOSSIP_MIRROR_DEBUG,"Executing cleanup....\n"); + gossip_debug(GOSSIP_MIRROR_DEBUG,"Executing cleanup....\n"); - struct PINT_server_op *sm_p = NULL; - PINT_server_create_copies_op *imm_p = NULL; - int i; + struct PINT_server_op *sm_p = NULL; + PINT_server_create_copies_op *imm_p = NULL; + int i; - sm_p = PINT_sm_frame(smcb,PINT_FRAME_CURRENT); - imm_p = &(sm_p->u.create_copies); + sm_p = PINT_sm_frame(smcb,PINT_FRAME_CURRENT); + imm_p = &(sm_p->u.create_copies); - if (js_p->error_code == NOTHING_TO_DO) - js_p->error_code = 0; + if (js_p->error_code == NOTHING_TO_DO) + js_p->error_code = 0; - if (imm_p->my_remote_servers) - free(imm_p->my_remote_servers); + if (imm_p->my_remote_servers) + free(imm_p->my_remote_servers); - if (imm_p->writes_completed) - free(imm_p->writes_completed); + if (imm_p->writes_completed) + free(imm_p->writes_completed); - if (imm_p->handle_array_copies_local) - free(imm_p->handle_array_copies_local); + if (imm_p->handle_array_copies_local) + free(imm_p->handle_array_copies_local); - if (imm_p->handle_array_copies_remote) - free(imm_p->handle_array_copies_remote); + if (imm_p->handle_array_copies_remote) + free(imm_p->handle_array_copies_remote); - if (imm_p->remote_io_servers) - { - for (i=0;iremote_io_servers_count;i++) + if (imm_p->remote_io_servers) + { + for (i=0;iremote_io_servers_count;i++) free(imm_p->remote_io_servers[i]); - free(imm_p->remote_io_servers); - } + free(imm_p->remote_io_servers); + } - if (imm_p->local_io_servers) - { - for (i=0; ilocal_io_servers_count; i++) - free(imm_p->local_io_servers[i]); - free(imm_p->local_io_servers); - } + if (imm_p->local_io_servers) + { + for (i=0; ilocal_io_servers_count; i++) + free(imm_p->local_io_servers[i]); + free(imm_p->local_io_servers); + } - if (imm_p->handle_array_base) - free(imm_p->handle_array_base); + if (imm_p->handle_array_base) + free(imm_p->handle_array_base); - if (imm_p->handle_array_base_local) - free(imm_p->handle_array_base_local); + if (imm_p->handle_array_base_local) + free(imm_p->handle_array_base_local); - if (imm_p->handle_array_copies) - free(imm_p->handle_array_copies); + if (imm_p->handle_array_copies) + free(imm_p->handle_array_copies); - if (imm_p->io_servers) - { - for (i=0;iio_servers_required;i++) - free(imm_p->io_servers[i]); - free(imm_p->io_servers); - } - - if (imm_p->ds_attr_a) - free(imm_p->ds_attr_a); + if (imm_p->io_servers) + { + for (i=0;iio_servers_required;i++) + { + free(imm_p->io_servers[i]); + } + free(imm_p->io_servers); + } - if (imm_p->bstream_array_base_local) - free(imm_p->bstream_array_base_local); + if (imm_p->ds_attr_a) + free(imm_p->ds_attr_a); - if (!js_p->error_code && imm_p->saved_error_code) - js_p->error_code = imm_p->saved_error_code; + if (imm_p->bstream_array_base_local) + free(imm_p->bstream_array_base_local); - if (imm_p->dist && imm_p->dist->dist_name) - free(imm_p->dist->dist_name); - if (imm_p->dist) - free(imm_p->dist); + if (!js_p->error_code && imm_p->saved_error_code) + js_p->error_code = imm_p->saved_error_code; - gossip_debug(GOSSIP_MIRROR_DEBUG,"Leaving cleanup: error_code:%d.....\n" - ,js_p->error_code); + if (imm_p->dist && imm_p->dist->dist_name) + free(imm_p->dist->dist_name); + if (imm_p->dist) + free(imm_p->dist); + gossip_debug(GOSSIP_MIRROR_DEBUG, "Leaving cleanup: error_code:%d.....\n", + js_p->error_code); - return SM_ACTION_COMPLETE; -}/*end action cleanup*/ + return SM_ACTION_COMPLETE; +} /* end action cleanup */ int mirror_comp_fn(void *v_p, struct PVFS_server_resp *resp_p, int i) { - gossip_debug(GOSSIP_MIRROR_DEBUG,"Executing mirror_comp_fn.....\n"); - - PINT_smcb *smcb = v_p; - struct PINT_server_op *mirror_op = - PINT_sm_frame(smcb, PINT_MSGPAIR_PARENT_SM); - struct PVFS_servresp_mirror *respmir = &(mirror_op->resp.u.mirror); - int k; - - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tmirror_op:%p\n",mirror_op); - - /* only posted one msgpair per source handle*/ - assert(i==0); - - /* If the response status is non-zero, then the rest of the response is */ - /* NOT encoded in final-response.sm. So, there are no values to access. */ - /* NOTE: An error code will be returned in the status field IFF NONE of */ - /* the writes were successful. Otherwise, the status of each write will */ - /* be contained in the write_status_code field. */ - if (resp_p->status != 0) - return(resp_p->status); - - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tresp->src_handle:%llu " - "\tresp->src_server_nr:%d " - "\tresp->status:%d\n" - ,llu(resp_p->u.mirror.src_handle) - ,resp_p->u.mirror.src_server_nr - ,resp_p->status ); - for (k=0; ku.mirror.dst_count; k++) - { - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tresp->bytes_written[%d]:%d" - "\tresp->write_status_code[%d]:%d\n" - ,k - ,resp_p->u.mirror.bytes_written[k] - ,k - ,resp_p->u.mirror.write_status_code[k]); - } - - assert(mirror_op->op == PVFS_SERV_MIRROR); - - memset(&(mirror_op->resp),0,sizeof(mirror_op->resp)); + gossip_debug(GOSSIP_MIRROR_DEBUG, "Executing mirror_comp_fn.....\n"); + + PINT_smcb *smcb = v_p; + struct PINT_server_op *mirror_op = PINT_sm_frame(smcb, + PINT_MSGPAIR_PARENT_SM); + struct PVFS_servresp_mirror *respmir = &(mirror_op->resp.u.mirror); + int k; + + gossip_debug(GOSSIP_MIRROR_DEBUG,"\tmirror_op:%p\n",mirror_op); + + /* only posted one msgpair per source handle*/ + assert(i==0); + + /* If the response status is non-zero, then the rest of the response is + * NOT encoded in final-response.sm. So, there are no values to access. + * NOTE: An error code will be returned in the status field IFF NONE of + * the writes were successful. Otherwise, the status of each write will + * be contained in the write_status_code field. */ + if (resp_p->status != 0) + return(resp_p->status); + + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tresp->src_handle:%llu " + "\tresp->src_server_nr:%d " + "\tresp->status:%d\n", + llu(resp_p->u.mirror.src_handle), + resp_p->u.mirror.src_server_nr, + resp_p->status ); + for (k=0; ku.mirror.dst_count; k++) + { + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tresp->bytes_written[%d]:%d" + "\tresp->write_status_code[%d]:%d\n", + k, + resp_p->u.mirror.bytes_written[k], + k, + resp_p->u.mirror. + write_status_code[k]); + } - /*capture information from the mirror operation.*/ - respmir->src_handle = resp_p->u.mirror.src_handle; - respmir->src_server_nr = resp_p->u.mirror.src_server_nr; - respmir->dst_count = resp_p->u.mirror.dst_count; + assert(mirror_op->op == PVFS_SERV_MIRROR); - respmir->bytes_written = malloc(sizeof(uint32_t) * respmir->dst_count); - if (!respmir->bytes_written) - { - gossip_lerr("Unable to allocate respmir->bytes_written\n"); - return (-PVFS_ENOMEM); - } - memset(respmir->bytes_written,0,sizeof(uint32_t) * respmir->dst_count); + memset(&(mirror_op->resp),0,sizeof(mirror_op->resp)); - respmir->write_status_code = malloc(sizeof(uint32_t) * respmir->dst_count); - if (!respmir->write_status_code) - { - gossip_lerr("Unable to allocate respmir->write_status_code.\n"); - return (-PVFS_ENOMEM); - } - memset(respmir->write_status_code,0,sizeof(uint32_t) * respmir->dst_count); + /* capture information from the mirror operation. */ + respmir->src_handle = resp_p->u.mirror.src_handle; + respmir->src_server_nr = resp_p->u.mirror.src_server_nr; + respmir->dst_count = resp_p->u.mirror.dst_count; - memcpy(respmir->bytes_written,resp_p->u.mirror.bytes_written - ,sizeof(uint32_t) * respmir->dst_count); - memcpy(respmir->write_status_code,resp_p->u.mirror.write_status_code - ,sizeof(uint32_t) * respmir->dst_count); + respmir->bytes_written = malloc(sizeof(uint32_t) * respmir->dst_count); + if (!respmir->bytes_written) + { + gossip_lerr("Unable to allocate respmir->bytes_written\n"); + return (-PVFS_ENOMEM); + } + memset(respmir->bytes_written,0,sizeof(uint32_t) * respmir->dst_count); - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tsmcb->base_frame:%d\tframe_count:%d\n" - ,smcb->base_frame,smcb->frame_count); + respmir->write_status_code = malloc(sizeof(uint32_t) * respmir->dst_count); + if (!respmir->write_status_code) + { + gossip_lerr("Unable to allocate respmir->write_status_code.\n"); + return (-PVFS_ENOMEM); + } + memset(respmir->write_status_code,0,sizeof(uint32_t) * respmir->dst_count); - return(0); -} /*end msgpair completion function mirror_comp_fn*/ + memcpy(respmir->bytes_written,resp_p->u.mirror.bytes_written, + sizeof(uint32_t) * respmir->dst_count); + memcpy(respmir->write_status_code,resp_p->u.mirror.write_status_code, + sizeof(uint32_t) * respmir->dst_count); + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tsmcb->base_frame:%d\tframe_count:%d\n", + smcb->base_frame,smcb->frame_count); + return(0); +} /* end msgpair completion function mirror_comp_fn */ static PVFS_handle *reorganize_copy_handles( struct PINT_server_create_copies_op *imm_p) { - gossip_debug(GOSSIP_MIRROR_DEBUG,"Executing reorganize_copy_handles..\n"); - - uint64_t i,j,k,rows,in_cols,out_cols; - PVFS_handle *copies_out = NULL; - PVFS_handle *copies_in = imm_p->handle_array_copies; + gossip_debug(GOSSIP_MIRROR_DEBUG,"Executing reorganize_copy_handles..\n"); + uint64_t i, j, k, rows, in_cols, out_cols; + PVFS_handle *copies_out = NULL; + PVFS_handle *copies_in = imm_p->handle_array_copies; - rows = imm_p->copies; - in_cols = imm_p->io_servers_required; - out_cols = imm_p->dfile_count; + rows = imm_p->copies; + in_cols = imm_p->io_servers_required; + out_cols = imm_p->dfile_count; - /* allocate copies_out array */ - copies_out = malloc(sizeof(PVFS_handle) * rows * out_cols); - if (!copies_out) - { - gossip_lerr("Unable to allocate memeory.\n"); - return (NULL); - } - memset(copies_out,0,sizeof(PVFS_handle) * rows * out_cols); + /* allocate copies_out array */ + copies_out = malloc(sizeof(PVFS_handle) * rows * out_cols); + if (!copies_out) + { + gossip_lerr("Unable to allocate memeory.\n"); + return (NULL); + } + memset(copies_out, 0, sizeof(PVFS_handle) * rows * out_cols); - for (i=0; i<(in_cols*rows); i++) - { - gossip_debug(GOSSIP_MIRROR_DEBUG,"\thandle_array_copies(%d):%llu\n" - ,(int)i - ,llu(copies_in[i])); - } + for (i=0; i<(in_cols*rows); i++) + { + gossip_debug(GOSSIP_MIRROR_DEBUG, "\thandle_array_copies(%d):%llu\n", + (int)i, + llu(copies_in[i])); + } - /*this code copies copies_in[n+1] to copies_out[n] within the same row*/ - /*each row represents one copy of the logical file, i.e., each of its */ - /*datahandles. */ - for (i=0,k=1; iio_servers_required; i++) - gossip_debug(GOSSIP_MIRROR_DEBUG,"\t [%d]:%s" - "\tlength:%d\n" - ,i - ,imm_p->io_servers[i] - ,(int)strlen(imm_p->io_servers[i])); - - - - /*Get access to the io server names residing in the cache*/ - ret = PINT_cached_config_io_server_names(&list,&size,imm_p->fs_id); - if (ret) - { - if (list) - free(list); - gossip_lerr("Unable to retrieve IO server names from the cache.\n"); - return(ret); - } - - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tReturned from PINT_cached_config...\n"); - for (i=0; idfile_count; j++) - { - if (strncmp(list[i],imm_p->io_servers[j],strlen(list[i])) == 0) + char **list=NULL; + int size=0,i,j,ret; + + gossip_debug(GOSSIP_MIRROR_DEBUG,"Executing get_server_names....\n"); + + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tio_servers(before):\n"); + for (i=0; iio_servers_required; i++) + gossip_debug(GOSSIP_MIRROR_DEBUG, "\t [%d]:%s" + "\tlength:%d\n", + i, + imm_p->io_servers[i], + (int)strlen(imm_p->io_servers[i])); + + /* Get access to the io server names residing in the cache */ + ret = PINT_cached_config_io_server_names(&list, &size, imm_p->fs_id); + if (ret) + { + if (list) + free(list); + gossip_lerr("Unable to retrieve IO server names from the cache.\n"); + return(ret); + } + + gossip_debug(GOSSIP_MIRROR_DEBUG,"\tReturned from PINT_cached_config...\n"); + for (i=0; idfile_count; j++) { - list[i] = NULL; - break; + if (strncmp(list[i],imm_p->io_servers[j],strlen(list[i])) == 0) + { + list[i] = NULL; + break; + } + } /* end for */ + } /* end for */ + + /* Add server names to io_servers list */ + for (i=0,j=imm_p->dfile_count; iio_servers_required; i++) + { + if (list[i]) + { + strncpy(imm_p->io_servers[j],list[i],SERVER_NAME_MAX-1); + j++; } - }/*end for*/ - }/*end for*/ - - /*Add server names to io_servers list*/ - for (i=0,j=imm_p->dfile_count; iio_servers_required; i++) - { - if (list[i]) - { - strncpy(imm_p->io_servers[j],list[i],SERVER_NAME_MAX-1); - j++; - } - }/*end for*/ - - gossip_debug(GOSSIP_MIRROR_DEBUG, "\tio_servers(after):\n"); - for (i=0; iio_servers_required; i++) - gossip_debug(GOSSIP_MIRROR_DEBUG,"\t [%d]:%s\n" - ,i - ,imm_p->io_servers[i]); - - /*deallocate memory used for "list"*/ - free(list); - - return (0); -}/*end function get_server_names*/ - -/******************************************************************************/ -/* Right now, this state machine is not called as a standalone request. It is */ -/* only called as a nested machine from seteattr; however, when time comes to */ -/* create a standalone server request, the values used for the request */ -/* parameters are listed below. */ -/******************************************************************************/ -static inline int PINT_get_object_ref_copies( struct PVFS_server_req *req - ,PVFS_fs_id *fs_id - ,PVFS_handle *handle ) + } /*end for*/ + + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tio_servers(after):\n"); + for (i=0; iio_servers_required; i++) + gossip_debug(GOSSIP_MIRROR_DEBUG,"\t [%d]:%s\n", + i, imm_p->io_servers[i]); + + /* deallocate memory used for "list" */ + free(list); + + return (0); +} /* end function get_server_names */ + +/* Right now, this state machine is not called as a standalone request. It is + * only called as a nested machine from seteattr; however, when time comes to + * create a standalone server request, the values used for the request + * parameters are listed below. */ +static inline int PINT_get_object_ref_copies( struct PVFS_server_req *req, + PVFS_fs_id *fs_id, + PVFS_handle *handle ) { - *fs_id = req->u.seteattr.fs_id; - *handle = req->u.seteattr.handle; + *fs_id = req->u.seteattr.fs_id; + *handle = req->u.seteattr.handle; return 0; }; -/*request parameters*/ +/* request parameters */ struct PINT_server_req_params pvfs2_create_immutable_copies_params = { .string_name = "create_immutable_copies", @@ -2116,5 +2118,3 @@ struct PINT_server_req_params pvfs2_create_immutable_copies_params = .get_object_ref = PINT_get_object_ref_copies, .state_machine = &pvfs2_create_immutable_copies_sm }; - -/****** E N D O F F I L E *******************************/ diff --git a/src/server/create.sm b/src/server/create.sm index 0ad5799..998c891 100644 --- a/src/server/create.sm +++ b/src/server/create.sm @@ -35,7 +35,7 @@ machine pvfs2_create_sm state create_metafile { run create_metafile; - OSD_MSGPAIR => setup_resp; + OSD_MSGPAIR => setup_local_datafile_handles; success => check_stuffed; default => setup_final_response; } @@ -57,6 +57,7 @@ machine pvfs2_create_sm state setup_local_datafile_handles { run setup_local_datafile_handles; + OSD_MSGPAIR => setup_resp; success => request_datafiles; default => remove_local_datafile_handles; } @@ -176,7 +177,7 @@ static int create_metafile( config->host_id, PINT_SERVER_TYPE_META, &meta_handle_ext_array); - + ret = job_trove_dspace_create( s_op->req->u.create.fs_id, &meta_handle_ext_array, @@ -188,14 +189,13 @@ static int create_metafile( js_p, &i, server_job_context, s_op->req->hints); - - if(config->osd_type ) + + if(config->osd_type == OSD_DATAFILE) { js_p->error_code = OSD_MSGPAIR; - return(ret); - } else { - return(ret); } + + return(ret); } static int check_stuffed( @@ -248,15 +248,20 @@ static int check_stuffed( /* is this metadata server also IO? */ svr_name = PINT_cached_config_map_addr(s_op->req->u.create.fs_id, myaddr, &server_type); + if(!svr_name) { js_p->error_code = ret; return SM_ACTION_COMPLETE; } - /* for now only support stuffing of ROUND_ROBIN layouts */ - if((server_type & PINT_SERVER_TYPE_IO) && fs_conf->file_stuffing && layout->algorithm == PVFS_SYS_LAYOUT_ROUND_ROBIN) - { + /* For now only support stuffing of ROUND_ROBIN layouts. + * As a performance enhancement, don't create a stuffed file when the current environment only has one server. + * This prevents unstuffing from being called by the client sys-io machine. + */ + if((server_type & PINT_SERVER_TYPE_IO) && fs_conf->file_stuffing && layout->algorithm == PVFS_SYS_LAYOUT_ROUND_ROBIN + && s_op->req->u.create.num_dfiles_req > 1 ) + { /* we can do a stuffed create here, only one datafile */ s_op->req->u.create.attr.u.meta.dfile_count = 1; s_op->resp.u.create.datafile_count = 1; @@ -269,11 +274,10 @@ static int check_stuffed( } s_op->resp.u.create.stuffed = 1; - s_op->u.create.handle_array_local[0] = 100; js_p->error_code = 0; return SM_ACTION_COMPLETE; } - + /* file will not be stuffed; need to allocate all datafiles */ s_op->u.create.num_io_servers = s_op->req->u.create.num_dfiles_req; s_op->resp.u.create.datafile_handles = malloc( @@ -324,6 +328,7 @@ static int check_stuffed( s_op->resp.u.create.stuffed = 0; js_p->error_code = 0; + return SM_ACTION_COMPLETE; } @@ -383,6 +388,7 @@ static int create_local_datafiles( config->host_id, PINT_SERVER_TYPE_IO, &data_handle_ext_array); + if(ret < 0) { js_p->error_code = ret; @@ -392,6 +398,7 @@ static int create_local_datafiles( /* deliberately not setting SYNC flag, because both the attrs and * keyvals will be synced in later states */ + ret = job_trove_dspace_create_list( s_op->req->u.create.fs_id, &data_handle_ext_array, @@ -406,7 +413,7 @@ static int create_local_datafiles( &tmp_id, server_job_context, s_op->req->hints); - + return(ret); } @@ -583,25 +590,54 @@ static PINT_sm_action setup_local_datafile_handles( struct PINT_server_op *s_op = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); int i; int tmp_index = 0; + PVFS_handle_extent_array data_handle_ext_array; + PINT_llist *cur = NULL; + struct host_alias_s *cur_alias; server_configuration_s *config = get_server_config_struct(); - - if(s_op->resp.u.create.stuffed) - { - s_op->resp.u.create.datafile_handles[0] = - s_op->u.create.handle_array_local[0]; - js_p->error_code = 0; - return(SM_ACTION_COMPLETE); - } - else + + if(config->osd_type == OSD_DATAFILE) { - for(i=0; iu.create.num_io_servers; i++) + cur = config->host_aliases; + while(cur) { - /* find local server positions and set handles */ - if(!strcmp(s_op->u.create.io_servers[i], config->host_id)) + cur_alias = PINT_llist_head(cur); + if (!cur_alias) { - s_op->resp.u.create.datafile_handles[i] = - s_op->u.create.handle_array_local[tmp_index]; - tmp_index++; + break; + } + if(!strncmp(cur_alias->bmi_address, "osd", 3)) { + PINT_cached_config_get_server( + s_op->req->u.create.fs_id, + cur_alias->bmi_address, + PINT_SERVER_TYPE_IO, + &data_handle_ext_array); + } + cur = PINT_llist_next(cur); + } + + s_op->resp.u.create.datafile_count = 1; + s_op->resp.u.create.datafile_handles = malloc(sizeof(PVFS_handle)); + s_op->resp.u.create.datafile_handles[0] = trove_handle_alloc_from_range(s_op->req->u.create.fs_id, &data_handle_ext_array); + js_p->error_code = OSD_MSGPAIR; + } else { + if(s_op->resp.u.create.stuffed) + { + s_op->resp.u.create.datafile_handles[0] = + s_op->u.create.handle_array_local[0]; + js_p->error_code = 0; + return(SM_ACTION_COMPLETE); + } + else + { + for(i=0; iu.create.num_io_servers; i++) + { + /* find local server positions and set handles */ + if(!strcmp(s_op->u.create.io_servers[i], config->host_id)) + { + s_op->resp.u.create.datafile_handles[i] = + s_op->u.create.handle_array_local[tmp_index]; + tmp_index++; + } } } } @@ -794,7 +830,7 @@ static int setup_resp( s_op->resp.u.create.metafile_handle = js_p->handle; PINT_ACCESS_DEBUG(s_op, GOSSIP_ACCESS_DEBUG, "create: new metadata handle: %llu.\n", - llu(js_p->handle)); + llu(s_op->resp.u.create.metafile_handle)); } return SM_ACTION_COMPLETE; diff --git a/src/server/get-attr.sm b/src/server/get-attr.sm index 26a3768..893e094 100644 --- a/src/server/get-attr.sm +++ b/src/server/get-attr.sm @@ -274,6 +274,7 @@ static PINT_sm_action getattr_verify_attribs( resp_attr->group = s_op->attr.group; resp_attr->perms = s_op->attr.perms; resp_attr->atime = s_op->attr.atime; + resp_attr->cid = s_op->attr.cid; resp_attr->mtime = PINT_util_mkversion_time(s_op->attr.mtime); if (resp_attr->mtime == 0) @@ -1286,7 +1287,7 @@ static PINT_sm_action interpret_metafile_distribution( static PINT_sm_action getattr_setup_resp( struct PINT_smcb *smcb, job_status_s *js_p) -{ +{ struct PINT_server_op *s_op = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); PVFS_object_attr *resp_attr = &s_op->resp.u.getattr.attr; @@ -1613,7 +1614,7 @@ static PINT_sm_action getattr_get_dir_hint( /* NOTE: memory allocations are released in the getattr_cleanup() * function */ - + if (!(s_op->u.getattr.attrmask & PVFS_ATTR_DIR_HINT)) { /* the caller didn't really want the dir hints; skip @@ -1801,6 +1802,7 @@ static PINT_sm_action getattr_interpret_dir_hint( js_p->error_code = 0; }/* end if val_a and key_a */ + return SM_ACTION_COMPLETE; } diff --git a/src/server/get-eattr.sm b/src/server/get-eattr.sm index 93ebf74..8d5ee22 100644 --- a/src/server/get-eattr.sm +++ b/src/server/get-eattr.sm @@ -78,7 +78,7 @@ static PINT_sm_action geteattr_setup_resp( struct PINT_smcb *smcb, job_status_s *js_p) { struct PINT_server_op *s_op = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); - int i, tsz; + int i; gossip_debug(GOSSIP_GETEATTR_DEBUG,"geteattr requesting %d keys\n", s_op->req->u.geteattr.nkey); @@ -132,7 +132,7 @@ static PINT_sm_action geteattr_setup_resp( return SM_ACTION_COMPLETE; } s_op->resp.u.geteattr.nkey = s_op->req->u.geteattr.nkey; - for (i = 0, tsz = 0; i < s_op->req->u.geteattr.nkey; i++) + for (i = 0; i < s_op->req->u.geteattr.nkey; i++) { s_op->resp.u.geteattr.val[i].buffer = malloc( s_op->req->u.geteattr.valsz[i]); diff --git a/src/server/list-eattr.sm b/src/server/list-eattr.sm index 441dde4..ec6a559 100644 --- a/src/server/list-eattr.sm +++ b/src/server/list-eattr.sm @@ -101,7 +101,8 @@ static PINT_sm_action listeattr_setup_resp( { gossip_debug(GOSSIP_LISTEATTR_DEBUG, "%s: requested key %d " "size of %ld is greater than maximum of %d\n", - __func__, i, (int64_t)s_op->req->u.listeattr.keysz[i], + __func__, i, + ((long int)s_op->req->u.listeattr.keysz[i]), PVFS_MAX_XATTR_NAMELEN ); js_p->error_code = -PVFS_EINVAL; return SM_ACTION_COMPLETE; diff --git a/src/server/mirror.sm b/src/server/mirror.sm index 7530ca2..13e325d 100644 --- a/src/server/mirror.sm +++ b/src/server/mirror.sm @@ -145,9 +145,12 @@ nested machine pvfs2_mirror_work_sm /*START OF pvfs2_mirror_sm*/ static PINT_sm_action inspect_inputs(struct PINT_smcb *smcb, job_status_s *js_p) { - gossip_debug(GOSSIP_MIRROR_DEBUG,"Executing mirror:inspect_inputs....\n"); - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tframe count is %d.\n",smcb->frame_count); - gossip_debug(GOSSIP_MIRROR_DEBUG,"\t base frame is %d.\n",smcb->base_frame); + gossip_debug(GOSSIP_MIRROR_DEBUG, + "Executing mirror:inspect_inputs....\n"); + gossip_debug(GOSSIP_MIRROR_DEBUG, + "\tframe count is %d.\n",smcb->frame_count); + gossip_debug(GOSSIP_MIRROR_DEBUG, + "\t base frame is %d.\n",smcb->base_frame); struct PINT_server_op *s_op = PINT_sm_frame(smcb,PINT_FRAME_CURRENT); struct PVFS_servreq_mirror *reqmir_p = &(s_op->req->u.mirror); int i; @@ -166,35 +169,33 @@ static PINT_sm_action inspect_inputs(struct PINT_smcb *smcb, job_status_s *js_p) "\tmirror.dist.name:%s" "\tmirror.bsize:%d" "\tmirror.src_server_nr:%d" - "\n" - ,s_op->req->op - ,llu(reqmir_p->src_handle) - ,reqmir_p->dst_count - ,reqmir_p->fs_id - ,reqmir_p->dist->dist_name - ,reqmir_p->bsize - ,reqmir_p->src_server_nr); + "\n", + s_op->req->op, + llu(reqmir_p->src_handle) , + reqmir_p->dst_count, + reqmir_p->fs_id, + reqmir_p->dist->dist_name, + reqmir_p->bsize, + reqmir_p->src_server_nr); for (i=0; idst_count; i++) - gossip_debug(GOSSIP_MIRROR_DEBUG,"\treqmir->dst_handle[%d] : %llu\n" - ,i - ,llu(reqmir_p->dst_handle[i])); + gossip_debug(GOSSIP_MIRROR_DEBUG, "\treqmir->dst_handle[%d] : %llu\n", + i, llu(reqmir_p->dst_handle[i])); } - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tds_attr.b_size:%d\n" - ,(int)s_op->ds_attr.u.datafile.b_size); - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tobject type:%0x\n" - ,(int)s_op->attr.objtype); - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tdatafile size:%d\n" - ,(int)s_op->attr.u.data.size); - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tmask:%0x\n" - ,s_op->attr.mask); + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tds_attr.b_size:%d\n", + (int)s_op->ds_attr.u.datafile.b_size); + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tobject type:%0x\n", + (int)s_op->attr.objtype); + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tdatafile size:%d\n", + (int)s_op->attr.u.data.size); + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tmask:%0x\n", s_op->attr.mask); return SM_ACTION_COMPLETE; }/*end action inspect_inputs*/ -static PINT_sm_action mirror_cleanup( struct PINT_smcb *smcb - ,job_status_s *js_p) +static PINT_sm_action mirror_cleanup( struct PINT_smcb *smcb, + job_status_s *js_p) { return(server_state_machine_complete(smcb)); @@ -209,10 +210,12 @@ static PINT_sm_action mirror_cleanup( struct PINT_smcb *smcb static PINT_sm_action initialize_structures(struct PINT_smcb *smcb ,job_status_s *js_p) { - gossip_debug(GOSSIP_MIRROR_DEBUG,"Executing mirror:" - "initialize_structures...\n"); - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tframe count is %d.\n",smcb->frame_count); - gossip_debug(GOSSIP_MIRROR_DEBUG,"\t base frame is %d.\n",smcb->base_frame); + gossip_debug(GOSSIP_MIRROR_DEBUG, "Executing mirror:" + "initialize_structures...\n"); + gossip_debug(GOSSIP_MIRROR_DEBUG, + "\tframe count is %d.\n", smcb->frame_count); + gossip_debug(GOSSIP_MIRROR_DEBUG, + "\t base frame is %d.\n", smcb->base_frame); struct PINT_server_op *s_op = PINT_sm_frame(smcb,PINT_FRAME_CURRENT); struct PVFS_servreq_mirror *reqmir_p = &(s_op->req->u.mirror); @@ -226,9 +229,9 @@ static PINT_sm_action initialize_structures(struct PINT_smcb *smcb memset(respmir_p,0,sizeof(*respmir_p)); - respmir_p->src_handle = reqmir_p->src_handle; - respmir_p->src_server_nr = reqmir_p->src_server_nr; - respmir_p->dst_count = reqmir_p->dst_count; + respmir_p->src_handle = reqmir_p->src_handle; + respmir_p->src_server_nr = reqmir_p->src_server_nr; + respmir_p->dst_count = reqmir_p->dst_count; respmir_p->bytes_written = malloc(sizeof(uint32_t) * respmir_p->dst_count); if (!respmir_p->bytes_written) @@ -237,7 +240,8 @@ static PINT_sm_action initialize_structures(struct PINT_smcb *smcb js_p->error_code = -PVFS_ENOMEM; return SM_ACTION_COMPLETE; } - memset(respmir_p->bytes_written,0,sizeof(uint32_t) * respmir_p->dst_count); + memset(respmir_p->bytes_written, 0, + sizeof(uint32_t) * respmir_p->dst_count); respmir_p->write_status_code = malloc(sizeof(uint32_t) * respmir_p->dst_count); @@ -247,8 +251,8 @@ static PINT_sm_action initialize_structures(struct PINT_smcb *smcb js_p->error_code = -PVFS_ENOMEM; return SM_ACTION_COMPLETE; } - memset(respmir_p->write_status_code,0,sizeof(uint32_t) * - respmir_p->dst_count); + memset(respmir_p->write_status_code, 0, sizeof(uint32_t) * + respmir_p->dst_count); if (reqmir_p->bsize == 0) { @@ -266,19 +270,19 @@ static PINT_sm_action initialize_structures(struct PINT_smcb *smcb "\tmirror.bsize:%d" "\tmirror.src_server_nr:%d" "\tmirror.dst_count:%d" - "\n" - ,s_op->req->op - ,llu(reqmir_p->src_handle) - ,reqmir_p->fs_id - ,reqmir_p->dist->dist_name - ,reqmir_p->bsize - ,reqmir_p->src_server_nr - ,reqmir_p->dst_count); + "\n", + s_op->req->op, + llu(reqmir_p->src_handle), + reqmir_p->fs_id, + reqmir_p->dist->dist_name, + reqmir_p->bsize, + reqmir_p->src_server_nr, + reqmir_p->dst_count); for (i=0; idst_count; i++) { - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tmirror.dst_handle[%d] : %llu\n" - ,i - ,llu(reqmir_p->dst_handle[i])); + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tmirror.dst_handle[%d] : %llu\n", + i, + llu(reqmir_p->dst_handle[i])); } } @@ -299,26 +303,26 @@ static PINT_sm_action initialize_structures(struct PINT_smcb *smcb if (s_op->scheduled_id != 0) return SM_ACTION_COMPLETE; - ret = job_req_sched_post(s_op->op - ,reqmir_p->fs_id - ,reqmir_p->src_handle - ,PINT_server_req_get_access_type(s_op->req) - ,PINT_server_req_get_sched_policy(s_op->req) - ,smcb - ,0 - ,js_p - ,&(s_op->scheduled_id) - ,server_job_context); + ret = job_req_sched_post(s_op->op, + reqmir_p->fs_id, + reqmir_p->src_handle, + PINT_server_req_get_access_type(s_op->req), + PINT_server_req_get_sched_policy(s_op->req), + smcb, + 0, + js_p, + &(s_op->scheduled_id), + server_job_context); return (ret); }/*end action initialize_structures*/ -static PINT_sm_action setup_write_request(struct PINT_smcb *smcb - ,job_status_s *js_p) +static PINT_sm_action setup_write_request(struct PINT_smcb *smcb, + job_status_s *js_p) { - gossip_debug(GOSSIP_MIRROR_DEBUG,"Executing mirror:" - "setup_write_request.....\n"); + gossip_debug(GOSSIP_MIRROR_DEBUG, "Executing mirror:" + "setup_write_request.....\n"); struct PINT_server_op *s_op = PINT_sm_frame(smcb,PINT_FRAME_CURRENT); struct PVFS_servreq_mirror *reqmir_p = &(s_op->req->u.mirror); @@ -332,7 +336,7 @@ static PINT_sm_action setup_write_request(struct PINT_smcb *smcb /*initialize msgarray_op structure*/ PINT_sm_msgarray_op *msgarray_op = &(s_op->msgarray_op); - memset(msgarray_op,0,sizeof(PINT_sm_msgarray_op)); + memset(msgarray_op, 0, sizeof(PINT_sm_msgarray_op)); /*parameters are setup like a client except for job_context*/ PINT_serv_init_msgarray_params(s_op,reqmir_p->fs_id); @@ -348,19 +352,19 @@ static PINT_sm_action setup_write_request(struct PINT_smcb *smcb /*setup msgpairarray to initiate PVFS_SERV_IO write request for the */ /*destination handles. */ - for (i=0; idst_count; i++) + for (i=0; i < reqmir_p->dst_count; i++) { PINT_sm_msgpair_state *msg_p = &(msgarray_op->msgarray[i]); - msg_p->fs_id = reqmir_p->fs_id; - msg_p->handle = reqmir_p->dst_handle[i]; + msg_p->fs_id = reqmir_p->fs_id; + msg_p->handle = reqmir_p->dst_handle[i]; msg_p->retry_flag = PVFS_MSGPAIR_RETRY; - msg_p->comp_fn = write_comp_fn; + msg_p->comp_fn = write_comp_fn; /*determine the BMI svr address for the destination handle*/ - ret = PINT_cached_config_map_to_server(&msg_p->svr_addr - ,msg_p->handle - ,msg_p->fs_id ); + ret = PINT_cached_config_map_to_server(&msg_p->svr_addr, + msg_p->handle, + msg_p->fs_id ); if (ret) { gossip_lerr("Failed to map address\n"); @@ -373,21 +377,21 @@ static PINT_sm_action setup_write_request(struct PINT_smcb *smcb /*setup the server PVFS_SERV_IO write request itself*/ - gossip_debug(GOSSIP_MIRROR_DEBUG,"\treqmir_p->bsize:%d.\n" - ,reqmir_p->bsize); - PINT_SERVREQ_IO_FILL( msg_p->req - ,s_op->req->credentials - ,reqmir_p->fs_id - ,reqmir_p->dst_handle[i] - ,PVFS_IO_WRITE - ,reqmir_p->flow_type - ,0 - ,1 - ,reqmir_p->dist - ,myFileReq - ,myFileReqOffset - ,reqmir_p->bsize - ,NULL ); + gossip_debug(GOSSIP_MIRROR_DEBUG, "\treqmir_p->bsize:%d.\n", + reqmir_p->bsize); + PINT_SERVREQ_IO_FILL( msg_p->req, + s_op->req->credentials, + reqmir_p->fs_id, + reqmir_p->dst_handle[i], + PVFS_IO_WRITE, + reqmir_p->flow_type, + 0, + 1, + reqmir_p->dist, + myFileReq, + myFileReqOffset, + reqmir_p->bsize, + NULL ); }/*end for*/ PINT_sm_push_frame(smcb,0,msgarray_op); @@ -397,10 +401,11 @@ static PINT_sm_action setup_write_request(struct PINT_smcb *smcb }/*end action setup_write_request*/ -static PINT_sm_action cleanup_msgpairarray( struct PINT_smcb *smcb - , job_status_s *js_p) +static PINT_sm_action cleanup_msgpairarray( struct PINT_smcb *smcb, + job_status_s *js_p) { - gossip_debug(GOSSIP_MIRROR_DEBUG,"Executing MIRROR:cleanup_msgpairarray\n"); + gossip_debug(GOSSIP_MIRROR_DEBUG, + "Executing MIRROR:cleanup_msgpairarray\n"); struct PINT_server_op *s_op = PINT_sm_frame(smcb,PINT_FRAME_CURRENT); struct PVFS_servreq_mirror *reqmir_p = &(s_op->req->u.mirror); @@ -413,8 +418,8 @@ static PINT_sm_action cleanup_msgpairarray( struct PINT_smcb *smcb js_p->error_code = 0; gossip_debug(GOSSIP_MIRROR_DEBUG,"\tCURRENT:\tsmcb->base_frame:%d" - "\tframe_count:%d\n" - ,smcb->base_frame,smcb->frame_count); + "\tframe_count:%d\n", + smcb->base_frame,smcb->frame_count); /*if ALL msgpairs have errors, then set an error code and skip the rest */ /*of this request. */ @@ -431,12 +436,14 @@ static PINT_sm_action cleanup_msgpairarray( struct PINT_smcb *smcb /*retain the session/flow identifier created in the PVFS_SERV_IO request */ /*for each destination handle. */ - for (i=0; idst_count; i++) + for (i=0; i < reqmir_p->dst_count; i++) { if (jobs[i].io_status == 0) { jobs[i].session_tag = msgarray_op->msgarray[i].session_tag; - } else { + } + else + { jobs[i].session_tag = 0; /*session tags are NEVER zero*/ /*PINT_util_get_next_tag() */ } @@ -446,12 +453,12 @@ static PINT_sm_action cleanup_msgpairarray( struct PINT_smcb *smcb PINT_msgpairarray_destroy(msgarray_op); gossip_debug(GOSSIP_MIRROR_DEBUG,"\tIO_STATUS & SESSION TAG\n"); - for (i=0; idst_count; i++) + for (i=0; i < reqmir_p->dst_count; i++) { gossip_debug(GOSSIP_MIRROR_DEBUG,"\t\tio_status[%d]:%d " - "\tsession_tag[%d]:%d\n" - ,i,jobs[i].io_status - ,i,jobs[i].session_tag); + "\tsession_tag[%d]:%d\n", + i, jobs[i].io_status, + i, jobs[i].session_tag); } @@ -460,17 +467,14 @@ static PINT_sm_action cleanup_msgpairarray( struct PINT_smcb *smcb return SM_ACTION_COMPLETE; }/*end action cleanup_msgpairarray*/ - - - -static PINT_sm_action post_ack_and_flow (struct PINT_smcb *smcb - ,job_status_s *js_p) +static PINT_sm_action post_ack_and_flow (struct PINT_smcb *smcb, + job_status_s *js_p) { gossip_debug(GOSSIP_MIRROR_DEBUG,"Executing mirror:post_ack_and_flow..\n"); struct PINT_server_op *s_op = PINT_sm_frame(smcb,PINT_FRAME_CURRENT); struct PVFS_servreq_mirror *reqmir_p = &(s_op->req->u.mirror); - PINT_server_mirror_op *mir_op = &(s_op->u.mirror); + PINT_server_mirror_op *mir_op = &(s_op->u.mirror); write_job_t *jobs = mir_op->jobs; int ret,i; @@ -479,10 +483,11 @@ static PINT_sm_action post_ack_and_flow (struct PINT_smcb *smcb js_p->error_code = 0; mir_op->job_count = 0; - mir_op->max_resp_sz = PINT_encode_calc_max_size( PINT_ENCODE_RESP - ,PVFS_SERV_WRITE_COMPLETION - ,reqmir_p->encoding ); - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tmax_resp_sz:%d\n",mir_op->max_resp_sz); + mir_op->max_resp_sz = PINT_encode_calc_max_size( PINT_ENCODE_RESP, + PVFS_SERV_WRITE_COMPLETION, + reqmir_p->encoding ); + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tmax_resp_sz:%d\n", + mir_op->max_resp_sz); /*get flow info from the server configuration file.*/ struct filesystem_configuration_s *cur_fs = NULL; @@ -492,20 +497,20 @@ static PINT_sm_action post_ack_and_flow (struct PINT_smcb *smcb cur_fs = PINT_config_find_fs_id(server_config,reqmir_p->fs_id); /*post write-ack and flow for each destination handle*/ - for (i=0; idst_count; i++) + for (i=0; i < reqmir_p->dst_count; i++) { - /*if the initial IO request for this destination handle failed, then */ - /*skip it. */ + /* if the initial IO request for this destination handle failed, then + * skip it. */ if (jobs[i].io_status != 0) { - gossip_debug(GOSSIP_MIRROR_DEBUG,"io_status[%d] : %d ...skipping\n" - ,i,jobs[i].io_status); + gossip_debug(GOSSIP_MIRROR_DEBUG,"io_status[%d] : %d ...skipping\n", + i, jobs[i].io_status); continue; } - jobs[i].encoded_resp_p = BMI_memalloc( jobs[i].svr_addr - ,mir_op->max_resp_sz - ,BMI_RECV ); + jobs[i].encoded_resp_p = BMI_memalloc( jobs[i].svr_addr, + mir_op->max_resp_sz, + BMI_RECV ); if (!jobs[i].encoded_resp_p) { gossip_lerr("mirror:BMI_memalloc (for write ack) failed.\n"); @@ -515,27 +520,28 @@ static PINT_sm_action post_ack_and_flow (struct PINT_smcb *smcb gossip_debug(GOSSIP_MIRROR_DEBUG,"\tencoded response successfully " "allocated.\n"); - /*pre-post this recv with an infinite timeout and adjust it after the */ - /*flow completes, since we don't know how long a flow can take at this */ - /*point. */ - gossip_debug(GOSSIP_MIRROR_DEBUG,"\trecv_id:%d\n",(int)jobs[i].recv_id); + /* pre-post this recv with an infinite timeout and adjust it after the + * flow completes, since we don't know how long a flow can take at this + * point. */ + gossip_debug(GOSSIP_MIRROR_DEBUG, "\trecv_id:%d\n", + (int)jobs[i].recv_id); status_user_tag = TAG(WRITE_ACK_RCV,i); - ret = job_bmi_recv( jobs[i].svr_addr - ,jobs[i].encoded_resp_p - ,mir_op->max_resp_sz - ,jobs[i].session_tag - ,BMI_PRE_ALLOC - ,smcb - ,status_user_tag - ,&(jobs[i].recv_status) - ,&(jobs[i].recv_id) - ,server_job_context - ,JOB_TIMEOUT_INF - ,NULL ); - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tWRITE_ACK_RCV:return code:%d\n" - ,ret); - /*we expect this job to __not__ complete immediately, since we have not*/ - /*posted the flow. */ + ret = job_bmi_recv( jobs[i].svr_addr, + jobs[i].encoded_resp_p, + mir_op->max_resp_sz, + jobs[i].session_tag, + BMI_PRE_ALLOC, + smcb, + status_user_tag, + &(jobs[i].recv_status), + &(jobs[i].recv_id), + server_job_context, + JOB_TIMEOUT_INF, + NULL ); + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tWRITE_ACK_RCV:return code:%d\n", + ret); + /* we expect this job to __not__ complete immediately, since we have not + * posted the flow. */ if (ret == 1 && jobs[i].recv_status.error_code) { /*Error posting the job*/ @@ -544,32 +550,32 @@ static PINT_sm_action post_ack_and_flow (struct PINT_smcb *smcb } else if (ret == 1) { - /*Job completed immediately with no errors. In this context, */ - /*immediate completion is an error. */ - js_p->error_code = -EPERM; /*operation not permitted.*/ + /* Job completed immediately with no errors. In this context, + * immediate completion is an error. */ + js_p->error_code = -EPERM; // operation not permitted. continue; } else if (ret != 0) { - /*Error adding job to the job_time_mgr*/ + /* Error adding job to the job_time_mgr */ js_p->error_code = ret; continue; } - /*increment once for successful post of write-ack*/ + /* increment once for successful post of write-ack */ mir_op->job_count++; - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tWrite ACK recv successfully posted." - "\tjob_id:%d \tjob_count:%d\n" - ,(int)jobs[i].recv_id,mir_op->job_count); - - - /*issue flow request for the src datahandle using the session tag */ - /* obtained from the PVFS_SERV_IO request. */ - /* */ - /*setup the flow descriptor. Read from the src datahandle and send to */ - /*the destination BMI endpoint. The PVFS_SERV_IO has already setup the*/ - /*other end of the flow (BMI src/TROVE dest). */ + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tWrite ACK recv successfully posted." + "\tjob_id:%d \tjob_count:%d\n", + (int)jobs[i].recv_id, + mir_op->job_count); + + /* issue flow request for the src datahandle using the session tag + * obtained from the PVFS_SERV_IO request. + * + * setup the flow descriptor. Read from the src datahandle and send to + * the destination BMI endpoint. The PVFS_SERV_IO has already setup the + * other end of the flow (BMI src/TROVE dest). */ jobs[i].flow_desc = PINT_flow_alloc(); if (!jobs[i].flow_desc) { @@ -582,61 +588,61 @@ static PINT_sm_action post_ack_and_flow (struct PINT_smcb *smcb PINT_flow_reset(jobs[i].flow_desc); - jobs[i].flow_desc->src.endpoint_id = TROVE_ENDPOINT; - jobs[i].flow_desc->src.u.trove.handle = reqmir_p->src_handle; + jobs[i].flow_desc->src.endpoint_id = TROVE_ENDPOINT; + jobs[i].flow_desc->src.u.trove.handle = reqmir_p->src_handle; jobs[i].flow_desc->src.u.trove.coll_id = reqmir_p->fs_id; - jobs[i].flow_desc->dest.endpoint_id = BMI_ENDPOINT; + jobs[i].flow_desc->dest.endpoint_id = BMI_ENDPOINT; jobs[i].flow_desc->dest.u.bmi.address = jobs[i].svr_addr; - jobs[i].flow_desc->buffer_size = cur_fs->fp_buffer_size; + jobs[i].flow_desc->buffer_size = cur_fs->fp_buffer_size; jobs[i].flow_desc->buffers_per_flow = cur_fs->fp_buffers_per_flow; jobs[i].flow_desc->file_data.extend_flag = 1; - jobs[i].flow_desc->file_data.fsize = reqmir_p->bsize; - jobs[i].flow_desc->file_data.dist = reqmir_p->dist; - jobs[i].flow_desc->file_data.server_nr = 0; - jobs[i].flow_desc->file_data.server_ct = 1; + jobs[i].flow_desc->file_data.fsize = reqmir_p->bsize; + jobs[i].flow_desc->file_data.dist = reqmir_p->dist; + jobs[i].flow_desc->file_data.server_nr = 0; + jobs[i].flow_desc->file_data.server_ct = 1; - jobs[i].flow_desc->file_req = PVFS_BYTE; - jobs[i].flow_desc->file_req_offset = 0; - jobs[i].flow_desc->mem_req = NULL; + jobs[i].flow_desc->file_req = PVFS_BYTE; + jobs[i].flow_desc->file_req_offset = 0; + jobs[i].flow_desc->mem_req = NULL; - jobs[i].flow_desc->tag = jobs[i].session_tag; - jobs[i].flow_desc->type = reqmir_p->flow_type; - jobs[i].flow_desc->user_ptr = NULL; - jobs[i].flow_desc->aggregate_size = reqmir_p->bsize; + jobs[i].flow_desc->tag = jobs[i].session_tag; + jobs[i].flow_desc->type = reqmir_p->flow_type; + jobs[i].flow_desc->user_ptr = NULL; + jobs[i].flow_desc->aggregate_size = reqmir_p->bsize; gossip_debug(GOSSIP_MIRROR_DEBUG,"\tbsize:%lld \tdatafile:nr:%d\tct:%d" - "\toffset:%lld \ttag:%d\n" - ,lld(jobs[i].flow_desc->file_data.fsize) - ,jobs[i].flow_desc->file_data.server_nr - ,jobs[i].flow_desc->file_data.server_ct - ,lld(jobs[i].flow_desc->file_req_offset) - ,jobs[i].flow_desc->tag ); - - /*post the flow*/ + "\toffset:%lld \ttag:%d\n", + lld(jobs[i].flow_desc->file_data.fsize), + jobs[i].flow_desc->file_data.server_nr, + jobs[i].flow_desc->file_data.server_ct, + lld(jobs[i].flow_desc->file_req_offset), + jobs[i].flow_desc->tag ); + + /* post the flow */ status_user_tag = TAG(SRC_FLOW_POST,i); - ret = job_flow( jobs[i].flow_desc - ,smcb - ,status_user_tag - ,&(jobs[i].flow_status) - ,&(jobs[i].flow_job_id) - ,server_job_context - ,server_config->server_job_flow_timeout - ,NULL ); - - /*if the flow fails immediately, then we have to do some special */ - /*handling. This function is not equipped to handle the failure */ - /*directly, so instead we post a null job that will propagate the error */ - /*to the normal state where we interpret flow errors. */ - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tSRC_FLOW_POST:return code:%d\n" - ,ret); - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tflow job id:%d\n" - ,(int)jobs[i].flow_job_id); + ret = job_flow( jobs[i].flow_desc, + smcb, + status_user_tag, + &(jobs[i].flow_status), + &(jobs[i].flow_job_id), + server_job_context, + server_config->server_job_flow_timeout, + NULL ); + + /* if the flow fails immediately, then we have to do some special + * handling. This function is not equipped to handle the failure + * directly, so instead we post a null job that will propagate the error + * to the normal state where we interpret flow errors. */ + gossip_debug(GOSSIP_MIRROR_DEBUG,"\tSRC_FLOW_POST:return code:%d\n", + ret); + gossip_debug(GOSSIP_MIRROR_DEBUG,"\tflow job id:%d\n", + (int)jobs[i].flow_job_id); if (ret<0) { - /* a failure occured while adding this job to the job_time_mgr*/ + /* a failure occured while adding this job to the job_time_mgr */ js_p->error_code = ret; job_bmi_cancel(jobs[i].recv_id,server_job_context); mir_op->job_count--; @@ -644,157 +650,162 @@ static PINT_sm_action post_ack_and_flow (struct PINT_smcb *smcb } else if (ret == 1 && jobs[i].flow_status.error_code == 0) { - /*job completed immediately AND was successful*/ + /* job completed immediately AND was successful */ js_p->error_code = 0; - /*increment job_count again for successful post of flow*/ + /* increment job_count again for successful post of flow */ mir_op->job_count++; continue; } else if (jobs[i].flow_status.error_code) { - /*job completed immediately AND was NOT successful*/ + /* job completed immediately AND was NOT successful */ js_p->error_code = jobs[i].flow_status.error_code; job_bmi_cancel(jobs[i].recv_id,server_job_context); mir_op->job_count--; continue; } - /*increment job_count again for successful post of flow*/ + /* increment job_count again for successful post of flow */ mir_op->job_count++; gossip_debug(GOSSIP_MIRROR_DEBUG,"\tsuccessfully posted flow " - "\tjob_count : %d...\n" - ,mir_op->job_count); - }/*end for each destination handle*/ - - /*if the job_count > 0, then at least one of the IO requests was successful */ - /*and the submission of the write-ack and flow were also successful. */ - if (mir_op->job_count > 0) - return SM_ACTION_DEFERRED; - else - { - /*if job_count is zero, then nothing worked.*/ - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tNo jobs successfully posted in " - "post_ack_and_flow : %d\n" - ,js_p->error_code); - js_p->error_code = -PVFS_EIO; - return SM_ACTION_COMPLETE; - } -}/*end action post_ack_and_flow*/ - - -static PINT_sm_action check_comm ( struct PINT_smcb *smcb - ,job_status_s *js_p) -{ - gossip_debug(GOSSIP_MIRROR_DEBUG,"Executing check_comm...\n"); + "\tjob_count : %d...\n", + mir_op->job_count); + } /* end for each destination handle */ + + /* if the job_count > 0, then at least one of the IO requests was + * successful + * and the submission of the write-ack and flow were also successful. */ + if (mir_op->job_count > 0) + return SM_ACTION_DEFERRED; + else + { + /* if job_count is zero, then nothing worked. */ + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tNo jobs successfully posted in " + "post_ack_and_flow : %d\n", + js_p->error_code); + js_p->error_code = -PVFS_EIO; + return SM_ACTION_COMPLETE; + } +} /* end action post_ack_and_flow */ - struct PINT_server_op *s_op = PINT_sm_frame(smcb,PINT_FRAME_CURRENT); - struct PVFS_servreq_mirror *reqmir_p = &(s_op->req->u.mirror); - PINT_server_mirror_op *mir_op = &(s_op->u.mirror); - write_job_t *jobs = mir_op->jobs; +static PINT_sm_action check_comm ( struct PINT_smcb *smcb, job_status_s *js_p) +{ + gossip_debug(GOSSIP_MIRROR_DEBUG,"Executing check_comm...\n"); - job_aint status_user_tag = js_p->status_user_tag; - int ret,i; + struct PINT_server_op *s_op = PINT_sm_frame(smcb,PINT_FRAME_CURRENT); + struct PVFS_servreq_mirror *reqmir_p = &(s_op->req->u.mirror); - struct filesystem_configuration_s *cur_fs = NULL; - struct server_configuration_s *server_config = NULL; + PINT_server_mirror_op *mir_op = &(s_op->u.mirror); + write_job_t *jobs = mir_op->jobs; - server_config = get_server_config_struct(); - cur_fs = PINT_config_find_fs_id(server_config,reqmir_p->fs_id); + job_aint status_user_tag = js_p->status_user_tag; + int ret,i; - /*status_user_tag's will only exist for those destination handles that had */ - /*successful posts of a write-ack and flow. */ - switch(PHASE(status_user_tag)) - { - case SRC_FLOW_POST: - { - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tReceived SRC_FLOW_POST for " - "dst(%d)...\n" - ,(int)DST(status_user_tag)); - i = (int)DST(status_user_tag); - jobs[i].flow_status = *js_p; - mir_op->job_count--; - if (mir_op->job_count > 0) - { - ret = job_reset_timeout(jobs[i].recv_id - ,server_config->server_job_bmi_timeout); - if (ret == 0 || ret == -PVFS_EINVAL) - { - gossip_debug(GOSSIP_MIRROR_DEBUG,"\ttimeout reset:%d(%0x)\n" - ,ret,ret); - /*ack was reset or it has already completed.*/ - } - else - { - gossip_lerr("Unable to reset timeout"); - return(ret); - } - } - break; - } - case WRITE_ACK_RCV: - { - i=(int)DST(status_user_tag); - jobs[i].recv_status = *js_p; - mir_op->job_count--; - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tReceived WRITE_ACK_RCV for " - "dst(%d)...\n" - ,(int)DST(status_user_tag)); - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tjob_count:%d\n" - ,mir_op->job_count); - gossip_debug(GOSSIP_MIRROR_DEBUG,"\trecv_status.error_code:%d\n" - ,jobs[i].recv_status.error_code); - break; - } - default: - { - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tReceived unknown:%d\n" - ,(int)status_user_tag); - mir_op->job_count = 0; - break; - } - }/*end switch*/ + struct filesystem_configuration_s *cur_fs = NULL; + struct server_configuration_s *server_config = NULL; - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tjs_p->error_code:%d" - "\tjs_p->actual_size:%d\n" - ,js_p->error_code - ,(int)js_p->actual_size); + server_config = get_server_config_struct(); + cur_fs = PINT_config_find_fs_id(server_config,reqmir_p->fs_id); + + if( cur_fs == NULL ) + { + return -PVFS_EINVAL; + } - js_p->error_code = 0; + /* status_user_tag's will only exist for those destination handles that had + * successful posts of a write-ack and flow. */ + switch(PHASE(status_user_tag)) + { + case SRC_FLOW_POST: + { + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tReceived SRC_FLOW_POST for " + "dst(%d)...\n", + (int)DST(status_user_tag)); + i = (int)DST(status_user_tag); + jobs[i].flow_status = *js_p; + mir_op->job_count--; + if (mir_op->job_count > 0) + { + ret = job_reset_timeout(jobs[i].recv_id, + server_config->server_job_bmi_timeout); + if (ret == 0 || ret == -PVFS_EINVAL) + { + gossip_debug(GOSSIP_MIRROR_DEBUG, + "\ttimeout reset:%d(%0x)\n", ret,ret); + /* ack was reset or it has already completed. */ + } + else + { + gossip_lerr("Unable to reset timeout"); + return(ret); + } + } + break; + } + case WRITE_ACK_RCV: + { + i = (int)DST(status_user_tag); + jobs[i].recv_status = *js_p; + mir_op->job_count--; + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tReceived WRITE_ACK_RCV for " + "dst(%d)...\n", + (int)DST(status_user_tag)); + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tjob_count:%d\n", + mir_op->job_count); + gossip_debug(GOSSIP_MIRROR_DEBUG, "\trecv_status.error_code:%d\n", + jobs[i].recv_status.error_code); + break; + } + default: + { + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tReceived unknown:%d\n", + (int)status_user_tag); + mir_op->job_count = 0; + break; + } + } /* end switch */ + + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tjs_p->error_code:%d" + "\tjs_p->actual_size:%d\n", + js_p->error_code, + (int)js_p->actual_size); - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tjob_count:%d\n",mir_op->job_count); - if (mir_op->job_count) /*more jobs to process*/ - { - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tjs_p->error_code:%d " - "\tjob_count:%d " - "\tleaving deferred\n" - ,js_p->error_code - ,mir_op->job_count); - return SM_ACTION_DEFERRED; - } + js_p->error_code = 0; - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tjs_p->error_code:%d" - "\tjob_count:%d" - "\tleaving complete\n" - ,js_p->error_code - ,mir_op->job_count); + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tjob_count:%d\n", mir_op->job_count); + if (mir_op->job_count) /* more jobs to process */ + { + gossip_debug(GOSSIP_MIRROR_DEBUG,"\tjs_p->error_code:%d " + "\tjob_count:%d " + "\tleaving deferred\n", + js_p->error_code, + mir_op->job_count); + return SM_ACTION_DEFERRED; + } - if (mir_op->job_count == 0) /*no more jobs to process*/ - js_p->error_code = COMM_DONE; + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tjs_p->error_code:%d" + "\tjob_count:%d" + "\tleaving complete\n", + js_p->error_code, + mir_op->job_count); - return SM_ACTION_COMPLETE; -}/*end action check_comm*/ + if (mir_op->job_count == 0) /*no more jobs to process*/ + js_p->error_code = COMM_DONE; + + return SM_ACTION_COMPLETE; +} /* end action check_comm */ -static PINT_sm_action check_results( struct PINT_smcb *smcb - ,job_status_s *js_p ) +static PINT_sm_action check_results( struct PINT_smcb *smcb, + job_status_s *js_p ) { gossip_debug(GOSSIP_MIRROR_DEBUG,"Executing check_results...\n"); - struct PINT_server_op *s_op = PINT_sm_frame(smcb,PINT_FRAME_CURRENT); - struct PVFS_servreq_mirror *reqmir_p = &(s_op->req->u.mirror); + struct PINT_server_op *s_op = PINT_sm_frame(smcb,PINT_FRAME_CURRENT); + struct PVFS_servreq_mirror *reqmir_p = &(s_op->req->u.mirror); struct PVFS_servresp_mirror *respmir_p = &(s_op->resp.u.mirror); - PINT_server_mirror_op *mir_p = &(s_op->u.mirror); + PINT_server_mirror_op *mir_p = &(s_op->u.mirror); write_job_t *jobs = mir_p->jobs; struct PINT_decoded_msg decoded_resp = {0}; @@ -813,58 +824,59 @@ static PINT_sm_action check_results( struct PINT_smcb *smcb } else if (jobs[i].recv_status.error_code) { - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tACK rcv failed:%d\n" - ,jobs[i].recv_status.error_code ); + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tACK rcv failed:%d\n", + jobs[i].recv_status.error_code ); respmir_p->write_status_code[i] = jobs[i].recv_status.error_code; } else if (jobs[i].flow_status.error_code) { - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tFLOW failed:%d\n" - ,jobs[i].flow_status.error_code); + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tFLOW failed:%d\n", + jobs[i].flow_status.error_code); respmir_p->write_status_code[i] = jobs[i].flow_status.error_code; } else { - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tACK & FLOW succeeded\n"); - gossip_debug(GOSSIP_MIRROR_DEBUG,"\trecv_status.actual_size:%d\n" - ,(int)jobs[i].recv_status.actual_size); + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tACK & FLOW succeeded\n"); + gossip_debug(GOSSIP_MIRROR_DEBUG, "\trecv_status.actual_size:%d\n", + (int)jobs[i].recv_status.actual_size); gossip_debug(GOSSIP_MIRROR_DEBUG,"\tparameters sent into " "PINT_serv_decode_resp:\n"); - gossip_debug(GOSSIP_MIRROR_DEBUG,"\t\tfs_id : %d\n" - "\t\t\tencoded_resp_p : %p\n" - "\t\t\tdecoded_resp : %p\n" - "\t\t\tsvr_addr : %ld\n" - "\t\t\tactual_size : %d\n" - "\t\t\tresp : %p\n" - ,reqmir_p->fs_id - ,(void *)jobs[i].encoded_resp_p - ,&decoded_resp - ,(long int)jobs[i].svr_addr - ,(int)jobs[i].recv_status.actual_size - ,resp); - ret = PINT_serv_decode_resp( reqmir_p->fs_id - ,jobs[i].encoded_resp_p - ,&decoded_resp - ,&(jobs[i].svr_addr) - ,jobs[i].recv_status.actual_size - ,&resp ); - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tafter PINT_serv_decode_resp..\n"); + gossip_debug(GOSSIP_MIRROR_DEBUG, "\t\tfs_id : %d\n" + "\t\t\tencoded_resp_p : %p\n" + "\t\t\tdecoded_resp : %p\n" + "\t\t\tsvr_addr : %ld\n" + "\t\t\tactual_size : %d\n" + "\t\t\tresp : %p\n", + reqmir_p->fs_id, + (void *)jobs[i].encoded_resp_p, + &decoded_resp, + (long int)jobs[i].svr_addr, + (int)jobs[i].recv_status.actual_size, + resp); + ret = PINT_serv_decode_resp( reqmir_p->fs_id, + jobs[i].encoded_resp_p, + &decoded_resp, + &(jobs[i].svr_addr), + jobs[i].recv_status.actual_size, + &resp ); + gossip_debug(GOSSIP_MIRROR_DEBUG, + "\tafter PINT_serv_decode_resp..\n"); if (ret == 0) { - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tsession_tag : %d\n" - ,jobs[i].session_tag); + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tsession_tag : %d\n", + jobs[i].session_tag); respmir_p->bytes_written[i] = resp->u.write_completion.total_completed; gossip_debug(GOSSIP_MIRROR_DEBUG,"\tafter bytes_written..\n"); respmir_p->write_status_code[i] = jobs[i].recv_status.error_code; gossip_debug(GOSSIP_MIRROR_DEBUG,"\tafter write_status_code..\n"); PINT_decode_release(&decoded_resp, PINT_DECODE_RESP); - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tbytes written:%d " - "\tresp status:%d " - "\tresp op:%d\n" - ,respmir_p->bytes_written[i] - ,respmir_p->write_status_code[i] - ,resp->op ); + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tbytes written:%d " + "\tresp status:%d " + "\tresp op:%d\n", + respmir_p->bytes_written[i], + respmir_p->write_status_code[i], + resp->op ); } else { @@ -876,16 +888,16 @@ static PINT_sm_action check_results( struct PINT_smcb *smcb if (jobs[i].flow_desc) PINT_flow_free(jobs[i].flow_desc); if (jobs[i].encoded_resp_p) - BMI_memfree( jobs[i].svr_addr - ,jobs[i].encoded_resp_p - ,mir_p->max_resp_sz - ,BMI_RECV); - }/*end for each destination handle*/ - - /*if at least ONE of the writes was successful, then return a zero to indi-*/ - /*cate that ALL status codes must be checked. If NONE of the writes were */ - /*successful, then return a non-zero to indicate that individual statuses */ - /*do not need to be checked. */ + BMI_memfree( jobs[i].svr_addr, + jobs[i].encoded_resp_p, + mir_p->max_resp_sz, + BMI_RECV); + } /* end for each destination handle */ + + /* if at least ONE of the writes was successful, then return a zero to + * indicate that ALL status codes must be checked. If NONE of the writes + * were successful, then return a non-zero to indicate that individual + * statuses do not need to be checked. */ for (i=0; idst_count; i++) { if (respmir_p->write_status_code[i] == 0) @@ -897,29 +909,23 @@ static PINT_sm_action check_results( struct PINT_smcb *smcb js_p->error_code = 0; return SM_ACTION_COMPLETE; -}/*end action check_results*/ - - +} /* end action check_results */ - - - - -static PINT_sm_action cleanup_mirror_work(struct PINT_smcb *smcb - ,job_status_s *js_p) +static PINT_sm_action cleanup_mirror_work(struct PINT_smcb *smcb, + job_status_s *js_p) { gossip_debug(GOSSIP_MIRROR_DEBUG,"Executing cleanup_mirror_work.....\n"); struct PINT_server_op *s_op = PINT_sm_frame(smcb,PINT_FRAME_CURRENT); - struct PVFS_servresp_mirror *respmir_p = &(s_op->resp.u.mirror); - struct PVFS_servreq_mirror *reqmir_p = &(s_op->req->u.mirror); - struct PINT_server_mirror_op *mir_p = &(s_op->u.mirror); + struct PVFS_servresp_mirror *respmir_p = &(s_op->resp.u.mirror); + struct PVFS_servreq_mirror *reqmir_p = &(s_op->req->u.mirror); + struct PINT_server_mirror_op *mir_p = &(s_op->u.mirror); write_job_t *jobs = mir_p->jobs; int i,ret; job_id_t job_id; - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tIN:js_p->error_code:%d\n" - ,js_p->error_code); + gossip_debug(GOSSIP_MIRROR_DEBUG,"\tIN:js_p->error_code:%d\n", + js_p->error_code); if (js_p->error_code == NO_DATA_TO_COPY) { js_p->error_code = 0; @@ -929,40 +935,39 @@ static PINT_sm_action cleanup_mirror_work(struct PINT_smcb *smcb { gossip_debug(GOSSIP_MIRROR_DEBUG,"\tJOBS IO STATUS...\n"); for (i=0; idst_count; i++) - gossip_debug(GOSSIP_MIRROR_DEBUG,"\t\tio_status(%d):%d\n" - ,i - ,(int)jobs[i].io_status); + gossip_debug(GOSSIP_MIRROR_DEBUG,"\t\tio_status(%d):%d\n", i, + (int)jobs[i].io_status); } if (mir_p->jobs) free(mir_p->jobs); - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tOUT:js_p->error_code:%d\n" - ,js_p->error_code); + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tOUT:js_p->error_code:%d\n", + js_p->error_code); - gossip_debug(GOSSIP_MIRROR_DEBUG,"\trespmir_p->src_handle:%llu\n" - ,llu(respmir_p->src_handle)); + gossip_debug(GOSSIP_MIRROR_DEBUG, "\trespmir_p->src_handle:%llu\n", + llu(respmir_p->src_handle)); for (i=0; idst_count; i++) { - gossip_debug(GOSSIP_MIRROR_DEBUG,"\t\tbytes_written[%d]:%d\n" - "\t\t\twrite_status_code[%d]:%d\n" - ,i,respmir_p->bytes_written[i] - ,i,respmir_p->write_status_code[i]); + gossip_debug(GOSSIP_MIRROR_DEBUG, "\t\tbytes_written[%d]:%d\n" + "\t\t\twrite_status_code[%d]:%d\n", + i, respmir_p->bytes_written[i], + i, respmir_p->write_status_code[i]); } - gossip_debug(GOSSIP_MIRROR_DEBUG,"\ts_op->resp.status:%d\n" - ,s_op->resp.status); + gossip_debug(GOSSIP_MIRROR_DEBUG,"\ts_op->resp.status:%d\n", + s_op->resp.status); /*If s_op->schedule_id is non-zero, then we must release the object */ /*from the scheduler. */ if (s_op->scheduled_id) { - ret = job_req_sched_release(s_op->scheduled_id - ,smcb - ,0 - ,js_p - ,&job_id - ,server_job_context); + ret = job_req_sched_release(s_op->scheduled_id, + smcb, + 0, + js_p, + &job_id, + server_job_context); s_op->scheduled_id = 0; gossip_debug(GOSSIP_MIRROR_DEBUG,"\tLeaving cleanup_mirror_work.....\n"); return (ret); @@ -970,19 +975,19 @@ static PINT_sm_action cleanup_mirror_work(struct PINT_smcb *smcb gossip_debug(GOSSIP_MIRROR_DEBUG,"Leaving cleanup_mirror_work.....\n"); return SM_ACTION_COMPLETE; -}/*end action cleanup_mirror_work*/ +} /* end action cleanup_mirror_work */ int write_comp_fn(void *v_p, struct PVFS_server_resp *resp_p, int i) { - /*This function executes AFTER each msgpair has completed and is under the */ - /*control of msgpairarray.sm. Here, we will capture the response from the */ - /*PVFS_SERV_IO request; however, the response pertains only to the initial */ - /*ACK and start of the flow on the remote server. We will retain the status*/ - /*from each response and then check it when we return from the jump to */ - /*msgpairarray. We will always return a zero from this function, even if */ - /*the request failed, so we can check it later. */ + /* This function executes AFTER each msgpair has completed and is under the + * control of msgpairarray.sm. Here, we will capture the response from the + * PVFS_SERV_IO request; however, the response pertains only to the initial + * ACK and start of the flow on the remote server. We will retain the status + * from each response and then check it when we return from the jump to + * msgpairarray. We will always return a zero from this function, even if + * the request failed, so we can check it later. */ gossip_debug(GOSSIP_MIRROR_DEBUG,"Executing write_comp_fn.....\n"); PINT_smcb *smcb = v_p; @@ -990,42 +995,36 @@ int write_comp_fn(void *v_p, struct PVFS_server_resp *resp_p, int i) struct PINT_server_mirror_op *mir_p = &(s_op->u.mirror); write_job_t *jobs = mir_p->jobs; - /*resp_p contains the response from the PVFS_SERV_IO request after it */ - /*has posted its initial write ack and flow. */ - + /* resp_p contains the response from the PVFS_SERV_IO request after it + * has posted its initial write ack and flow. */ jobs[i].io_status = resp_p->status; - - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tInitial ACK from IO write request(%d). " - "bstream_size is %d.\n" - ,i - ,(int)resp_p->u.io.bstream_size); - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tstatus:%d\n",(int)jobs[i].io_status); + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tInitial ACK from IO write request(%d). " + "bstream_size is %d.\n", + i, + (int)resp_p->u.io.bstream_size); + gossip_debug(GOSSIP_MIRROR_DEBUG, "\tstatus:%d\n", (int)jobs[i].io_status); if (resp_p->status != 0) { gossip_debug(GOSSIP_MIRROR_DEBUG,"\tNegative response from " - "PVFS_SERV_IO:%d\n" - ,resp_p->status); + "PVFS_SERV_IO:%d\n", resp_p->status); } return(0); -} /*end msgpair completion function mirror_comp_fn*/ +} /* end msgpair completion function mirror_comp_fn */ - - - -/*set handle and fs-id ... required by the state machine processor*/ -static inline int PINT_get_object_ref_mirror( struct PVFS_server_req *req - ,PVFS_fs_id *fs_id - ,PVFS_handle *handle ) +/* set handle and fs-id ... required by the state machine processor */ +static inline int PINT_get_object_ref_mirror( struct PVFS_server_req *req, + PVFS_fs_id *fs_id, + PVFS_handle *handle ) { - *fs_id = req->u.mirror.fs_id; - *handle = req->u.mirror.src_handle; + *fs_id = req->u.mirror.fs_id; + *handle = req->u.mirror.src_handle; return 0; }; -/*request parameters*/ +/* request parameters */ struct PINT_server_req_params pvfs2_mirror_params = { .string_name = "mirror", @@ -1035,10 +1034,3 @@ struct PINT_server_req_params pvfs2_mirror_params = .get_object_ref = PINT_get_object_ref_mirror, .state_machine = &pvfs2_mirror_sm }; -/****************************end of file***************************************/ - - - - - - diff --git a/src/server/mkdir.sm b/src/server/mkdir.sm index 068b3a2..52467da 100644 --- a/src/server/mkdir.sm +++ b/src/server/mkdir.sm @@ -318,6 +318,7 @@ static inline int PINT_get_object_ref_mkdir( struct PINT_server_req_params pvfs2_mkdir_params = { .string_name = "mkdir", + .get_object_ref = PINT_get_object_ref_mkdir, .perm = PINT_SERVER_CHECK_NONE, .access_type = PINT_server_req_modify, .state_machine = &pvfs2_mkdir_sm diff --git a/src/server/module.mk.in b/src/server/module.mk.in index 14732af..afbafc7 100644 --- a/src/server/module.mk.in +++ b/src/server/module.mk.in @@ -47,7 +47,8 @@ ifdef BUILD_SERVER $(DIR)/unexpected.c \ $(DIR)/precreate-pool-refiller.c \ $(DIR)/unstuff.c \ - $(DIR)/tree-communicate.c + $(DIR)/tree-communicate.c \ + $(DIR)/mgmt-get-uid.c # c files that should be added to server library SERVERSRC += \ diff --git a/src/server/perf-mon.sm b/src/server/perf-mon.sm index 1c8c0a8..4500e0f 100644 --- a/src/server/perf-mon.sm +++ b/src/server/perf-mon.sm @@ -13,11 +13,11 @@ #include #include "pvfs2-server.h" +#include "pint-util.h" #include "pint-perf-counter.h" -static uint64_t* static_start_time_array_ms = NULL; -static uint64_t* static_interval_array_ms = NULL; -static int64_t** static_value_matrix = NULL; +/* there had better not be but one of these requests at a time */ +static int64_t *static_value_array = NULL; static int static_history_size = 0; static int static_key_count = 0; @@ -25,38 +25,51 @@ static int reallocate_static_arrays_if_needed(void); #define MAX_NEXT_ID 1000000000 +#define STATIC_TIME(i) (static_value_array[((i) * (static_key_count + 2)) \ + + static_key_count]) +#define STATIC_INTV(i) (static_value_array[((i) * (static_key_count + 2)) \ + + static_key_count + 1]) +#define STATIC_SAMP(i) (static_value_array[((i) * (static_key_count + 2))]) + +#define SOP_PERF_SAMP(i) (s_op->resp.u.mgmt_perf_mon.perf_array[((i) \ + * (key_count + 2))]) +#define SOP_PERF_TIME(i) (s_op->resp.u.mgmt_perf_mon.perf_array[((i) \ + * (key_count + 2)) + key_count]) +#define SOP_PERF_INTV(i) (s_op->resp.u.mgmt_perf_mon.perf_array[((i) \ + * (key_count + 2)) + key_count + 1]) + %% machine pvfs2_perf_mon_sm { - state prelude - { - jump pvfs2_prelude_sm; - default => do_work; - } - - state do_work - { - run perf_mon_do_work; - default => final_response; - } - - state final_response - { - jump pvfs2_final_response_sm; - default => cleanup; - } - - state cleanup - { - run perf_mon_cleanup; - default => terminate; - } + state prelude + { + jump pvfs2_prelude_sm; + default => do_work; + } + + state do_work + { + run perf_mon_do_work; + default => final_response; + } + + state final_response + { + jump pvfs2_final_response_sm; + default => cleanup; + } + + state cleanup + { + run perf_mon_cleanup; + default => terminate; + } } %% -/* perf_mon_cleanup() +/** perf_mon_cleanup() * * cleans up any resources consumed by this state machine and ends * execution of the machine @@ -66,12 +79,12 @@ static PINT_sm_action perf_mon_cleanup( { struct PINT_server_op *s_op = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); if(s_op->resp.u.mgmt_perf_mon.perf_array) - free(s_op->resp.u.mgmt_perf_mon.perf_array); + free(s_op->resp.u.mgmt_perf_mon.perf_array); return(server_state_machine_complete(smcb)); } -/* perf_mon_do_work() +/** perf_mon_do_work() * * gathers statistics and builds response */ @@ -79,12 +92,12 @@ static PINT_sm_action perf_mon_do_work( struct PINT_smcb *smcb, job_status_s *js_p) { struct PINT_server_op *s_op = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); - struct timeval tv; int i; int valid_count = 0; uint32_t tmp_next_id; int ret = -1; - int idx; + uint32_t key_count = 0; + uint32_t sample_count = 0; #ifdef __PVFS2_DISABLE_PERF_COUNTERS__ gossip_err("Error: perf_mon request received, but perf counters are disabled.\n"); @@ -92,27 +105,65 @@ static PINT_sm_action perf_mon_do_work( return SM_ACTION_COMPLETE; #endif + /* how many keys and history intervals do we have in the perf counter? */ + ret = PINT_perf_get_info(PINT_server_pc, PINT_PERF_KEY_COUNT, + &key_count); + if(ret < 0) + { + return SM_ACTION_COMPLETE; + return(ret); + } + + /* get no more counters than exist, and no more than requested */ + if (key_count > s_op->req->u.mgmt_perf_mon.key_count) + { + key_count = s_op->req->u.mgmt_perf_mon.key_count; + } + + /* how many keys and history intervals do we have in the perf counter? */ + ret = PINT_perf_get_info(PINT_server_pc, PINT_PERF_HISTORY_SIZE, + &sample_count); + if(ret < 0) + { + js_p->error_code = ret; + return SM_ACTION_COMPLETE; + } + + /* get no more counters than exist, and no more than requested */ + if (sample_count > s_op->req->u.mgmt_perf_mon.count) + { + sample_count = s_op->req->u.mgmt_perf_mon.count; + } + + if (key_count < 1 || sample_count < 1) + { + gossip_err("Error: perf mon request with key_count or sample_count less than 1.\n"); + js_p->error_code = -PVFS_EINVAL; + return SM_ACTION_COMPLETE; + } + /* allocate memory to hold statistics */ s_op->resp.u.mgmt_perf_mon.perf_array - = (struct PVFS_mgmt_perf_stat*)malloc(s_op->req->u.mgmt_perf_mon.count * - sizeof(struct PVFS_mgmt_perf_stat)); + = (int64_t *)malloc(sample_count * (key_count + 2) + * sizeof(int64_t)); if(!s_op->resp.u.mgmt_perf_mon.perf_array) { - js_p->error_code = -PVFS_ENOMEM; - return SM_ACTION_COMPLETE; + js_p->error_code = -PVFS_ENOMEM; + return SM_ACTION_COMPLETE; } + memset(s_op->resp.u.mgmt_perf_mon.perf_array, 0, + sample_count * (key_count + 2) * sizeof(int64_t)); /* fill in some of the response */ - gettimeofday(&tv, NULL); - s_op->resp.u.mgmt_perf_mon.cur_time_ms = tv.tv_sec*1000 + - tv.tv_usec/1000; + s_op->resp.u.mgmt_perf_mon.cur_time_ms = PINT_util_get_time_ms(); s_op->resp.u.mgmt_perf_mon.suggested_next_id - = s_op->req->u.mgmt_perf_mon.next_id; - s_op->resp.u.mgmt_perf_mon.perf_array_count - = s_op->req->u.mgmt_perf_mon.count; + = s_op->req->u.mgmt_perf_mon.next_id; + s_op->resp.u.mgmt_perf_mon.key_count = key_count; + s_op->resp.u.mgmt_perf_mon.perf_array_count = + (key_count + 2) * sample_count; - /* make sure we have scratch memory to use as an intermediate buffer for - * performance counters + /* make sure we have scratch memory to use as an intermediate + * buffer for performance counters */ ret = reallocate_static_arrays_if_needed(); if(ret < 0) @@ -124,22 +175,22 @@ static PINT_sm_action perf_mon_do_work( } PINT_perf_retrieve(PINT_server_pc, - static_value_matrix, - static_start_time_array_ms, - static_interval_array_ms, - static_key_count, - static_history_size); - - /* work through start times, and find the oldest one that is new enough - * to satisfy next_id - * NOTE: we encode hi order bits of timestamp as id values. That - * should be sufficient to maintain compatibility. + static_value_array, + static_key_count, + static_history_size); + + /* we are filling per_array in backwards, but this is the order + * karma and other programs that collect data over multiple + * intervals expect it */ + /* Work through start times, and find the oldest one that + * is new enough to satisfy next_id + * NOTE: we encode hi order bits of timestamp as id values. + * That * should be sufficient to maintain compatibility. */ - for(i=static_history_size-1; i>=0; i--) + valid_count = 0; + for(i = 1; i < static_history_size; i++) { - tmp_next_id = 0; - tmp_next_id += (uint32_t)(static_start_time_array_ms[i] % MAX_NEXT_ID); - + tmp_next_id = STATIC_TIME(i) % MAX_NEXT_ID; /* check three conditions: * 1) that this interval from the perf counter is valid (start time * not zero) @@ -148,74 +199,66 @@ static PINT_sm_action perf_mon_do_work( * 3) if the start time has rolled over within MAX_NEXT_ID */ if(tmp_next_id != 0 && - ((tmp_next_id >= s_op->req->u.mgmt_perf_mon.next_id) || - ((s_op->req->u.mgmt_perf_mon.next_id-tmp_next_id)>(MAX_NEXT_ID/2)))) + ((tmp_next_id >= s_op->req->u.mgmt_perf_mon.next_id) || + ((s_op->req->u.mgmt_perf_mon.next_id - tmp_next_id) > + (MAX_NEXT_ID / 2)))) { - /* found the first valid timestamp */ - valid_count = i+1; - /* compute a next id to suggest that the client use next time - * (newest time plus 1) - */ - tmp_next_id = 0; - tmp_next_id += (uint32_t)(static_start_time_array_ms[0] % - MAX_NEXT_ID); - tmp_next_id += 1; - s_op->resp.u.mgmt_perf_mon.suggested_next_id = tmp_next_id; + /* found oldest valid sample */ break; } - } - if(valid_count > s_op->req->u.mgmt_perf_mon.count) - { - valid_count = s_op->req->u.mgmt_perf_mon.count; - } - - /* fill in all of the valid values */ - for(i=0; ireq->u.mgmt_perf_mon.count; i++) + } + /* now copy newer, valid samples */ + for(; i < static_history_size && valid_count < sample_count; i++) { - if(iresp.u.mgmt_perf_mon.perf_array[idx].valid_flag = 1; - s_op->resp.u.mgmt_perf_mon.perf_array[idx].id = 0; - s_op->resp.u.mgmt_perf_mon.perf_array[idx].id += - (uint32_t)(static_start_time_array_ms[i] % 1000000000); - s_op->resp.u.mgmt_perf_mon.perf_array[idx].start_time_ms = - static_start_time_array_ms[i]; - s_op->resp.u.mgmt_perf_mon.perf_array[idx].read = - static_value_matrix[PINT_PERF_READ][i]; - s_op->resp.u.mgmt_perf_mon.perf_array[idx].write = - static_value_matrix[PINT_PERF_WRITE][i]; - s_op->resp.u.mgmt_perf_mon.perf_array[idx].metadata_read = - static_value_matrix[PINT_PERF_METADATA_READ][i]; - s_op->resp.u.mgmt_perf_mon.perf_array[idx].metadata_write = - static_value_matrix[PINT_PERF_METADATA_WRITE][i]; - s_op->resp.u.mgmt_perf_mon.perf_array[idx].dspace_queue = - static_value_matrix[PINT_PERF_METADATA_DSPACE_OPS][i]; - s_op->resp.u.mgmt_perf_mon.perf_array[idx].keyval_queue = - static_value_matrix[PINT_PERF_METADATA_KEYVAL_OPS][i]; + /* valid sample */ + memcpy(&SOP_PERF_SAMP(valid_count), + &STATIC_SAMP(i), + key_count * sizeof(int64_t)); + memcpy(&SOP_PERF_TIME(valid_count), + &STATIC_TIME(i), + 2 * sizeof(int64_t)); + + valid_count++; } - else + } + if(valid_count < sample_count) + { + /* copy sample zero - the newest sample */ + if(STATIC_TIME(0) != 0) { - s_op->resp.u.mgmt_perf_mon.perf_array[i].valid_flag = 0; + /* valid sample */ + memcpy(&SOP_PERF_SAMP(valid_count), + &STATIC_SAMP(0), + key_count * sizeof(int64_t)); + memcpy(&SOP_PERF_TIME(valid_count), + &STATIC_TIME(0), + 2 * sizeof(int64_t)); + + valid_count++; } } - + /* nextid is based on time stamp of last valid sample */ /* set final end time */ if(valid_count > 0) { s_op->resp.u.mgmt_perf_mon.end_time_ms = - static_start_time_array_ms[0] + - static_interval_array_ms[0]; + SOP_PERF_TIME(valid_count-1) + SOP_PERF_INTV(valid_count-1); + s_op->resp.u.mgmt_perf_mon.suggested_next_id = + (SOP_PERF_TIME(valid_count-1) + 1) % MAX_NEXT_ID; + } + else + { + s_op->resp.u.mgmt_perf_mon.end_time_ms = 0; } js_p->error_code = 0; + return SM_ACTION_COMPLETE; } -/* reallocate_static_arrays() +/** reallocate_static_arrays() * * allocates new arrays for temporary storage of performance counter data, * freeing old memory if needed @@ -227,87 +270,46 @@ static int reallocate_static_arrays_if_needed(void) unsigned int history_size; unsigned int key_count; int ret = -1; - int i; /* how many keys and history intervals do we have in the perf counter? */ ret = PINT_perf_get_info(PINT_server_pc, PINT_PERF_KEY_COUNT, - &key_count); + &key_count); if(ret < 0) { return(ret); } + + /* the key count shouldn't change once acquired */ + if (static_key_count == 0) + { + static_key_count = key_count; + } + assert(key_count == static_key_count); + + /* get server history size - this can change */ ret = PINT_perf_get_info(PINT_server_pc, PINT_PERF_HISTORY_SIZE, - &history_size); + &history_size); if(ret < 0) { return(ret); } + /* allocate array if needed */ if(history_size > static_history_size) { - if(static_start_time_array_ms) - { - free(static_start_time_array_ms); - } - if(static_interval_array_ms) + if(static_value_array) { - free(static_interval_array_ms); - } - - /* reallocate time arrays */ - static_start_time_array_ms = - (uint64_t*)malloc(history_size*sizeof(uint64_t)); - if(!static_start_time_array_ms) - { - return(-PVFS_ENOMEM); + free(static_value_array); } - static_interval_array_ms = - (uint64_t*)malloc(history_size*sizeof(uint64_t)); - if(!static_interval_array_ms) + static_value_array = (int64_t *) + malloc(history_size * (key_count + 2) * sizeof(int64_t)); + if(!static_value_array) { - free(static_start_time_array_ms); return(-PVFS_ENOMEM); } - - /* the key count shouldn't change once acquired */ - assert((static_key_count == 0)||(key_count == static_key_count)); - - /* allocate value matrix */ - if(!static_value_matrix) - { - static_value_matrix = - (int64_t**)malloc(key_count*sizeof(int64_t*)); - if(!static_value_matrix) - { - free(static_start_time_array_ms); - free(static_interval_array_ms); - return(-PVFS_ENOMEM); - } - memset(static_value_matrix, 0, key_count*sizeof(int64_t*)); - } - - for(i=0; i=0; i--) - { - free(static_value_matrix[i]); - } - free(static_start_time_array_ms); - free(static_interval_array_ms); - return(-PVFS_ENOMEM); - } - } + static_history_size = history_size; } - /* NOTE: we change the static counts, even if they are decreasing. It is - * ok if the arrays are bigger than needed. - */ - static_history_size = history_size; - static_key_count = key_count; return(0); } diff --git a/src/server/perf-update.sm b/src/server/perf-update.sm index 3aa015c..3230698 100644 --- a/src/server/perf-update.sm +++ b/src/server/perf-update.sm @@ -35,7 +35,7 @@ machine pvfs2_perf_update_sm %% -/* perf_update_error() +/** perf_update_error() * * cleans up any resources consumed by this state machine and ends * execution of the machine @@ -50,7 +50,7 @@ static PINT_sm_action perf_update_error( return(server_state_machine_complete(smcb)); } -/* perf_update_do_work() +/** perf_update_do_work() * * resets counters, updates metrices, etc- this is intended to be called * repeatedly on a regular interval @@ -65,7 +65,6 @@ static PINT_sm_action perf_update_do_work( char* ptr; char* token; char delim[] = "\n"; - struct server_configuration_s *user_opts = get_server_config_struct(); #if 0 PINT_STATE_DEBUG("do_work"); @@ -92,12 +91,12 @@ static PINT_sm_action perf_update_do_work( PINT_perf_rollover(PINT_server_pc); /* post another timer */ - return(job_req_sched_post_timer(user_opts->perf_update_interval, - smcb, - 0, - js_p, - &tmp_id, - server_job_context)); + return(job_req_sched_post_timer(PINT_server_pc->interval, + smcb, + 0, + js_p, + &tmp_id, + server_job_context)); } struct PINT_server_req_params pvfs2_perf_update_params = diff --git a/src/server/pjmp-machines.sm b/src/server/pjmp-machines.sm index 71b2093..1ab252a 100644 --- a/src/server/pjmp-machines.sm +++ b/src/server/pjmp-machines.sm @@ -186,26 +186,23 @@ static PINT_sm_action call_msgpairarray (struct PINT_smcb *smcb gossip_debug(GOSSIP_SERVER_DEBUG,"Executing pvfs2_pjmp_call_msgpairarray_sm:" "call_msgpairarray for operation (%s)\n" ,PINT_map_server_op_to_string(smcb->op)); - gossip_debug(GOSSIP_MIRROR_DEBUG,"Executing pvfs2_pjmp_call_msgpairarray_sm:" - "call_msgpairarray for operation (%s)\n" - ,PINT_map_server_op_to_string(smcb->op)); - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tframe count is %d.\n",smcb->frame_count); - gossip_debug(GOSSIP_MIRROR_DEBUG,"\t base frame is %d.\n",smcb->base_frame); - gossip_debug(GOSSIP_MIRROR_DEBUG,"\t op nbr is #%d.\n",smcb->op); + gossip_debug(GOSSIP_SERVER_DEBUG,"\tframe count is %d.\n",smcb->frame_count); + gossip_debug(GOSSIP_SERVER_DEBUG,"\t base frame is %d.\n",smcb->base_frame); + gossip_debug(GOSSIP_SERVER_DEBUG,"\t op nbr is #%d.\n",smcb->op); struct PINT_server_op *s_op = PINT_sm_frame(smcb,PINT_FRAME_CURRENT); PINT_sm_msgarray_op *msgarray = &(s_op->msgarray_op); - gossip_debug(GOSSIP_MIRROR_DEBUG,"\ts_op:%p\n",s_op); + gossip_debug(GOSSIP_SERVER_DEBUG,"\ts_op:%p\n",s_op); js_p->error_code = 0; - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tmsgarray->msgpair.req.op:%d\n" + gossip_debug(GOSSIP_SERVER_DEBUG,"\tmsgarray->msgpair.req.op:%d\n" ,msgarray->msgpair.req.op ); PINT_sm_push_frame(smcb,0,msgarray); - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tAFTER PUSH:smcb->base_frame:%d" + gossip_debug(GOSSIP_SERVER_DEBUG,"\tAFTER PUSH:smcb->base_frame:%d" "\tframe_count:%d\n" ,smcb->base_frame,smcb->frame_count); @@ -215,24 +212,24 @@ static PINT_sm_action call_msgpairarray (struct PINT_smcb *smcb static PINT_sm_action cleanup_msgpairarray (struct PINT_smcb *smcb ,job_status_s *js_p) { - gossip_debug(GOSSIP_MIRROR_DEBUG,"Executing pvfs2_pjmp_call_msgpairarray_sm:cleanup_msgpairarray" + gossip_debug(GOSSIP_SERVER_DEBUG,"Executing pvfs2_pjmp_call_msgpairarray_sm:cleanup_msgpairarray" "....\n"); struct PINT_server_op *s_op = PINT_sm_frame(smcb,PINT_FRAME_CURRENT); PINT_sm_msgarray_op *msgarray = &(s_op->msgarray_op); - gossip_debug(GOSSIP_MIRROR_DEBUG,"\ts_op:%p\n",s_op); + gossip_debug(GOSSIP_SERVER_DEBUG,"\ts_op:%p\n",s_op); - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tjs_p->error_code:%d\n" + gossip_debug(GOSSIP_SERVER_DEBUG,"\tjs_p->error_code:%d\n" ,js_p->error_code); - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tBEFORE POP:smcb->frame_base:%d" + gossip_debug(GOSSIP_SERVER_DEBUG,"\tBEFORE POP:smcb->frame_base:%d" "\tframe_count:%d\n" ,smcb->base_frame,smcb->frame_count); - gossip_debug(GOSSIP_MIRROR_DEBUG,"\tmsgarray->msgpair.req.op:%d\n" + gossip_debug(GOSSIP_SERVER_DEBUG,"\tmsgarray->msgpair.req.op:%d\n" ,msgarray->msgpair.req.op ); - gossip_debug(GOSSIP_MIRROR_DEBUG,"\ts_op->resp.status:%d\n" + gossip_debug(GOSSIP_SERVER_DEBUG,"\ts_op->resp.status:%d\n" ,s_op->resp.status); return SM_ACTION_TERMINATE; diff --git a/src/server/prelude.sm b/src/server/prelude.sm index bb84ed7..a72afac 100644 --- a/src/server/prelude.sm +++ b/src/server/prelude.sm @@ -92,9 +92,21 @@ static PINT_sm_action prelude_setup( ret = PINT_server_req_get_object_ref( s_op->req, &s_op->target_fs_id, &s_op->target_handle); + if( ret != 0 ) + { + js_p->error_code = -PVFS_EINVAL; + } 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); + /* add the user to the uid mgmt system */ + ret = PINT_add_user_to_uid_mgmt(s_op->req->credentials.uid); + if (ret != 0) + { + gossip_debug(GOSSIP_MIRROR_DEBUG, "Unable to add user id to uid" + "management interface\n"); + } + return SM_ACTION_COMPLETE; } @@ -130,7 +142,9 @@ static PINT_sm_action prelude_req_sched( smcb, 0, js_p, &(s_op->scheduled_id), server_job_context); + /* these are two different counters - one instantaneous, one cumulative */ PINT_perf_count(PINT_server_pc, PINT_PERF_REQSCHED, 1, PINT_PERF_ADD); + PINT_perf_count(PINT_server_pc, PINT_PERF_REQUESTS, 1, PINT_PERF_ADD); return ret; } @@ -368,7 +382,6 @@ static PINT_sm_action prelude_perm_check( PVFS_ds_attributes *ds_attr = NULL; 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 squashed_flag = 0; int skip_acl_flag = 0; @@ -409,7 +422,7 @@ static PINT_sm_action prelude_perm_check( else { /* Translate the uid and gid's in case we need to do some squashing based on the export and the client address */ - if (translate_ids(fsid, s_op->req->credentials.uid, s_op->req->credentials.gid, + if (translate_ids(s_op->target_fs_id, s_op->req->credentials.uid, s_op->req->credentials.gid, &translated_uid, &translated_gid, s_op->addr) == 1) { squashed_flag = 1; @@ -426,6 +439,11 @@ static PINT_sm_action prelude_perm_check( s_op->req->u.mkdir.attr.owner = translated_uid; s_op->req->u.mkdir.attr.group = translated_gid; } + else if (s_op->req->op == PVFS_SERV_CREATE) + { + s_op->req->u.create.attr.owner = translated_uid; + s_op->req->u.create.attr.group = translated_gid; + } } } } diff --git a/src/server/pvfs2-server-req.c b/src/server/pvfs2-server-req.c index cf78773..95ec6e1 100644 --- a/src/server/pvfs2-server-req.c +++ b/src/server/pvfs2-server-req.c @@ -51,6 +51,7 @@ extern struct PINT_server_req_params pvfs2_mirror_params; extern struct PINT_server_req_params pvfs2_create_immutable_copies_params; extern struct PINT_server_req_params pvfs2_tree_remove_params; extern struct PINT_server_req_params pvfs2_tree_get_file_size_params; +extern struct PINT_server_req_params pvfs2_uid_mgmt_params; /* table of incoming request types and associated parameters */ struct PINT_server_req_entry PINT_server_req_table[] = @@ -98,6 +99,7 @@ struct PINT_server_req_entry PINT_server_req_table[] = /* 40 */ {PVFS_SERV_IMM_COPIES, &pvfs2_create_immutable_copies_params}, /* 41 */ {PVFS_SERV_TREE_REMOVE, &pvfs2_tree_remove_params}, /* 42 */ {PVFS_SERV_TREE_GET_FILE_SIZE, &pvfs2_tree_get_file_size_params}, + /* 43 */ {PVFS_SERV_MGMT_GET_UID, &pvfs2_uid_mgmt_params}, }; #define CHECK_OP(_op_) assert(_op_ == PINT_server_req_table[_op_].op_type) diff --git a/src/server/pvfs2-server.c b/src/server/pvfs2-server.c index 4c0bd06..c1a3244 100644 --- a/src/server/pvfs2-server.c +++ b/src/server/pvfs2-server.c @@ -16,14 +16,10 @@ #include #include #include +#include #ifdef __PVFS2_SEGV_BACKTRACE__ #include - -#ifndef __USE_GNU -#define __USE_GNU -#endif - #include #endif @@ -50,6 +46,7 @@ #include "src/server/request-scheduler/request-scheduler.h" #include "pint-event.h" #include "pint-util.h" +#include "pint-uid-mgmt.h" #ifndef PVFS2_VERSION #define PVFS2_VERSION "Unknown" @@ -66,6 +63,7 @@ #endif #define PVFS2_VERSION_REQUEST 0xFF +#define PVFS2_HELP 0xFE /* this controls how many jobs we will test for per job_testcontext() * call. NOTE: this is currently independent of the config file @@ -74,19 +72,6 @@ */ #define PVFS_SERVER_TEST_COUNT 64 -/* track performance counters for the server */ -static struct PINT_perf_key server_keys[] = -{ - {"bytes read", PINT_PERF_READ, 0}, - {"bytes written", PINT_PERF_WRITE, 0}, - {"metadata reads", PINT_PERF_METADATA_READ, PINT_PERF_PRESERVE}, - {"metadata writes", PINT_PERF_METADATA_WRITE, PINT_PERF_PRESERVE}, - {"metadata dspace ops", PINT_PERF_METADATA_DSPACE_OPS, PINT_PERF_PRESERVE}, - {"metadata keyval ops", PINT_PERF_METADATA_KEYVAL_OPS, PINT_PERF_PRESERVE}, - {"request scheduler", PINT_PERF_REQSCHED, PINT_PERF_PRESERVE}, - {NULL, 0, 0}, -}; - /* For the switch statement to know what interfaces to shutdown */ static PINT_server_status_flag server_status_flag; @@ -121,7 +106,8 @@ typedef struct } options_t; static options_t s_server_options = { 0, 0, 1, NULL, NULL}; -static char *fs_conf = NULL; +static char fs_conf[PATH_MAX]; +static char startup_cwd[PATH_MAX+1]; /* each of the elements in this array consists of a string and its length. * we're able to use sizeof here because sizeof an inlined string ("") gives @@ -217,6 +203,10 @@ int main(int argc, char **argv) { return 0; } + else if (ret == PVFS2_HELP) + { + return 0; + } else if (ret != 0) { goto server_shutdown; @@ -227,7 +217,6 @@ int main(int argc, char **argv) s_server_options.server_alias, PVFS2_VERSION); /* code to handle older two config file format */ - ret = PINT_parse_config(&server_config, fs_conf, s_server_options.server_alias); if (ret) { @@ -321,10 +310,10 @@ int main(int argc, char **argv) goto server_shutdown; } +#if 0 #ifndef __PVFS2_DISABLE_PERF_COUNTERS__ /* kick off performance update state machine */ - ret = server_state_machine_alloc_noreq(PVFS_SERV_PERF_UPDATE, - &(tmp_op)); + ret = server_state_machine_alloc_noreq(PVFS_SERV_PERF_UPDATE, &(tmp_op)); if (ret == 0) { ret = server_state_machine_start_noreq(tmp_op); @@ -335,6 +324,7 @@ int main(int argc, char **argv) "state machine.\n", ret); goto server_shutdown; } +#endif #endif /* kick off timer for expired jobs */ @@ -365,6 +355,14 @@ int main(int argc, char **argv) if (signal_recvd_flag == SIGHUP) { reload_config(); + + /* re-open log file to allow normal rotation */ + gossip_reopen_file(server_config.logfile, "a"); + gossip_set_debug_mask(1, GOSSIP_SERVER_DEBUG); + gossip_debug(GOSSIP_SERVER_DEBUG, + "Re-opened log %s, continuing\n", + server_config.logfile); + gossip_set_debug_mask(1, debug_mask); signal_recvd_flag = 0; /* Reset the flag */ } else @@ -553,8 +551,7 @@ static int server_initialize( ret = server_initialize_subsystems(server_status_flag); if (ret < 0) { - gossip_err("Error: Could not initialize server interfaces; " - "aborting.\n"); + gossip_err("Error: Could not initialize server subsystems\n"); return ret; } @@ -813,7 +810,7 @@ static int server_initialize_subsystems( gossip_err("Error initializing cached_config interface.\n"); return(ret); } - + /* initialize the flow interface */ ret = PINT_flow_initialize(server_config.flow_modules, 0); @@ -846,6 +843,7 @@ static int server_initialize_subsystems( can't error out since they're just hints. thus, we complain in logging and continue. */ + ret = trove_collection_setinfo( cur_fs->coll_id, 0, TROVE_DIRECTIO_THREADS_NUM, @@ -876,10 +874,10 @@ static int server_initialize_subsystems( ret = trove_collection_lookup( cur_fs->trove_method, cur_fs->file_system_name, &(orig_fsid), NULL, NULL); - + if (ret < 0) { - gossip_err("Error initializing filesystem %s\n", + gossip_err("Error initializing trove for filesystem %s\n", cur_fs->file_system_name); return ret; } @@ -906,11 +904,12 @@ static int server_initialize_subsystems( cur_merged_handle_range = PINT_config_get_merged_handle_range_str( &server_config, cur_fs); - + /* * error out if we're not configured to house either a meta or * data handle range at all. */ + if (!cur_merged_handle_range) { gossip_err("Error: Invalid handle range for host %s " @@ -1131,15 +1130,50 @@ static int server_initialize_subsystems( *server_status_flag |= SERVER_REQ_SCHED_INIT; #ifndef __PVFS2_DISABLE_PERF_COUNTERS__ + /* hist size should be in server config too */ PINT_server_pc = PINT_perf_initialize(server_keys); if(!PINT_server_pc) { gossip_err("Error initializing performance counters.\n"); return(ret); } + ret = PINT_perf_set_info(PINT_server_pc, PINT_PERF_UPDATE_INTERVAL, + server_config.perf_update_interval); + if (ret < 0) + { + gossip_err("Error PINT_perf_set_info (update interval)\n"); + return(ret); + } + /* if history_size is greater than 1, start the rollover SM */ + if (PINT_server_pc->running) + { + struct PINT_smcb *tmp_op = NULL; + ret = server_state_machine_alloc_noreq( + PVFS_SERV_PERF_UPDATE, &(tmp_op)); + if (ret == 0) + { + ret = server_state_machine_start_noreq(tmp_op); + } + if (ret < 0) + { + PVFS_perror_gossip("Error: failed to start perf update " + "state machine.\n", ret); + return(ret); + } + } + *server_status_flag |= SERVER_PERF_COUNTER_INIT; #endif + ret = PINT_uid_mgmt_initialize(); + if (ret < 0) + { + gossip_err("Error initializing the uid management interface\n"); + return (ret); + } + + *server_status_flag |= SERVER_UID_MGMT_INIT; + if (!server_config.osd_type) { ret = precreate_pool_initialize(server_index); @@ -1188,8 +1222,10 @@ static int server_setup_signal_handlers(void) sigaction (SIGQUIT, &new_action, NULL); #ifdef __PVFS2_SEGV_BACKTRACE__ sigaction (SIGSEGV, &segv_action, NULL); + sigaction (SIGABRT, &segv_action, NULL); #else sigaction (SIGSEGV, &new_action, NULL); + sigaction (SIGABRT, &new_action, NULL); #endif /* ignore these */ @@ -1207,7 +1243,7 @@ static int server_setup_signal_handlers(void) #elif defined(REG_RIP) # define REG_INSTRUCTION_POINTER REG_RIP #else -# error Unknown instruction pointer location for your architecture, configure without --enable-segv-backtrace. +# error Unknown instruction pointer location for your architecture, configure with --disable-segv-backtrace. #endif /* bt_signalhandler() @@ -1279,6 +1315,7 @@ static void hup_sighandler(int sig, siginfo_t *info, void *secret) static void reload_config(void) { struct server_configuration_s sighup_server_config; + struct server_configuration_s *orig_server_config; PINT_llist *orig_filesystems = NULL; PINT_llist *hup_filesystems = NULL; struct filesystem_configuration_s *orig_fs; @@ -1287,6 +1324,8 @@ static void reload_config(void) char **tmp_ptr = NULL; int *tmp_int_ptr = NULL; + gossip_debug(GOSSIP_SERVER_DEBUG, "Reloading configuration %s\n", + fs_conf); /* We received a SIGHUP. Update configuration in place */ if (PINT_parse_config(&sighup_server_config, fs_conf, s_server_options.server_alias) < 0) { @@ -1296,6 +1335,19 @@ static void reload_config(void) } else /* Successful load of config */ { + /* Get the current server configuration and update global items */ + orig_server_config = get_server_config_struct(); + if (orig_server_config->event_logging) + { + free(orig_server_config->event_logging); + } + + /* Copy the new logging mask into the current server configuration */ + orig_server_config->event_logging = strdup(sighup_server_config.event_logging); + + /* Reset the debug mask */ + gossip_set_debug_mask(1, PVFS_debug_eventlog_to_mask(orig_server_config->event_logging)); + orig_filesystems = server_config.file_systems; /* Loop and update all stored file systems */ while(orig_filesystems) @@ -1587,6 +1639,16 @@ static int server_shutdown( "interface [ stopped ]\n"); } + if (status & SERVER_UID_MGMT_INIT) + { + gossip_debug(GOSSIP_SERVER_DEBUG, "[+] halting uid management " + "interface [ ... ]\n"); + PINT_uid_mgmt_finalize(); + gossip_debug(GOSSIP_SERVER_DEBUG, "[-] uid management " + "interface [ stopped ]\n"); + + } + if (status & SERVER_GOSSIP_INIT) { gossip_debug(GOSSIP_SERVER_DEBUG, @@ -1668,7 +1730,7 @@ static int server_parse_cmd_line_args(int argc, char **argv) { int ret = 0, option_index = 0; int total_arguments = 0; - const char *cur_option = NULL; + const char *cur_option = NULL, *tmp_path = NULL; static struct option long_opts[] = { {"foreground",0,0,0}, @@ -1677,7 +1739,7 @@ static int server_parse_cmd_line_args(int argc, char **argv) {"rmfs",0,0,0}, {"version",0,0,0}, {"pidfile",1,0,0}, - {"alias",0,0,0}, + {"alias",1,0,0}, {0,0,0,0} }; @@ -1742,7 +1804,8 @@ static int server_parse_cmd_line_args(int argc, char **argv) s_server_options.pidfile = optarg; if(optarg[0] != '/') { - gossip_err("Error: pidfile must be specified with an absolute path.\n"); + gossip_err("Error: pidfile must be specified with an " + "absolute path.\n"); goto parse_cmd_line_args_failure; } break; @@ -1754,6 +1817,12 @@ static int server_parse_cmd_line_args(int argc, char **argv) case '?': case 'h': do_help: + usage(argc, argv); + if(s_server_options.server_alias) + { + free(s_server_options.server_alias); + } + return PVFS2_HELP; default: parse_cmd_line_args_failure: usage(argc, argv); @@ -1771,7 +1840,64 @@ static int server_parse_cmd_line_args(int argc, char **argv) goto parse_cmd_line_args_failure; } - fs_conf = argv[optind++]; + if (argv[optind][0] != '/') + { + if( (tmp_path = getcwd(startup_cwd, PATH_MAX)) == NULL ) + { + gossip_err("Failed to get current working directory to create " + "absolute path for configuration file: %s\n", + strerror(errno)); + } + + if( (strlen(argv[optind]) + strlen(startup_cwd) + 1) >= PATH_MAX ) + { + gossip_err("Config file path greater than %d characters\n", + PATH_MAX); + goto parse_cmd_line_args_failure; + } + + if( strncat(startup_cwd, "/", PATH_MAX) == NULL ) + { + gossip_err("Failure creating absolute path from relative " + "configuration file path\n"); + goto parse_cmd_line_args_failure; + } + + /* copy the relative path into the string for the user */ + if( strncat(startup_cwd, argv[optind++], PATH_MAX) == NULL ) + { + gossip_err("Failure creating absolute path from relative " + "configuration file path\n"); + goto parse_cmd_line_args_failure; + } + + if( strncpy(fs_conf, startup_cwd, PATH_MAX) == NULL ) + { + gossip_err("Failure copying created full path into configuration " + "file path\n"); + goto parse_cmd_line_args_failure; + } + } + else + { + if( strlen(argv[optind]) >= PATH_MAX ) + { + gossip_err("Config file path greater than %d characters\n", + PATH_MAX); + goto parse_cmd_line_args_failure; + } + if( strncpy( fs_conf, argv[optind++], PATH_MAX) == NULL ) + { + gossip_err("Failure copying configuration file path\n"); + goto parse_cmd_line_args_failure; + } + } + + if( fs_conf == NULL ) + { + gossip_err("Failure copying configuration file path\n"); + goto parse_cmd_line_args_failure; + } if(argc - total_arguments > 2) { @@ -2370,7 +2496,8 @@ static int precreate_pool_initialize(int server_index) gossip_debug(GOSSIP_SERVER_DEBUG, "%s: setting up pool on " "%s, type: %u, fs_id: %llu, handle: %llu\n", - __func__, host, t, llu(cur_fs->coll_id), + __func__, host, t, + (long long unsigned int)cur_fs->coll_id, llu(pool_handle)); ret = precreate_pool_setup_server(host, t, cur_fs->coll_id, &pool_handle); diff --git a/src/server/pvfs2-server.h b/src/server/pvfs2-server.h index ed818c6..6044026 100644 --- a/src/server/pvfs2-server.h +++ b/src/server/pvfs2-server.h @@ -17,8 +17,10 @@ #include #include +#ifndef WIN32 #include #include +#endif #include #include "pvfs2-debug.h" #include "pvfs2-storage.h" @@ -207,6 +209,7 @@ typedef enum SERVER_DIST_INIT = (1 << 16), SERVER_CACHED_CONFIG_INIT = (1 << 17), SERVER_PRECREATE_INIT = (1 << 18), + SERVER_UID_MGMT_INIT = (1 << 19), } PINT_server_status_flag; typedef enum @@ -308,7 +311,7 @@ struct PINT_server_create_copies_op /*source remote server names in distribution*/ char **remote_io_servers; - /*source local server names in distribution*/; + /*source local server names in distribution*/ char **local_io_servers; /*number of source server names in the distribution*/ @@ -708,16 +711,32 @@ typedef struct PINT_server_op * no return value */ #ifdef GOSSIP_DISABLE_DEBUG +#ifdef WIN32 +#define PINT_ACCESS_DEBUG(__s_op, __mask, format, ...) do {} while (0) +#else #define PINT_ACCESS_DEBUG(__s_op, __mask, format, f...) do {} while (0) +#endif +#else +#ifdef WIN32 +#define PINT_ACCESS_DEBUG(__s_op, __mask, format, ...) \ + PINT_server_access_debug(__s_op, __mask, format, __VA_ARGS__) #else #define PINT_ACCESS_DEBUG(__s_op, __mask, format, f...) \ PINT_server_access_debug(__s_op, __mask, format, ##f) #endif +#endif +#ifdef WIN32 +void PINT_server_access_debug(PINT_server_op * s_op, + int64_t debug_mask, + const char * format, + ...); +#else void PINT_server_access_debug(PINT_server_op * s_op, int64_t debug_mask, const char * format, ...) __attribute__((format(printf, 3, 4))); +#endif /* server side state machines */ extern struct PINT_state_machine_s pvfs2_mirror_sm; diff --git a/src/server/request-scheduler/request-scheduler.c b/src/server/request-scheduler/request-scheduler.c index 54ffc9b..0c0594a 100644 --- a/src/server/request-scheduler/request-scheduler.c +++ b/src/server/request-scheduler/request-scheduler.c @@ -25,7 +25,9 @@ #include #include +#ifndef WIN32 #include +#endif #include #include "request-scheduler.h" diff --git a/src/server/set-attr.sm b/src/server/set-attr.sm index b131f3c..5c7050e 100644 --- a/src/server/set-attr.sm +++ b/src/server/set-attr.sm @@ -244,6 +244,9 @@ static PINT_sm_action setattr_setobj_attribs( dspace_a_p = &s_op->attr; a_p = &s_op->req->u.setattr.attr; + + a_p->cid = s_op->req->u.setattr.cid; + dspace_a_p->cid = a_p->cid; if (a_p->mask & PVFS_ATTR_META_DFILES) { @@ -361,6 +364,7 @@ static PINT_sm_action setattr_write_metafile_datafile_handles_if_required( /* we don't sync here since we're going to do it anyway in * write_metafile_distribution */ + ret = job_trove_keyval_write( s_op->req->u.setattr.fs_id, s_op->req->u.setattr.handle, &(s_op->key), &(s_op->val), diff --git a/src/server/small-io.sm b/src/server/small-io.sm index 9b4785e..49167b1 100644 --- a/src/server/small-io.sm +++ b/src/server/small-io.sm @@ -17,6 +17,7 @@ #include "pvfs2-request.h" #include "pint-distribution.h" #include "pint-request.h" +#include "pint-perf-counter.h" %% @@ -182,8 +183,9 @@ static PINT_sm_action small_io_start_job( s_op->u.small_io.result_bytes = result.bytes; - gossip_debug(GOSSIP_IO_DEBUG,"\tsubmitting job_trove_bstream_read_list for handle %llu\n" - ,llu(s_op->req->u.small_io.handle)); + gossip_debug(GOSSIP_IO_DEBUG, + "\tsubmitting job_trove_bstream_read_list for handle %llu\n" + ,llu(s_op->req->u.small_io.handle)); ret = job_trove_bstream_read_list( s_op->req->u.small_io.fs_id, s_op->req->u.small_io.handle, @@ -230,6 +232,28 @@ static PINT_sm_action small_io_check_size( s_op->resp.u.small_io.result_size = s_op->u.small_io.result_bytes; } } + if(s_op->req->u.small_io.io_type == PVFS_IO_READ) + { + PINT_perf_count(PINT_server_pc, + PINT_PERF_READ, + s_op->resp.u.small_io.result_size, + PINT_PERF_ADD); + PINT_perf_count(PINT_server_pc, + PINT_PERF_SMALL_READ, + s_op->resp.u.small_io.result_size, + PINT_PERF_ADD); + } + else + { + PINT_perf_count(PINT_server_pc, + PINT_PERF_WRITE, + s_op->resp.u.small_io.result_size, + PINT_PERF_ADD); + PINT_perf_count(PINT_server_pc, + PINT_PERF_SMALL_WRITE, + s_op->resp.u.small_io.result_size, + PINT_PERF_ADD); + } return SM_ACTION_COMPLETE; } diff --git a/src/server/tree-communicate.sm b/src/server/tree-communicate.sm index e533d45..fd4609f 100644 --- a/src/server/tree-communicate.sm +++ b/src/server/tree-communicate.sm @@ -577,7 +577,6 @@ static int tree_get_file_size_work_cleanup( int i, j, k, task_id, error_code; uint32_t size_array_index=0, error_array_index=0; PINT_server_op *old_frame; - struct PVFS_servresp_tree_get_file_size *tree_resp = NULL; struct PVFS_servreq_tree_get_file_size *tree_req = NULL; PINT_sm_msgpair_state *tree_msgarray = NULL; PINT_sm_msgarray_op *tree_msgop = NULL; @@ -595,9 +594,7 @@ static int tree_get_file_size_work_cleanup( { old_frame = PINT_sm_pop_frame(smcb, &task_id, &error_code, NULL); if (old_frame) - { /* response from sub-tree request */ - tree_resp = &(old_frame->resp.u.tree_get_file_size); - + { /* sub-tree msgpair array*/ tree_msgarray = old_frame->msgarray_op.msgarray; diff --git a/test/Makefile.in b/test/Makefile.in index cd2a896..829d83f 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -320,7 +320,7 @@ $(MPIIOTESTS): %: %.o $(LIBRARIES) # default rule for building executables from object files %: %.o $(LIBRARIES) $(MISCOBJS) $(SHAREDOBJS) $(Q) " LD $@" - $(E)$(LD) $(LDFLAGS) $(call modldflags,$<) $< $(MISCOBJS) $(SHAREDOBJS) $(LIBS) -o $@ + $(E)$(LD) $(LDFLAGS) $< $(MISCOBJS) $(SHAREDOBJS) $(LIBS) $(call modldflags,$<) -o $@ # default rule for building objects %.o: %.c diff --git a/test/automated/README.tests b/test/automated/README.tests index d73ca4b..bea8f1d 100644 --- a/test/automated/README.tests +++ b/test/automated/README.tests @@ -1,5 +1,5 @@ # -# $Date: 2010/04/30 20:00:56 $ +# $Date: 2010-04-30 20:00:56 $ # # A brief description of the contents of the test/automated directory diff --git a/test/client/sysint/client.c b/test/client/sysint/client.c index 8e1a4a8..2ee816f 100644 --- a/test/client/sysint/client.c +++ b/test/client/sysint/client.c @@ -5,7 +5,9 @@ */ #include +#ifndef WIN32 #include +#endif #include #include #include @@ -46,7 +48,8 @@ int main( PVFS_sys_attr attr; PVFS_object_ref pinode_refn; PVFS_ds_position token; - int pvfs_dirent_incount; + int pvfs_dirent_incount, + pvfs_dirent_outcount; PVFS_handle lk_handle; PVFS_handle lk_fsid; @@ -477,22 +480,32 @@ int main( token = PVFS_READDIR_START; pvfs_dirent_incount = 6; - // call readdir - ret = PVFS_sys_readdir(pinode_refn, token, pvfs_dirent_incount, - &credentials, resp_readdir, NULL); - if (ret < 0) - { - printf("readdir failed with errcode = %d\n", ret); - return (-1); - } - - // print the handle - printf("--readdir--\n"); - printf("Token:%ld\n", (long int) resp_readdir->token); - for (i = 0; i < resp_readdir->pvfs_dirent_outcount; i++) + /* + do { - printf("name:%s\n", resp_readdir->dirent_array[i].d_name); - } + */ + // call readdir + ret = PVFS_sys_readdir(pinode_refn, token, pvfs_dirent_incount, + &credentials, resp_readdir, NULL); + if (ret < 0) + { + printf("readdir failed with errcode = %d\n", ret); + return (-1); + } + + // print the handle + printf("--readdir--\n"); + printf("Token:%ld\n", (long int) resp_readdir->token); + for (i = 0; i < resp_readdir->pvfs_dirent_outcount; i++) + { + printf("name:%s\n", resp_readdir->dirent_array[i].d_name); + } + token = resp_readdir->token; + pvfs_dirent_outcount = resp_readdir->pvfs_dirent_outcount; + /* + } + while (pvfs_dirent_outcount == 6); + */ #if 0 // test the rmdir function @@ -591,6 +604,7 @@ void gen_rand_str( int newchar = 0; gettimeofday(&poop, NULL); + srand(poop.tv_sec); *gen_str = malloc(len + 1); for (i = 0; i < len; i++) { diff --git a/test/client/sysint/find.c b/test/client/sysint/find.c index 45747b6..5fb8cea 100644 --- a/test/client/sysint/find.c +++ b/test/client/sysint/find.c @@ -8,11 +8,17 @@ #include #include #include +#ifndef WIN32 #include +#endif #include #include "pvfs2-util.h" #include "pvfs2-internal.h" +#ifdef WIN32 +#define snprintf _snprintf +#endif + /* TODO: this can be larger after system interface readdir logic * is in place to break up large readdirs into multiple operations */ diff --git a/test/client/sysint/flush-2.c b/test/client/sysint/flush-2.c index adf9879..a8eefb4 100644 --- a/test/client/sysint/flush-2.c +++ b/test/client/sysint/flush-2.c @@ -38,7 +38,6 @@ int main( PVFS_Request file_req; PVFS_Request mem_req; void *buffer; - int buffer_size; if (argc != 2) { @@ -156,7 +155,6 @@ int main( (long) pinode_refn.handle, (int) pinode_refn.fs_id); buffer = io_buffer; - buffer_size = io_size * sizeof(int); file_req = PVFS_BYTE; diff --git a/test/client/sysint/io-bug.c b/test/client/sysint/io-bug.c index 96d8f49..e7f3a45 100644 --- a/test/client/sysint/io-bug.c +++ b/test/client/sysint/io-bug.c @@ -38,8 +38,6 @@ int main( PVFS_object_ref pinode_refn; PVFS_Request file_req; PVFS_Request mem_req; - void *buffer; - int buffer_size; int32_t len_array1[17]; int32_t len_array2[17]; PVFS_offset off_array1[17]; @@ -161,9 +159,6 @@ int main( printf("IO-TEST: performing write on handle: %ld, fs: %d\n", (long) pinode_refn.handle, (int) pinode_refn.fs_id); - buffer = io_buffer; - buffer_size = io_size * sizeof(int); - off_array1[0] = 0; off_array1[0] += (intptr_t)io_buffer; off_array2[0] = 327552; diff --git a/test/client/sysint/io-test-offset.c b/test/client/sysint/io-test-offset.c index 7ec4ef0..05b6d0f 100644 --- a/test/client/sysint/io-test-offset.c +++ b/test/client/sysint/io-test-offset.c @@ -42,7 +42,6 @@ int main( PVFS_Request mem_req; PVFS_Request mem_req2; void *buffer; - int buffer_size; void *off_buffer; if (argc != 2) @@ -162,7 +161,6 @@ int main( (long) pinode_refn.handle, (int) pinode_refn.fs_id); buffer = io_buffer; - buffer_size = io_size * sizeof(int); file_req = PVFS_BYTE; diff --git a/test/client/sysint/io-test-threaded.c b/test/client/sysint/io-test-threaded.c index 7b75e84..41bf544 100644 --- a/test/client/sysint/io-test-threaded.c +++ b/test/client/sysint/io-test-threaded.c @@ -45,7 +45,7 @@ int main(int argc, char **argv) char *filename = NULL; int ret = -1, io_size = DEFAULT_IO_SIZE; int *io_buffer = NULL; - int i, buffer_size; + int i; PVFS_fs_id fs_id; char name[512] = {0}; char *entry_name = NULL; @@ -163,7 +163,6 @@ int main(int argc, char **argv) */ buffer = io_buffer; - buffer_size = io_size * sizeof(int); /* file datatype is tiled, so we can get away with a trivial type diff --git a/test/client/sysint/io-test.c b/test/client/sysint/io-test.c index 54238f7..6458079 100644 --- a/test/client/sysint/io-test.c +++ b/test/client/sysint/io-test.c @@ -6,8 +6,10 @@ #include #include "client.h" +#ifndef WIN32 #include #include +#endif #include #include #include @@ -16,6 +18,11 @@ #include "pvfs2-mgmt.h" #include "pvfs2-internal.h" +#ifdef WIN32 +#define snprintf _snprintf +#define rindex strrchr +#endif + #define DEFAULT_IO_SIZE 8*1024*1024 int main(int argc, char **argv) @@ -26,7 +33,7 @@ int main(int argc, char **argv) char *filename = NULL; int ret = -1, io_size = DEFAULT_IO_SIZE; int *io_buffer = NULL; - int i, errors, buffer_size; + int i, errors; PVFS_fs_id fs_id; char name[512] = {0}; char *entry_name = NULL; @@ -138,7 +145,6 @@ int main(int argc, char **argv) (long) pinode_refn.handle, (int) pinode_refn.fs_id); buffer = io_buffer; - buffer_size = io_size * sizeof(int); /* file datatype is tiled, so we can get away with a trivial type diff --git a/test/client/sysint/lookup.c b/test/client/sysint/lookup.c index f4ff545..0f555ad 100644 --- a/test/client/sysint/lookup.c +++ b/test/client/sysint/lookup.c @@ -5,11 +5,17 @@ */ #include +#ifdef WIN32 +#include +#else #include +#endif #include #include #include +#ifndef WIN32 #include +#endif #include #include "client.h" diff --git a/test/client/sysint/ls.c b/test/client/sysint/ls.c index f5a0c79..c568d01 100644 --- a/test/client/sysint/ls.c +++ b/test/client/sysint/ls.c @@ -15,6 +15,10 @@ #include "str-utils.h" #include "pvfs2-internal.h" +#ifdef WIN32 +#define snprintf _snprintf +#endif + #define MAX_NUM_DIRENTS 32 void print_entry_attr( diff --git a/test/client/sysint/mkdir.c b/test/client/sysint/mkdir.c index eb7a461..b4e1dc1 100644 --- a/test/client/sysint/mkdir.c +++ b/test/client/sysint/mkdir.c @@ -5,10 +5,14 @@ */ #include +#ifndef WIN32 #include +#endif #include #include +#ifndef WIN32 #include +#endif #include #include "pvfs2-util.h" diff --git a/test/client/sysint/pvfs2tab b/test/client/sysint/pvfs2tab index 8bd615b..b6f700c 100644 --- a/test/client/sysint/pvfs2tab +++ b/test/client/sysint/pvfs2tab @@ -1,2 +1 @@ -tcp://localhost:3334/pvfs2-fs /mnt/pvfs pvfs2 encoding=le_bfield 0 0 - +tcp://localhost:3334/pvfs2-fs /mnt/pvfs pvfs2 encoding=le_bfield 0 0 diff --git a/test/client/sysint/readdir.c b/test/client/sysint/readdir.c index 2aa5efd..3d82ea5 100644 --- a/test/client/sysint/readdir.c +++ b/test/client/sysint/readdir.c @@ -5,10 +5,14 @@ */ #include +#ifndef WIN32 #include +#endif #include #include +#ifndef WIN32 #include +#endif #include #include "pvfs2-util.h" diff --git a/test/client/sysint/remove.c b/test/client/sysint/remove.c index 6f56929..85c3fcd 100644 --- a/test/client/sysint/remove.c +++ b/test/client/sysint/remove.c @@ -5,7 +5,9 @@ */ #include +#ifndef WIN32 #include +#endif #include #include "client.h" diff --git a/test/client/sysint/rename.c b/test/client/sysint/rename.c index 0876e5f..5cd0631 100644 --- a/test/client/sysint/rename.c +++ b/test/client/sysint/rename.c @@ -5,7 +5,9 @@ */ #include +#ifndef WIN32 #include +#endif #include #include "client.h" #include "pvfs2-types.h" diff --git a/test/client/sysint/test-hindexed-test.c b/test/client/sysint/test-hindexed-test.c index 963e2f3..0580a40 100644 --- a/test/client/sysint/test-hindexed-test.c +++ b/test/client/sysint/test-hindexed-test.c @@ -119,8 +119,8 @@ static int fillup_buffer(cm_frame_t *frame) int main(int argc, char **argv) { int ret = -1; - char str_buf[PVFS_NAME_MAX] = {0}, *fname = NULL; - char pvfs_path[PVFS_NAME_MAX] = {0}; + char str_buf[PVFS_NAME_MAX+1] = {0}, *fname = NULL; + char pvfs_path[PVFS_NAME_MAX+1] = {0}; PVFS_fs_id cur_fs; PVFS_sysresp_lookup resp_lookup; PVFS_sysresp_create resp_create; diff --git a/test/common/misc/test-perf-counter.c b/test/common/misc/test-perf-counter.c index ce2639f..ca1ab1b 100644 --- a/test/common/misc/test-perf-counter.c +++ b/test/common/misc/test-perf-counter.c @@ -226,9 +226,7 @@ static void print_counters(struct PINT_perf_counter* pc, int* in_key_count, unsigned int key_count; unsigned int history_size; int ret; - int64_t** stat_matrix; - uint64_t* start_time_array_ms; - uint64_t* interval_array_ms; + int64_t* stat_matrix; int i,j; if(in_key_count) @@ -255,34 +253,22 @@ static void print_counters(struct PINT_perf_counter* pc, int* in_key_count, } /* allocate storage for results */ - stat_matrix = malloc(key_count*sizeof(int64_t*)); - for(i=0; i #include +#include +#ifndef WIN32 #include +#endif #include #include +#ifndef WIN32 #include +#endif #include "gossip.h" #include #include "bmi.h" @@ -20,8 +25,12 @@ int bench_args( int argc, char **argv) { +#ifdef WIN32 + int argi = 1; +#else char flags[] = "L:pm:t:l:s:r"; int one_opt = ' '; +#endif int got_method = 0; int ret = -1; @@ -35,6 +44,50 @@ int bench_args( user_opts->list_io_factor = 1; /* look at command line arguments */ +#ifdef WIN32 + while (argi < argc) + { + ret = 1; + if (strcmp(argv[argi], "-s") == 0) + { + ret = sscanf(argv[++argi], "%d", &user_opts->num_servers); + } + else if (strcmp(argv[argi], "-l") == 0) + { + ret = sscanf(argv[++argi], "%d", &user_opts->message_len); + } + else if (strcmp(argv[argi], "-L") == 0) + { + ret = sscanf(argv[++argi], "%d", &user_opts->list_io_factor); + } + else if (strcmp(argv[argi], "-t") == 0) + { + ret = sscanf(argv[++argi], "%d", &user_opts->total_len); + } + else if (strcmp(argv[argi], "-m") == 0) + { + got_method = 1; + ret = sscanf(argv[++argi], "%s", user_opts->method_name); + } + else if (strcmp(argv[argi], "-p") == 0) + { + user_opts->flags |= BMI_ALLOCATE_MEMORY; + } + else if (strcmp(argv[argi], "-r") == 0) + { + user_opts->flags |= REUSE_BUFFERS; + } + + if (ret < 1) + { + return -1; + } + + argi++; + } + + +#else while ((one_opt = getopt(argc, argv, flags)) != EOF) { switch (one_opt) @@ -85,7 +138,7 @@ int bench_args( break; } } - +#endif if (!got_method) { printf("Must specify method!\n"); diff --git a/test/io/bmi/bench-args.h b/test/io/bmi/bench-args.h index 99b00f2..6a045fc 100644 --- a/test/io/bmi/bench-args.h +++ b/test/io/bmi/bench-args.h @@ -6,7 +6,9 @@ #include #include +#ifndef WIN32 #include +#endif #include #include #include diff --git a/test/io/bmi/bench-initialize.c b/test/io/bmi/bench-initialize.c index 87ef54f..8f07ed3 100644 --- a/test/io/bmi/bench-initialize.c +++ b/test/io/bmi/bench-initialize.c @@ -6,7 +6,9 @@ #include #include +#ifndef WIN32 #include +#endif #include #include #include @@ -15,7 +17,9 @@ #include "bmi.h" #include "bench-initialize.h" #include "bench-args.h" +#ifndef WIN32 #include +#endif int bench_init( struct bench_options *opts, @@ -171,7 +175,7 @@ int bench_initialize_bmi_interface( if (flags & BMI_INIT_SERVER) { - ret = BMI_initialize(NULL, NULL, 0); + ret = BMI_initialize(method, local_address, flags); } else { @@ -239,7 +243,11 @@ int bench_initialize_mpi_params( MPI_Get_processor_name(local_proc_name, &proc_namelen); /* trim off all but hostname portion */ +#ifdef WIN32 + trunc_point = strchr(local_proc_name, '.'); +#else trunc_point = index(local_proc_name, '.'); +#endif if (trunc_point) { trunc_point[0] = '\0'; @@ -311,6 +319,7 @@ int bench_initialize_bmi_addresses_client( { ret = MPI_Recv(server_name, 256, MPI_BYTE, i, 0, MPI_COMM_WORLD, &status_foo); + if (ret != MPI_SUCCESS) { return (-1); diff --git a/test/io/bmi/bench-initialize.h b/test/io/bmi/bench-initialize.h index 4697ebf..c741498 100644 --- a/test/io/bmi/bench-initialize.h +++ b/test/io/bmi/bench-initialize.h @@ -6,7 +6,9 @@ #include #include +#ifndef WIN32 #include +#endif #include #include #include diff --git a/test/io/bmi/bench-mem.c b/test/io/bmi/bench-mem.c index ee19096..355255c 100644 --- a/test/io/bmi/bench-mem.c +++ b/test/io/bmi/bench-mem.c @@ -6,7 +6,9 @@ #include #include +#ifndef WIN32 #include +#endif #include #include #include diff --git a/test/io/bmi/bench-mem.h b/test/io/bmi/bench-mem.h index 989addc..b16e5af 100644 --- a/test/io/bmi/bench-mem.h +++ b/test/io/bmi/bench-mem.h @@ -6,7 +6,9 @@ #include #include +#ifndef WIN32 #include +#endif #include #include #include diff --git a/test/io/bmi/driver-bw-multi.c b/test/io/bmi/driver-bw-multi.c index d559643..06d38db 100644 --- a/test/io/bmi/driver-bw-multi.c +++ b/test/io/bmi/driver-bw-multi.c @@ -6,7 +6,9 @@ #include #include +#ifndef WIN32 #include +#endif #include #include "gossip.h" #include @@ -483,7 +485,7 @@ static int bmi_server_postall( ret = BMI_post_recv(&(ids[j][i]), addr_array[j], recv_buffer, bmi_buf_array[0].size, &actual_size, - buffer_type, 0, NULL, context); + buffer_type, 0, NULL, context, NULL); if (ret < 0) { fprintf(stderr, "Server: BMI recv error.\n"); @@ -665,7 +667,7 @@ static int bmi_client_postall( ret = BMI_post_send(&(ids[j][i]), addr_array[j], send_buffer, bmi_buf_array[0].size, buffer_type, 0, NULL, - context); + context, NULL); if (ret < 0) { fprintf(stderr, "Client: BMI send error.\n"); diff --git a/test/io/bmi/module.mk.in b/test/io/bmi/module.mk.in index b134461..59a5a17 100644 --- a/test/io/bmi/module.mk.in +++ b/test/io/bmi/module.mk.in @@ -42,3 +42,4 @@ MPITESTSRC += $(LOCAL_MPITESTSRC) #$(LOCALMPITESTS): %: %.o $(LOCALMPIOBJS) lib/libpvfs2.a # $(Q) " MPILD $@" # $(E)$(MPICC) $^ $(LDFLAGS) $(LIBS) -lm -o $@ + diff --git a/test/io/bmi/pingpong.c b/test/io/bmi/pingpong.c index 500e2b7..788e980 100644 --- a/test/io/bmi/pingpong.c +++ b/test/io/bmi/pingpong.c @@ -14,11 +14,15 @@ #include #include +#ifndef WIN32 #include +#endif #include #include +#ifndef WIN32 #include #include +#endif #include #include @@ -29,6 +33,7 @@ #include /* lld(), llu() */ #include "pvfs2-test-config.h" +#include /* now lld(), llu() here */ #ifdef HAVE_ZLIB_H #include @@ -67,7 +72,10 @@ struct options int crc; }; - +#ifdef WIN32 +/* performance counter frequency */ +LARGE_INTEGER freq; +#endif /************************************************************** * Internal utility functions */ @@ -106,6 +114,11 @@ int main(int argc, char **argv) gossip_enable_stderr(); gossip_set_debug_mask(0, GOSSIP_BMI_DEBUG_ALL); +#ifdef WIN32 + /* get performance counter frequency */ + QueryPerformanceFrequency(&freq); +#endif + /* initialize local interface (default options) */ if (opts->which == SERVER) ret = BMI_initialize(opts->method, opts->hostid, BMI_INIT_SERVER); @@ -211,6 +224,9 @@ static int do_server(struct options *opts, bmi_context_id *context) BMI_unexpected_free(peer_addr, request_info.buffer); +#ifdef WIN32 + server_addr = (PVFS_BMI_addr_t) 0; +#endif ret = BMI_get_info(server_addr, BMI_CHECK_MAXSIZE, (void *)&max_bytes); if (ret < 0) { @@ -397,8 +413,13 @@ static int do_client(struct options *opts, bmi_context_id *context) int iterations = 0; int msg_len = 0; int run = 0; +#ifdef WIN32 + LARGE_INTEGER start; + LARGE_INTEGER end; +#else struct timeval start; struct timeval end; +#endif double *val = NULL; double lat = 0.0; double min = 99999.9; @@ -518,7 +539,11 @@ static int do_client(struct options *opts, bmi_context_id *context) } /* make sure server has posted first recv */ +#ifdef WIN32 + Sleep(1000); +#else sleep(1); +#endif fprintf(stdout, " Bytes usecs MB/s StdDev Min Max\n"); @@ -528,9 +553,16 @@ static int do_client(struct options *opts, bmi_context_id *context) iterations = bytes_to_iterations(bytes); for (i=0; i < iterations; i++) { - +#ifdef WIN32 + offset = rand() % (max_bytes - bytes - 1); +#else offset = random() % (max_bytes - bytes - 1); +#endif +#ifdef WIN32 + QueryPerformanceCounter(&start); +#else gettimeofday(&start, NULL); +#endif #ifdef HAVE_LIBZ if(opts->crc) @@ -601,18 +633,28 @@ static int do_client(struct options *opts, bmi_context_id *context) rcrc = adler32(rcrc, recv_buffer, bytes); if(rcrc != crc) { - fprintf(stderr, "CRC Mismatch! Sent %llu but received %llu\n", - llu(crc), llu(rcrc)); + fprintf(stderr, "CRC Mismatch! " + "Sent %llu but received %llu\n", + llu(crc), + llu(rcrc)); } } #endif +#ifdef WIN32 + QueryPerformanceCounter(&end); +#else gettimeofday(&end, NULL); +#endif if (!warmup) { +#ifdef WIN32 + val[i] = ((double) end.QuadPart - (double) start.QuadPart) / (double) freq.QuadPart; +#else val[i] = (double) end.tv_sec + (double) end.tv_usec * 0.000001; val[i] -= (double) start.tv_sec + (double) start.tv_usec * 0.000001; +#endif lat += val[i]; } } @@ -680,6 +722,93 @@ static void get_method(struct options *opts) return; } +#ifdef WIN32 +static struct options *parse_args(int argc, char *argv[]) +{ + + struct options *opts = NULL; + int argi = 1; + + /* create storage for the command line options */ + opts = (struct options *) calloc(1, sizeof(struct options)); + if (!opts) { + goto parse_args_error; + } + + /* look at command line arguments */ + while (argi < argc) { + if (strcmp(argv[argi], "-h") == 0) + { + opts->hostid = (char *) strdup(argv[++argi]); + if (opts->hostid == NULL) { + goto parse_args_error; + } + get_method(opts); + argi++; + } + else if (strcmp(argv[argi], "-s") == 0) + { + if (opts->which == CLIENT) { + fprintf(stderr, "use -s OR -c, not both\n"); + goto parse_args_error; + } + opts->which = SERVER; + argi++; + } + else if (strcmp(argv[argi], "-c") == 0) + { + if (opts->which == SERVER) { + fprintf(stderr, "use -s OR -c, not both\n"); + goto parse_args_error; + } + opts->which = CLIENT; + argi++; + } + else if (strcmp(argv[argi], "-u") == 0) + { + opts->test = UNEXPECTED; + argi++; + } + else if (strcmp(argv[argi], "-r") == 0) + { + opts->crc = 1; + argi++; + } + else + { + break; + } + } + + /* if we didn't get a host argument, bail: */ + if (opts->hostid == NULL) { + fprintf(stderr, "you must specify -h\n"); + goto parse_args_error; + } + if (opts->method == NULL) { + fprintf(stderr, "you must use a valid HOST_URI\n"); + goto parse_args_error; + } + if (opts->which == 0) { + fprintf(stderr, "you must specify -s OR -c\n"); + goto parse_args_error; + } + + return (opts); + +parse_args_error: + + /* if an error occurs, just free everything and return NULL */ + if (opts) { + if (opts->hostid) { + free(opts->hostid); + } + free(opts); + } + return (NULL); +} + +#else static struct options *parse_args(int argc, char *argv[]) { @@ -758,6 +887,7 @@ static struct options *parse_args(int argc, char *argv[]) } return (NULL); } +#endif /* * vim:expandtab:shiftwidth=8:tabstop=8: diff --git a/test/io/bmi/test-bmi-client-eagerbug.c b/test/io/bmi/test-bmi-client-eagerbug.c index ecf2d09..7f26617 100644 --- a/test/io/bmi/test-bmi-client-eagerbug.c +++ b/test/io/bmi/test-bmi-client-eagerbug.c @@ -14,7 +14,9 @@ #include #include +#ifndef WIN32 #include +#endif #include #include @@ -282,7 +284,11 @@ int main( } /* let the server get ahead of us */ +#ifdef WIN32 + Sleep(10000); +#else sleep(10); +#endif ret = BMI_post_send(&(client_ops[0]), server_addr, testeagerbuf1, 6, BMI_EXT_ALLOC, 1, NULL, context, NULL); @@ -336,7 +342,80 @@ int main( return (0); } +#ifdef WIN32 +static struct options *parse_args( + int argc, + char *argv[]) +{ + struct options *tmp_opts = NULL; + int len = -1, argi = 1; + int ret = -1; + + /* create storage for the command line options */ + tmp_opts = malloc(sizeof(struct options)); + if (!tmp_opts) + { + goto parse_args_error; + } + + /* fill in defaults (except for hostid) */ + tmp_opts->hostid = NULL; + tmp_opts->message_size = 32000; + + /* look at command line arguments */ + while (argi < argc) + { + if (strcmp(argv[argi], "-h") == 0) + { + len = strlen(argv[++argi]) + 1; + tmp_opts->hostid = (char *) malloc(len); + if (tmp_opts->hostid == NULL) + { + goto parse_args_error; + } + memcpy(tmp_opts->hostid, argv[argi], len); + argi++; + } + else if (strcmp(argv[argi], "-s") == 0) + { + ret = sscanf(argv[++argi], "%d", &tmp_opts->message_size); + if (ret < -1) + { + goto parse_args_error; + } + argi++; + } + else { + goto parse_args_error; + } + } + + /* if we didn't get a host argument, fill in a default: */ + if (tmp_opts->hostid == NULL) { + len = (strlen(DEFAULT_HOSTID)) + 1; + if ((tmp_opts->hostid = malloc(len)) == NULL) + { + goto parse_args_error; + } + memcpy(tmp_opts->hostid, DEFAULT_HOSTID, len); + } + + return (tmp_opts); + parse_args_error: + + /* if an error occurs, just free everything and return NULL */ + if (tmp_opts) + { + if (tmp_opts->hostid) + { + free(tmp_opts->hostid); + } + free(tmp_opts); + } + return (NULL); +} +#else static struct options *parse_args( int argc, char *argv[]) @@ -409,6 +488,7 @@ static struct options *parse_args( } return (NULL); } +#endif /* * Local variables: diff --git a/test/io/bmi/test-bmi-client-list.c b/test/io/bmi/test-bmi-client-list.c index 78c47e6..d6fa869 100644 --- a/test/io/bmi/test-bmi-client-list.c +++ b/test/io/bmi/test-bmi-client-list.c @@ -14,7 +14,9 @@ #include #include +#ifndef WIN32 #include +#endif #include #include @@ -86,7 +88,7 @@ int main( /* set debugging stuff */ gossip_enable_stderr(); - gossip_set_debug_mask(0, GOSSIP_BMI_DEBUG_ALL); + gossip_set_debug_mask(1, GOSSIP_BMI_DEBUG_ALL); /* convert address to bmi method type by prefixing bmi_ */ cp = strchr(user_opts->hostid, ':'); @@ -98,7 +100,7 @@ int main( method[4+len] = '\0'; /* initialize local interface */ - ret = BMI_initialize(method, NULL, 0); + ret = BMI_initialize(NULL, NULL, 0); if (ret < 0) { errno = -ret; @@ -326,7 +328,74 @@ int main( return (0); } +#ifdef WIN32 +static struct options *parse_args( + int argc, + char *argv[]) +{ + int argi = 1; + + /* getopt stuff */ + char flags[] = "h:"; + int one_opt = 0; + + struct options *tmp_opts = NULL; + int len = -1; + /* create storage for the command line options */ + tmp_opts = (struct options *) malloc(sizeof(struct options)); + if (!tmp_opts) + { + goto parse_args_error; + } + + tmp_opts->hostid = NULL; + + /* look at command line arguments */ + while (argi < argc) + { + if (strcmp(argv[argi], "-h") == 0) + { + len = strlen(argv[++argi]) + 1; + tmp_opts->hostid = (char *) malloc(len); + if (tmp_opts->hostid == NULL) + { + goto parse_args_error; + } + memcpy(tmp_opts->hostid, argv[argi], len); + argi++; + } + else { + goto parse_args_error; + } + } + + /* if we didn't get a host argument, fill in a default: */ + if (tmp_opts->hostid == NULL) { + len = (strlen(DEFAULT_HOSTID)) + 1; + if ((tmp_opts->hostid = (char *) malloc(len)) == NULL) + { + goto parse_args_error; + } + memcpy(tmp_opts->hostid, DEFAULT_HOSTID, len); + } + + return (tmp_opts); + + parse_args_error: + + /* if an error occurs, just free everything and return NULL */ + if (tmp_opts) + { + if (tmp_opts->hostid) + { + free(tmp_opts->hostid); + } + free(tmp_opts); + } + return (NULL); +} +#else static struct options *parse_args( int argc, char *argv[]) @@ -391,6 +460,7 @@ static struct options *parse_args( } return (NULL); } +#endif /* * Local variables: diff --git a/test/io/bmi/test-bmi-client.c b/test/io/bmi/test-bmi-client.c index 3eb7717..b7a09f7 100644 --- a/test/io/bmi/test-bmi-client.c +++ b/test/io/bmi/test-bmi-client.c @@ -14,7 +14,9 @@ #include #include +#ifndef WIN32 #include +#endif #include #include @@ -297,7 +299,75 @@ int main( return (0); } +#ifdef WIN32 +static struct options *parse_args( + int argc, + char *argv[]) +{ + int argi = 1, len, ret; + struct options *tmp_opts = malloc(sizeof(struct options)); + if (!tmp_opts) + { + goto parse_args_error; + } + + /* defaults */ + tmp_opts->hostid = NULL; + tmp_opts->message_size = 32000; + + while (argi < argc) + { + if (strcmp(argv[argi], "-h") == 0) + { + len = strlen(argv[++argi]) + 1; + tmp_opts->hostid = (char *) malloc(len); + if (tmp_opts->hostid == NULL) + { + goto parse_args_error; + } + memcpy(tmp_opts->hostid, argv[argi], len); + argi++; + } + else if (strcmp(argv[argi], "-s") == 0) + { + ret = sscanf(argv[++argi], "%d", &tmp_opts->message_size); + if (ret < -1) + { + goto parse_args_error; + } + argi++; + } + else { + goto parse_args_error; + } + } + + /* if we didn't get a host argument, fill in a default: */ + if (tmp_opts->hostid == NULL) { + len = (strlen(DEFAULT_HOSTID)) + 1; + if ((tmp_opts->hostid = malloc(len)) == NULL) + { + goto parse_args_error; + } + memcpy(tmp_opts->hostid, DEFAULT_HOSTID, len); + } + + return (tmp_opts); + + parse_args_error: + /* if an error occurs, just free everything and return NULL */ + if (tmp_opts) + { + if (tmp_opts->hostid) + { + free(tmp_opts->hostid); + } + free(tmp_opts); + } + return (NULL); +} +#else static struct options *parse_args( int argc, char *argv[]) @@ -370,6 +440,7 @@ static struct options *parse_args( } return (NULL); } +#endif /* WIN32 */ /* * Local variables: diff --git a/test/io/bmi/test-bmi-server-eagerbug.c b/test/io/bmi/test-bmi-server-eagerbug.c index 2f1b256..4659339 100644 --- a/test/io/bmi/test-bmi-server-eagerbug.c +++ b/test/io/bmi/test-bmi-server-eagerbug.c @@ -14,7 +14,9 @@ #include #include +#ifndef WIN32 #include +#endif #include #include @@ -214,7 +216,11 @@ int main( } /* sleep a bit to let client get ahead of us */ +#ifdef WIN32 + Sleep(3000); +#else sleep(3); +#endif /* poke at BMI to make it buffer the eager message */ ret = BMI_testcontext(1, &out_id, &outcount, &error_code, @@ -338,6 +344,69 @@ int main( } +#ifdef WIN32 +static struct options *parse_args( + int argc, + char *argv[]) +{ + struct options *tmp_opts = NULL; + int len = -1, argi = 1; + + /* create storage for the command line options */ + tmp_opts = malloc(sizeof(struct options)); + if (!tmp_opts) + { + goto parse_args_error; + } + tmp_opts->hostid = NULL; + + /* look at command line arguments */ + while (argi < argc) + { + if (strcmp(argv[argi], "-h") == 0) + { + len = strlen(argv[++argi]) + 1; + tmp_opts->hostid = (char *) malloc(len); + if (tmp_opts->hostid == NULL) + { + goto parse_args_error; + } + memcpy(tmp_opts->hostid, argv[argi], len); + argi++; + } + else { + goto parse_args_error; + } + } + + + /* if we didn't get a host argument, fill in a default: */ + if (tmp_opts->hostid == NULL) { + len = (strlen(DEFAULT_SERVERID)) + 1; + if ((tmp_opts->hostid = malloc(len)) == NULL) + { + goto parse_args_error; + } + memcpy(tmp_opts->hostid, DEFAULT_SERVERID, len); + } + + return (tmp_opts); + + parse_args_error: + + /* if an error occurs, just free everything and return NULL */ + if (tmp_opts) + { + if (tmp_opts->hostid) + { + free(tmp_opts->hostid); + } + free(tmp_opts); + } + return (NULL); +} + +#else static struct options *parse_args( int argc, char *argv[]) @@ -399,6 +468,7 @@ static struct options *parse_args( } return (NULL); } +#endif /* * Local variables: diff --git a/test/io/bmi/test-bmi-server-list.c b/test/io/bmi/test-bmi-server-list.c index 1402d15..d478f7e 100644 --- a/test/io/bmi/test-bmi-server-list.c +++ b/test/io/bmi/test-bmi-server-list.c @@ -14,7 +14,9 @@ #include #include +#ifndef WIN32 #include +#endif #include #include @@ -80,7 +82,7 @@ int main( /* set debugging stuff */ gossip_enable_stderr(); - gossip_set_debug_mask(0, GOSSIP_BMI_DEBUG_ALL); + gossip_set_debug_mask(1, GOSSIP_BMI_DEBUG_ALL); /* convert address to bmi method type by prefixing bmi_ */ cp = strchr(user_opts->hostid, ':'); @@ -264,7 +266,73 @@ int main( return (0); } +#ifdef WIN32 +static struct options *parse_args( + int argc, + char *argv[]) +{ + + /* getopt stuff */ + char flags[] = "h:"; + int one_opt = 0; + + struct options *tmp_opts = NULL; + int len = -1; + int argi = 1; + + /* create storage for the command line options */ + tmp_opts = (struct options *) malloc(sizeof(struct options)); + if (!tmp_opts) + { + goto parse_args_error; + } + tmp_opts->hostid = NULL; + + /* look at command line arguments */ + while (argi < argc) + { + if (strcmp(argv[argi], "-h") == 0) + { + len = strlen(argv[++argi]) + 1; + tmp_opts->hostid = (char *) malloc(len); + if (tmp_opts->hostid == NULL) + { + goto parse_args_error; + } + memcpy(tmp_opts->hostid, argv[argi], len); + argi++; + } + else { + goto parse_args_error; + } + } + + /* if we didn't get a host argument, fill in a default: */ + if (tmp_opts->hostid == NULL) { + len = (strlen(DEFAULT_SERVERID)) + 1; + if ((tmp_opts->hostid = (char *) malloc(len)) == NULL) + { + goto parse_args_error; + } + memcpy(tmp_opts->hostid, DEFAULT_SERVERID, len); + } + + return (tmp_opts); + parse_args_error: + + /* if an error occurs, just free everything and return NULL */ + if (tmp_opts) + { + if (tmp_opts->hostid) + { + free(tmp_opts->hostid); + } + free(tmp_opts); + } + return (NULL); +} +#else static struct options *parse_args( int argc, char *argv[]) @@ -328,6 +396,7 @@ static struct options *parse_args( } return (NULL); } +#endif /* * Local variables: diff --git a/test/io/bmi/test-bmi-server.c b/test/io/bmi/test-bmi-server.c index 8b827b8..8baba79 100644 --- a/test/io/bmi/test-bmi-server.c +++ b/test/io/bmi/test-bmi-server.c @@ -14,7 +14,9 @@ #include #include +#ifndef WIN32 #include +#endif #include #include @@ -239,6 +241,65 @@ int main( } +#ifdef WIN32 +static struct options *parse_args( + int argc, + char *argv[]) +{ + int argi = 1, len; + struct options *tmp_opts = malloc(sizeof(struct options)); + if (!tmp_opts) + { + goto parse_args_error; + } + + /* defaults */ + tmp_opts->hostid = NULL; + + while (argi < argc) + { + if (strcmp(argv[argi], "-h") == 0) + { + len = strlen(argv[++argi]) + 1; + tmp_opts->hostid = (char *) malloc(len); + if (tmp_opts->hostid == NULL) + { + goto parse_args_error; + } + memcpy(tmp_opts->hostid, argv[argi], len); + argi++; + } + else { + goto parse_args_error; + } + } + + /* if we didn't get a host argument, fill in a default: */ + if (tmp_opts->hostid == NULL) { + len = (strlen(DEFAULT_HOSTID)) + 1; + if ((tmp_opts->hostid = malloc(len)) == NULL) + { + goto parse_args_error; + } + memcpy(tmp_opts->hostid, DEFAULT_HOSTID, len); + } + + return (tmp_opts); + + parse_args_error: + + /* if an error occurs, just free everything and return NULL */ + if (tmp_opts) + { + if (tmp_opts->hostid) + { + free(tmp_opts->hostid); + } + free(tmp_opts); + } + return (NULL); +} +#else static struct options *parse_args( int argc, char *argv[]) @@ -300,6 +361,7 @@ static struct options *parse_args( } return (NULL); } +#endif /* * Local variables: diff --git a/test/io/buffer/mt_test4.c b/test/io/buffer/mt_test4.c index f2312bb..cec22be 100644 --- a/test/io/buffer/mt_test4.c +++ b/test/io/buffer/mt_test4.c @@ -26,7 +26,7 @@ int main(int argc, char * argv[]) NCAC_info_t info; - int ret1, ret2, ret3; + int ret1, ret2; int extcnt; int threadcnt; @@ -50,7 +50,6 @@ int main(int argc, char * argv[]) ret1 = 0; ret2 = 1*req_cnt; - ret3 = 2*req_cnt; if (pthread_create(&thread1, NULL, diff --git a/test/io/trove/trove-export.c b/test/io/trove/trove-export.c index f2aa8d5..df440f5 100644 --- a/test/io/trove/trove-export.c +++ b/test/io/trove/trove-export.c @@ -156,8 +156,12 @@ int main(int argc, char **argv) } /* write data to file */ - write(fd, buf, f_size); - + ret = write(fd, buf, f_size); + if( ret == -1 ) + { + fprintf(stderr, "write failed.\n"); + return -1; + } close(fd); trove_close_context(coll_id, trove_context); diff --git a/test/io/trove/trove-import.c b/test/io/trove/trove-import.c index 054ca84..db5ae7a 100644 --- a/test/io/trove/trove-import.c +++ b/test/io/trove/trove-import.c @@ -170,7 +170,12 @@ int main(int argc, char **argv) if (buf == NULL) return -1; /* pull data from file */ - read(fd, buf, u_stat.st_size); + ret = read(fd, buf, u_stat.st_size); + if( ret == -1 ) + { + fprintf(stderr, "read failed.\n"); + return -1; + } f_size = (TROVE_size) u_stat.st_size; /* write data out to trove file */ diff --git a/test/io/trove/trove-ls.c b/test/io/trove/trove-ls.c index 721941d..13fe490 100644 --- a/test/io/trove/trove-ls.c +++ b/test/io/trove/trove-ls.c @@ -92,7 +92,7 @@ int main(int argc, char **argv) TROVE_DEFAULT_TEST_TIMEOUT); if (ret < 0) return -1; - if (s_attr.type != TROVE_TEST_DIR) { + if ((int)s_attr.type != TROVE_TEST_DIR) { fprintf(stderr, "%s is not a directory.\n", path_name); return -1; } diff --git a/test/io/trove/trove-rm.c b/test/io/trove/trove-rm.c index 58f6bd9..a58c045 100644 --- a/test/io/trove/trove-rm.c +++ b/test/io/trove/trove-rm.c @@ -115,7 +115,7 @@ int main(int argc, char **argv) TROVE_DEFAULT_TEST_TIMEOUT); if (ret < 0) return -1; - if (s_attr.type != TROVE_TEST_FILE) { + if ((int)s_attr.type != TROVE_TEST_FILE) { fprintf(stderr, "%s is not a file.\n", file_name); return -1; } diff --git a/test/io/trove/trove-test.h b/test/io/trove/trove-test.h index fe0c826..343e09e 100644 --- a/test/io/trove/trove-test.h +++ b/test/io/trove/trove-test.h @@ -92,7 +92,7 @@ static inline int path_lookup( if (ret < 0) return -1; if (state != 0) return -1; - if (s_attr.type != TROVE_TEST_DIR) { + if ((int)s_attr.type != TROVE_TEST_DIR) { fprintf(stderr, "%s is not a directory.\n", dir); return -1; } diff --git a/test/posix/libstat.c b/test/posix/libstat.c index 9d3944b..a1ca79e 100644 --- a/test/posix/libstat.c +++ b/test/posix/libstat.c @@ -5,7 +5,6 @@ #include #include #include -#include #include #define S_SLITE_SIZET 0x1 diff --git a/test/posix/open.c b/test/posix/open.c index 5c06763..a4ff76c 100644 --- a/test/posix/open.c +++ b/test/posix/open.c @@ -4,32 +4,61 @@ * system call! */ #include +#ifdef WIN32 +#include +#include +#else #include +#endif #include #include +#ifndef WIN32 #include +#endif #include #include #include #include #include +#ifndef WIN32 #include #include "sha1.h" #include "crc32c.h" +#endif #include "mpi.h" +#ifdef WIN32 +#define open(f, o, p) _open(f, o, p) +#define close(f) _close(f) +#define unlink(f) _unlink(f) +#endif + +#if 0 static inline double msec_diff(double *end, double *begin) { return (*end - *begin); } +#endif +#ifdef WIN32 +static double Wtime(void) +{ + LARGE_INTEGER counter; + + QueryPerformanceCounter(&counter); + + return (double) counter.QuadPart; +} +#else static double Wtime(void) { struct timeval t; gettimeofday(&t, NULL); return((double)t.tv_sec * 1e03 + (double)(t.tv_usec) * 1e-03); } +#endif +#if 0 struct file_handle_generic { /* Filled by VFS */ int32_t fhg_magic; /* magic number */ @@ -38,6 +67,7 @@ struct file_handle_generic { int32_t fhg_crc_csum; /* crc32c check sum of the blob */ unsigned char fhg_hmac_sha1[24]; /* hmac-sha1 message authentication code */ }; +#endif int main(int argc, char *argv[]) { @@ -47,11 +77,20 @@ int main(int argc, char *argv[]) double begin, end, tdiff = 0.0, max_diff; int open_flags = 0; int i, rank, np; +#ifdef WIN32 + LARGE_INTEGER freq; + HANDLE hFile; +#endif MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &np); - +#ifdef WIN32 + /* just use one option for now */ + fname = argv[1]; + open_flags |= O_CREAT; + do_create = 1; +#else while ((c = getopt(argc, argv, opt)) != EOF) { switch (c) { case 'u': @@ -75,6 +114,7 @@ int main(int argc, char *argv[]) exit(1); } } +#endif if (fname == NULL) { fprintf(stderr, "Usage: %s -f -c {create} -u {unlink} -n \n", argv[0]); @@ -88,18 +128,43 @@ int main(int argc, char *argv[]) open_flags |= O_RDONLY; begin = Wtime(); +#ifdef WIN32 + hFile = CreateFile(fname, + GENERIC_READ | GENERIC_WRITE, + FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, + NULL, + CREATE_ALWAYS, + FILE_ATTRIBUTE_NORMAL, + NULL); + if (hFile == INVALID_HANDLE_VALUE) + { + fprintf(stderr, "CreateFile: %d\n", GetLastError()); + MPI_Finalize(); + exit(1); + } +#else fd = open(fname, open_flags, 0775); if (fd < 0) { perror("open(2) error:"); MPI_Finalize(); exit(1); } +#endif end = Wtime(); tdiff += (end - begin); +#ifdef WIN32 + CloseHandle(hFile); +#else close(fd); +#endif if (rank == 0 && i < (niters - 1)) unlink(fname); } + +#ifdef WIN32 + QueryPerformanceFrequency(&freq); + tdiff = tdiff / (double) freq.QuadPart * 1000.0; +#endif tdiff = tdiff / niters; MPI_Allreduce(&tdiff, &max_diff, 1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD); diff --git a/test/posix/openg-socket.c b/test/posix/openg-socket.c index 8115122..30850ac 100644 --- a/test/posix/openg-socket.c +++ b/test/posix/openg-socket.c @@ -258,7 +258,6 @@ int main(int argc, char *argv[]) end = Wtime(); if (fd < 0) { fprintf(stderr, "openfh failed: %s\n", strerror(errno)); - free(ptr); exit(1); } printf("openfh returned %d [Time %g usec]\n", fd, usec_diff(&end, &begin));