From 6a631075c478794e998ad67d90e33d304521fbd3 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Thu, 6 Mar 2008 14:33:09 +0000 Subject: [PATCH] windows-afsd-misc-20080306 LICENSE MIT (1) an attempt to make better use of bandwidth from the BkgDaemon threads by preventing the thread from blocking on a vnode that is already storing data in another thread (2) prevents CM_SCACHEFLAG_ASYNCSTORE from being reset on a write failure. (3) fixes cm_EvaluateSysName to avoid accessing uninitialized memory (4) prevents a lock leak if the symlink's mountpointstring is too long. (This could never actually happen but better to correct the code.) --- src/WINNT/afsd/cm_daemon.c | 7 ++++++- src/WINNT/afsd/cm_dcache.c | 23 +++++++++++++++++++---- src/WINNT/afsd/cm_vnodeops.c | 8 +++++--- 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/src/WINNT/afsd/cm_daemon.c b/src/WINNT/afsd/cm_daemon.c index 4e9818d0c..9ef65d4af 100644 --- a/src/WINNT/afsd/cm_daemon.c +++ b/src/WINNT/afsd/cm_daemon.c @@ -105,7 +105,8 @@ void cm_BkgDaemon(void * parm) /* we found a request */ for (rp = cm_bkgListEndp; rp; rp = (cm_bkgRequest_t *) osi_QPrev(&rp->q)) { - if (cm_ServerAvailable(&rp->scp->fid, rp->userp)) + if (cm_ServerAvailable(&rp->scp->fid, rp->userp) && + !(rp->scp->flags & CM_SCACHEFLAG_DATASTORING)) break; } if (rp == NULL) { @@ -137,6 +138,10 @@ void cm_BkgDaemon(void * parm) lock_ObtainWrite(&cm_daemonLock); + /* + * Keep the following list synchronized with the + * error code list in cm_BkgStore + */ switch ( code ) { case 0: /* success */ osi_Log1(afsd_logp,"cm_BkgDaemon SUCCESS: request 0x%p", rp); diff --git a/src/WINNT/afsd/cm_dcache.c b/src/WINNT/afsd/cm_dcache.c index 5b9c65ff6..3b7ffb358 100644 --- a/src/WINNT/afsd/cm_dcache.c +++ b/src/WINNT/afsd/cm_dcache.c @@ -630,10 +630,25 @@ cm_BkgStore(cm_scache_t *scp, afs_uint32 p1, afs_uint32 p2, afs_uint32 p3, afs_u osi_Log4(afsd_logp, "Finished BKG store scp 0x%p, offset 0x%x:%08x, code 0x%x", scp, p2, p1, code); } - lock_ObtainWrite(&scp->rw); - cm_SyncOpDone(scp, NULL, CM_SCACHESYNC_ASYNCSTORE); - lock_ReleaseWrite(&scp->rw); - + /* + * Keep the following list synchronized with the + * error code list in cm_BkgDaemon + */ + switch ( code ) { + case CM_ERROR_TIMEDOUT: /* or server restarting */ + case CM_ERROR_RETRY: + case CM_ERROR_WOULDBLOCK: + case CM_ERROR_ALLBUSY: + case CM_ERROR_ALLDOWN: + case CM_ERROR_ALLOFFLINE: + case CM_ERROR_PARTIALWRITE: + break; /* cm_BkgDaemon will re-insert the request in the queue */ + case 0: + default: + lock_ObtainWrite(&scp->rw); + cm_SyncOpDone(scp, NULL, CM_SCACHESYNC_ASYNCSTORE); + lock_ReleaseWrite(&scp->rw); + } return code; } diff --git a/src/WINNT/afsd/cm_vnodeops.c b/src/WINNT/afsd/cm_vnodeops.c index 9b9f6ddd1..329e20b36 100644 --- a/src/WINNT/afsd/cm_vnodeops.c +++ b/src/WINNT/afsd/cm_vnodeops.c @@ -1408,7 +1408,7 @@ int cm_ExpandSysName(char *inp, char *outp, long outSize, unsigned int index) if (outp == NULL) return 1; - if (index >= MAXNUMSYSNAMES) + if (index >= cm_sysNameCount) return -1; /* otherwise generate the properly expanded @sys name */ @@ -1775,8 +1775,10 @@ long cm_AssembleLink(cm_scache_t *linkScp, char *pathSuffixp, * being a little conservative here. */ if (strlen(linkScp->mountPointStringp) + strlen(pathSuffixp) + 2 - >= CM_UTILS_SPACESIZE) - return CM_ERROR_TOOBIG; + >= CM_UTILS_SPACESIZE) { + code = CM_ERROR_TOOBIG; + goto done; + } tsp = cm_GetSpace(); linkp = linkScp->mountPointStringp; -- 2.39.5