]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
windows-get-buffer-20071228
authorJeffrey Altman <jaltman@secure-endpoints.com>
Fri, 28 Dec 2007 07:24:48 +0000 (07:24 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Fri, 28 Dec 2007 07:24:48 +0000 (07:24 +0000)
LICENSE MIT

cm_BkgPrefetch() contained two errors.  First, the loop at the top of the
function that ensures that a cm_buf_t is allocated for each of the offset
positions failed to actually obtain the buffer for the specified offset.
Instead, it repeatedly obtained the buffer for the starting base address.

Second, cm_GetBuffer() would reserve all of the buffers associated with
the cm_scache_t even in the case where we already have a callback and the
existing buffer has the proper data version number.  In that situation
reserving the buffers simply wastes valuable time.

src/WINNT/afsd/cm_dcache.c

index e5b34b16638830404095a899a74b644e0583c92d..620357ac778b6b17023100ae4b9b7f47c978b659 100644 (file)
@@ -694,7 +694,7 @@ cm_BkgPrefetch(cm_scache_t *scp, afs_uint32 p1, afs_uint32 p2, afs_uint32 p3, af
             lock_ReleaseMutex(&scp->mx);
             mxheld = 0;
         }
-        code = buf_Get(scp, &base, &bp);
+        code = buf_Get(scp, &offset, &bp);
         if (!mxheld) {
             lock_ObtainMutex(&scp->mx);
             mxheld = 1;
@@ -1354,6 +1354,11 @@ long cm_GetBuffer(cm_scache_t *scp, cm_buf_t *bufp, int *cpffp, cm_user_t *userp
         osi_Log1(afsd_logp,"GetBuffer returns cm_data.rootSCachep=%x",cm_data.rootSCachep);
 #endif
 
+    if (cm_HaveCallback(scp) && bufp->dataVersion == scp->dataVersion) {
+        /* We already have this buffer don't do extra work */
+        return 0;
+    }
+
     cm_AFSFidFromFid(&tfid, &scp->fid);
 
     code = cm_SetupFetchBIOD(scp, &bufp->offset, &biod, userp, reqp);