windows-afsd-misc-20080306
authorJeffrey Altman <jaltman@secure-endpoints.com>
Thu, 6 Mar 2008 14:33:09 +0000 (14:33 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Thu, 6 Mar 2008 14:33:09 +0000 (14:33 +0000)
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
src/WINNT/afsd/cm_dcache.c
src/WINNT/afsd/cm_vnodeops.c

index 4e9818d..9ef65d4 100644 (file)
@@ -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);
index 5b9c65f..3b7ffb3 100644 (file)
@@ -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;
 }
 
index 9b9f6dd..329e20b 100644 (file)
@@ -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;