From b1dd6e87cb615dcad234537751fb20ce91febeda Mon Sep 17 00:00:00 2001 From: Derrick Brashear Date: Sat, 15 Nov 2003 04:59:08 +0000 Subject: [PATCH] threaded-volserver-progress-20031114 not ready for primetime. not even close. --- Makefile.in | 12 +++ configure.in | 1 + src/tvolser/Makefile.in | 206 ++++++++++++++++++++++++++++++++++++++++ src/vol/fssync.c | 15 ++- src/vol/volume.c | 1 + src/vol/volume.h | 7 ++ src/vol/vutil.c | 6 +- src/volser/common.c | 6 ++ src/volser/dumpstuff.c | 8 ++ src/volser/volmain.c | 37 ++++++-- src/volser/volprocs.c | 12 +++ src/volser/volser.p.h | 6 ++ 12 files changed, 304 insertions(+), 13 deletions(-) create mode 100644 src/tvolser/Makefile.in diff --git a/Makefile.in b/Makefile.in index 9acc7c5268..1dd09ff610 100644 --- a/Makefile.in +++ b/Makefile.in @@ -230,6 +230,18 @@ tviced: cmd comerr viced vlserver libafsrpc libafsauthent volser: cmd comerr tviced usd kauth audit ${COMPILE_PART1} volser ${COMPILE_PART2} +tvolser: project tviced usd libafsrpc libafsauthent + case ${SYS_NAME} in \ + alpha_dux*|sgi_*|sun*_5*|rs_aix*|*linux*|hp_ux11*|ia64_hpux*) \ + ${COMPILE_PART1} tvolser ${COMPILE_PART2} ;; \ + *_darwin_[1-6][0-9]) \ + echo Not building MT volser for ${SYS_NAME} ;; \ + *_darwin_*) \ + ${COMPILE_PART1} tvolser ${COMPILE_PART2} ;; \ + *) \ + echo Not building MT volser for ${SYS_NAME} ;; \ + esac + venus: cmd comerr volser ptserver ${COMPILE_PART1} venus ${COMPILE_PART2} ${COMPILE_PART1} venus/test ${COMPILE_PART2} diff --git a/configure.in b/configure.in index a200c7fe8c..76956d14d6 100644 --- a/configure.in +++ b/configure.in @@ -106,6 +106,7 @@ src/tests/run-tests \ src/tests/OpenAFS/Dirpath.pm \ src/tsm41/Makefile \ src/tviced/Makefile \ +src/tvolser/Makefile \ src/ubik/Makefile \ src/update/Makefile \ src/usd/test/Makefile \ diff --git a/src/tvolser/Makefile.in b/src/tvolser/Makefile.in new file mode 100644 index 0000000000..4331105179 --- /dev/null +++ b/src/tvolser/Makefile.in @@ -0,0 +1,206 @@ +# Copyright 2000, International Business Machines Corporation and others. +# All Rights Reserved. +# +# This software has been released under the terms of the IBM Public +# License. For details, see the LICENSE file in the top-level source +# directory or online at http://www.openafs.org/dl/license10.html + +srcdir=@srcdir@ +include @TOP_OBJDIR@/src/config/Makefile.config +HELPER_SPLINT=@HELPER_SPLINT@ + +CC=${MT_CC} +CFLAGS=${COMMON_CFLAGS} -I.. -DNINTERFACE ${MT_CFLAGS} -DRXDEBUG + +CCRULE=${CC} ${CFLAGS} -c $? + +VICED=../viced +VLSERVER=../vlserver +LWP=../lwp +LIBACL=../libacl +UTIL=../util +DIR=../dir +VOL=../vol +FSINT=../fsint +VOLSER=../volser + +VOLSEROBJS=volmain.o volprocs.o physio.o voltrans.o volerr.o volint.cs.o dumpstuff.o volint.ss.o volint.xdr.o vscommon.o + +VLSERVEROBJS=#vldbint.cs.o vldbint.xdr.o + +LWPOBJS=lock.o fasttime.o threadname.o + +LIBACLOBJS=aclprocs.o netprocs.o + +UTILOBJS=assert.o uuid.o serverLog.o fileutil.o netutils.o dirpath.o volparse.o flipbase64.o softsig.o + +DIROBJS=buffer.o dir.o salvage.o + +VOLOBJS= vnode.o volume.o vutil.o partition.o fssync.o purge.o \ + clone.o devname.o common.o ihandle.o listinodes.o namei_ops.o nuke.o + +FSINTOBJS=# afsaux.o afscbint.cs.o afsint.ss.o afsint.xdr.o + +objects= ${VOLSEROBJS} ${VLSERVEROBJS} ${LWPOBJS} ${LIBACLOBJS} \ + ${UTILOBJS} ${DIROBJS} ${VOLOBJS} ${FSINTOBJS} + +LIBS=${TOP_LIBDIR}/libafsauthent.a ${TOP_LIBDIR}/libafsrpc.a ${TOP_LIBDIR}/util.a + +all: volserver + +COMPILE=${CC} ${CFLAGS} -c $? + +volmain.o: ${VOLSER}/volmain.c + ${COMPILE} +volprocs.o: ${VOLSER}/volprocs.c + ${COMPILE} +physio.o: ${VOLSER}/physio.c + ${COMPILE} +voltrans.o: ${VOLSER}/voltrans.c + ${COMPILE} +volerr.o: ${VOLSER}/volerr.c + ${COMPILE} +volint.cs.o: ${VOLSER}/volint.cs.c + ${COMPILE} +dumpstuff.o: ${VOLSER}/dumpstuff.c + ${COMPILE} +volint.ss.o: ${VOLSER}/volint.ss.c + ${COMPILE} +volint.xdr.o: ${VOLSER}/volint.xdr.c + ${COMPILE} + +assert.o: ${UTIL}/assert.c + ${COMPILE} + +uuid.o: ${UTIL}/uuid.c + ${COMPILE} + +serverLog.o: ${UTIL}/serverLog.c + ${COMPILE} + +fileutil.o: ${UTIL}/fileutil.c + ${COMPILE} + +volparse.o: ${UTIL}/volparse.c + ${COMPILE} + +flipbase64.o: ${UTIL}/flipbase64.c + ${COMPILE} + +netutils.o: ${UTIL}/netutils.c + ${COMPILE} + +dirpath.o: ${UTIL}/dirpath.c + ${COMPILE} + +softsig.o: ${UTIL}/softsig.c + ${COMPILE} + +lock.o: ${LWP}/lock.c + ${COMPILE} + +fasttime.o: ${LWP}/fasttime.c + ${COMPILE} + +threadname.o: ${LWP}/threadname.c + ${COMPILE} + +aclprocs.o: ${LIBACL}/aclprocs.c + ${COMPILE} + +netprocs.o: ${LIBACL}/netprocs.c + ${COMPILE} + +vldbint.cs.o: ${VLSERVER}/vldbint.cs.c + ${COMPILE} + +vldbint.xdr.o: ${VLSERVER}/vldbint.xdr.c + ${COMPILE} + +buffer.o: ${DIR}/buffer.c + ${COMPILE} + +dir.o: ${DIR}/dir.c + ${COMPILE} + +salvage.o: ${DIR}/salvage.c + ${COMPILE} + +vnode.o: ${VOL}/vnode.c + ${COMPILE} + +volume.o: ${VOL}/volume.c + ${COMPILE} + +vutil.o: ${VOL}/vutil.c + ${COMPILE} + +partition.o: ${VOL}/partition.c + ${COMPILE} + +nuke.o: ${VOL}/nuke.c + ${COMPILE} + +fssync.o: ${VOL}/fssync.c + ${COMPILE} + +purge.o: ${VOL}/purge.c + ${COMPILE} + +clone.o: ${VOL}/clone.c + ${COMPILE} + +devname.o: ${VOL}/devname.c + ${COMPILE} + +common.o: ${VOL}/common.c + ${COMPILE} + +vscommon.o: ${VOLSER}/common.c + ${COMPILE} -o vscommon.o + +listinodes.o: ${VOL}/listinodes.c + ${COMPILE} + +ihandle.o: ${VOL}/ihandle.c + ${COMPILE} + +namei_ops.o: ${VOL}/namei_ops.c + ${COMPILE} + +afsaux.o: ${FSINT}/afsaux.c + ${COMPILE} + +afscbint.cs.o: ${FSINT}/afscbint.cs.c + ${COMPILE} + +afscbint.ss.o: ${FSINT}/afscbint.ss.c + ${COMPILE} + +afsint.cs.o: ${FSINT}/afsint.cs.c + ${COMPILE} + +afsint.ss.o: ${FSINT}/afsint.ss.c + ${COMPILE} + +afsint.xdr.o: ${FSINT}/afsint.xdr.c + ${COMPILE} + +volserver: ${objects} ${LIBS} + ${CC} ${LDFLAGS} -o volserver ${objects} ${LIBS} ${MTLIBS} ${XLIBS} + +${DEST}/root.server/usr/afs/bin/volserver: volserver + ${INSTALL} -ns $? $@ + +install: ${DESTDIR}${afssrvlibexecdir}/volserver + +clean: + $(RM) -f *.o volserver core AFS_component_version_number.c + +include ../config/Makefile.version + +${DESTDIR}${afssrvlibexecdir}/volserver: volserver + ${INSTALL} -ns $? $@ + +dest: ${DEST}/root.server/usr/afs/bin/volserver + diff --git a/src/vol/fssync.c b/src/vol/fssync.c index 1494552c39..7e0c0ef5d3 100644 --- a/src/vol/fssync.c +++ b/src/vol/fssync.c @@ -204,26 +204,31 @@ FSYNC_askfs(VolumeId volume, char *partName, int com, int reason) else command.partName[0] = 0; assert(FS_sd != -1); + VFSYNC_LOCK #ifdef AFS_NT40_ENV if (send(FS_sd, (char *)&command, sizeof(command), 0) != sizeof(command)) { printf("FSYNC_askfs: write to file server failed\n"); - return FSYNC_DENIED; + response = FSYNC_DENIED; + goto done; } while ((n = recv(FS_sd, &response, 1, 0)) != 1) { if (n == 0 || WSAEINTR != WSAGetLastError()) { printf("FSYNC_askfs: No response from file server\n"); - return FSYNC_DENIED; + response = FSYNC_DENIED; + goto done; } } #else if (write(FS_sd, &command, sizeof(command)) != sizeof(command)) { printf("FSYNC_askfs: write to file server failed\n"); - return FSYNC_DENIED; + response = FSYNC_DENIED; + goto done; } while ((n = read(FS_sd, &response, 1)) != 1) { if (n == 0 || errno != EINTR) { printf("FSYNC_askfs: No response from file server\n"); - return FSYNC_DENIED; + response = FSYNC_DENIED; + goto done; } } #endif @@ -232,6 +237,8 @@ FSYNC_askfs(VolumeId volume, char *partName, int com, int reason) ("FSYNC_askfs: negative response from file server; volume %u, command %d\n", command.volume, (int)command.command); } + done: + VFSYNC_UNLOCK return response; } diff --git a/src/vol/volume.c b/src/vol/volume.c index e9b140fe14..1d53d06f01 100644 --- a/src/vol/volume.c +++ b/src/vol/volume.c @@ -148,6 +148,7 @@ RCSID #ifdef AFS_PTHREAD_ENV pthread_mutex_t vol_glock_mutex; pthread_mutex_t vol_attach_mutex; +pthread_mutex_t vol_fsync_mutex; pthread_cond_t vol_put_volume_cond; pthread_cond_t vol_sleep_cond; #endif /* AFS_PTHREAD_ENV */ diff --git a/src/vol/volume.h b/src/vol/volume.h index 63cd6ea5c4..d01e5b56bf 100644 --- a/src/vol/volume.h +++ b/src/vol/volume.h @@ -30,6 +30,7 @@ typedef bit32 FileOffset; /* Offset in this file */ #include extern pthread_mutex_t vol_glock_mutex; extern pthread_mutex_t vol_attach_mutex; +extern pthread_mutex_t vol_fsync_mutex; extern pthread_cond_t vol_put_volume_cond; extern pthread_cond_t vol_sleep_cond; #define VATTACH_LOCK \ @@ -40,11 +41,17 @@ extern pthread_cond_t vol_sleep_cond; assert(pthread_mutex_lock(&vol_glock_mutex) == 0); #define VOL_UNLOCK \ assert(pthread_mutex_unlock(&vol_glock_mutex) == 0); +#define VFSYNC_LOCK \ + assert(pthread_mutex_lock(&vol_fsync_mutex) == 0); +#define VFSYNC_UNLOCK \ + assert(pthread_mutex_unlock(&vol_fsync_mutex) == 0); #else /* AFS_PTHREAD_ENV */ #define VATTACH_LOCK #define VATTACH_UNLOCK #define VOL_LOCK #define VOL_UNLOCK +#define VFSYNC_LOCK +#define VFSYNC_UNLOCK #endif /* AFS_PTHREAD_ENV */ typedef enum { fileServer, volumeUtility, salvager } ProgramType; diff --git a/src/vol/vutil.c b/src/vol/vutil.c index ed551c1d9a..4bd448a13b 100644 --- a/src/vol/vutil.c +++ b/src/vol/vutil.c @@ -139,7 +139,7 @@ VCreateVolume_r(Error * ec, char *partname, VolId volumeId, VolId parentId) handle = NULL; /* Verify that the parition is valid before writing to it. */ - if (!(partition = VGetPartition(partname, 0))) { + if (!(partition = VGetPartition_r(partname, 0))) { Log("VCreateVolume: partition %s is not in service.\n", partname); *ec = VNOVOL; return NULL; @@ -148,7 +148,7 @@ VCreateVolume_r(Error * ec, char *partname, VolId volumeId, VolId parentId) nearInodeHash(volumeId, nearInode); nearInode %= partition->f_files; #endif - VLockPartition(partname); + VLockPartition_r(partname); memset(&tempHeader, 0, sizeof(tempHeader)); tempHeader.stamp.magic = VOLUMEHEADERMAGIC; tempHeader.stamp.version = VOLUMEHEADERVERSION; @@ -282,7 +282,7 @@ VCreateVolume_r(Error * ec, char *partname, VolId volumeId, VolId parentId) } fsync(fd); close(fd); - return (VAttachVolumeByName(ec, partname, headerName, V_SECRETLY)); + return (VAttachVolumeByName_r(ec, partname, headerName, V_SECRETLY)); } diff --git a/src/volser/common.c b/src/volser/common.c index f6238390fc..30b536ae08 100644 --- a/src/volser/common.c +++ b/src/volser/common.c @@ -17,6 +17,7 @@ RCSID #include #include +#ifndef AFS_PTHREAD_ENV /*@printflike@*/ void Log(const char *format, ...) { @@ -26,6 +27,7 @@ Log(const char *format, ...) vViceLog(0, (format, args)); va_end(args); } +#endif void LogError(afs_int32 errcode) @@ -34,6 +36,7 @@ LogError(afs_int32 errcode) ("%s: %s\n", error_table_name(errcode), error_message(errcode))); } +#ifndef AFS_PTHREAD_ENV /*@printflike@*/ void Abort(const char *format, ...) { @@ -45,10 +48,12 @@ Abort(const char *format, ...) va_end(args); abort(); } +#endif void InitErrTabs(void) { +#ifndef AFS_PTHREAD_ENV initialize_KA_error_table(); initialize_RXK_error_table(); initialize_KTC_error_table(); @@ -56,5 +61,6 @@ InitErrTabs(void) initialize_CMD_error_table(); initialize_VL_error_table(); initialize_VOLS_error_table(); +#endif return; } diff --git a/src/volser/dumpstuff.c b/src/volser/dumpstuff.c index ac206f9ff9..4a5217e59a 100644 --- a/src/volser/dumpstuff.c +++ b/src/volser/dumpstuff.c @@ -34,7 +34,11 @@ RCSID #endif #endif #include +#ifdef AFS_PTHREAD_ENV +#include +#else /* AFS_PTHREAD_ENV */ #include +#endif /* AFS_PTHREAD_ENV */ #include #include #include @@ -609,7 +613,9 @@ DumpFile(struct iod *iodp, int vnode, FdHandle_t * handleP) /* Now write the data out */ if (iod_Write(iodp, (char *)p, howMany) != howMany) error = VOLSERDUMPERROR; +#ifndef AFS_PTHREAD_ENV IOMGR_Poll(); +#endif } if (pad) { /* Any padding we hadn't reported yet */ @@ -798,8 +804,10 @@ DumpVnodeIndex(register struct iod *iodp, Volume * vp, VnodeClass class, code = DumpVnode(iodp, vnode, V_id(vp), bitNumberToVnodeNumber(vnodeIndex, class), flag); +#ifndef AFS_PTHREAD_ENV if (!flag) IOMGR_Poll(); /* if we dont' xfr data, but scan instead, could lose conn */ +#endif } STREAM_CLOSE(file); FDH_CLOSE(fdP); diff --git a/src/volser/volmain.c b/src/volser/volmain.c index f6e94b1a5d..8fa9058a44 100644 --- a/src/volser/volmain.c +++ b/src/volser/volmain.c @@ -35,7 +35,11 @@ RCSID #include #include #include +#ifdef AFS_PTHREAD_ENV +#include +#else /* AFS_PTHREAD_ENV */ #include +#endif /* AFS_PTHREAD_ENV */ #include #include #include @@ -69,7 +73,9 @@ RCSID extern int (*vol_PollProc) (); extern struct volser_trans *TransList(); +#ifndef AFS_PTHREAD_ENV extern int IOMGR_Poll(); +#endif char *GlobalNameHack = NULL; int hackIsIn = 0; afs_int32 GlobalVolCloneId, GlobalVolParentId; @@ -135,7 +141,11 @@ BKGLoop() while (1) { tv.tv_sec = GCWAKEUP; tv.tv_usec = 0; +#ifdef AFS_PTHREAD_ENV + select(0, 0, 0, 0, &tv); +#else (void)IOMGR_Select(0, 0, 0, 0, &tv); +#endif GCTrans(); TryUnlock(); loop++; @@ -155,7 +165,11 @@ BKGSleep() if (TTsleep) { while (1) { +#ifdef AFS_PTHREAD_ENV + sleep(TTrun); +#else /* AFS_PTHREAD_ENV */ IOMGR_Sleep(TTrun); +#endif for (tt = TransList(); tt; tt = tt->next) { if ((strcmp(tt->lastProcName, "DeleteVolume") == 0) || (strcmp(tt->lastProcName, "Clone") == 0) @@ -209,7 +223,6 @@ main(argc, argv) int argc; char **argv; { - char *pid; register afs_int32 code; struct rx_securityClass *(securityObjects[3]); struct rx_service *service; @@ -340,7 +353,9 @@ main(argc, argv) #endif VInitVolumePackage(volumeUtility, 0, 0, CONNECT_FS, 0); DInit(40); +#ifndef AFS_PTHREAD_ENV vol_PollProc = IOMGR_Poll; /* tell vol pkg to poll io system periodically */ +#endif #ifndef AFS_NT40_ENV rxi_syscallp = volser_syscall; #endif @@ -365,11 +380,21 @@ main(argc, argv) OpenLog(AFSDIR_SERVER_VOLSERLOG_FILEPATH); SetupLogSignals(); - /* create the lwp to garbage-collect old transactions and sleep periodically */ - LWP_CreateProcess(BKGLoop, 16 * 1024, 3, (void *)0, "vol bkg daemon", - &pid); - LWP_CreateProcess(BKGSleep, 16 * 1024, 3, (void *)0, "vol slp daemon", - &pid); + { +#ifdef AFS_PTHREAD_ENV + pthread_t tid; + pthread_attr_t tattr; + assert(pthread_attr_init(&tattr) == 0); + assert(pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED) == 0); + + assert(pthread_create(&tid, &tattr, BKGLoop, NULL) == 0); + assert(pthread_create(&tid, &tattr, BKGSleep, NULL) == 0); +#else + PROCESS pid; + LWP_CreateProcess(BKGLoop, 16*1024, 3, 0, "vol bkg daemon", &pid); + LWP_CreateProcess(BKGSleep,16*1024, 3, 0, "vol slp daemon", &pid); +#endif + } /* Create a single security object, in this case the null security object, for unauthenticated connections, which will be used to control security on connections made to this server */ diff --git a/src/volser/volprocs.c b/src/volser/volprocs.c index a390e0d833..a75576b6e1 100644 --- a/src/volser/volprocs.c +++ b/src/volser/volprocs.c @@ -40,7 +40,11 @@ RCSID #include #include #include +#ifdef AFS_PTHREAD_ENV +#include +#else /* AFS_PTHREAD_ENV */ #include +#endif /* AFS_PTHREAD_ENV */ #include #include #include @@ -1916,7 +1920,9 @@ VolListOneVolume(acid, partid, volumeId, volumeInfo) if (volid == volumeId) { /*copy other things too */ found = 1; +#ifndef AFS_PTHREAD_ENV IOMGR_Poll(); /*make sure that the client doesnot time out */ +#endif ttc = NewTrans(volid, partid); if (!ttc) { pntr->status = VBUSY; @@ -2127,7 +2133,9 @@ VolXListOneVolume(a_rxCidP, a_partID, a_volID, a_volumeXInfoP) * doesn't time out) and to set up a transaction on the volume. */ found = 1; +#ifndef AFS_PTHREAD_ENV IOMGR_Poll(); +#endif ttc = NewTrans(currVolID, a_partID); if (!ttc) { /* @@ -2304,7 +2312,9 @@ VolListVolumes(acid, partid, flags, volumeInfo) } if (flags) { /*copy other things too */ +#ifndef AFS_PTHREAD_ENV IOMGR_Poll(); /*make sure that the client doesnot time out */ +#endif ttc = NewTrans(volid, partid); if (!ttc) { pntr->status = VBUSY; @@ -2543,7 +2553,9 @@ VolXListVolumes(a_rxCidP, a_partID, a_flags, a_volumeXInfoP) * Full info about the volume desired. Poll to make sure the * client doesn't time out, then start up a new transaction. */ +#ifndef AFS_PTHREAD_ENV IOMGR_Poll(); +#endif ttc = NewTrans(volid, a_partID); if (!ttc) { /* diff --git a/src/volser/volser.p.h b/src/volser/volser.p.h index be9801cc03..6cea79ef33 100644 --- a/src/volser/volser.p.h +++ b/src/volser/volser.p.h @@ -9,6 +9,12 @@ #ifndef _VOLSER_ #define _VOLSER_ 1 + +#ifdef AFS_PTHREAD_ENV +#include +#include +#endif + /* vflags, representing state of the volume */ #define VTDeleteOnSalvage 1 /* delete on next salvage */ #define VTOutOfService 2 /* never put this volume online */