From 2ba19804b979816b802ed0fda9aa60db9b4c1394 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Fri, 28 Dec 2007 07:26:00 +0000 Subject: [PATCH] DEVEL15-windows-get-buffer-20071228 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. (cherry picked from commit 33aeecd83f8ce670269868145648ae6e277cf3cb) --- src/WINNT/afsd/cm_dcache.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/WINNT/afsd/cm_dcache.c b/src/WINNT/afsd/cm_dcache.c index cc08c91f6..7fcbabf68 100644 --- a/src/WINNT/afsd/cm_dcache.c +++ b/src/WINNT/afsd/cm_dcache.c @@ -696,7 +696,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; @@ -1356,6 +1356,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); -- 2.39.5