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)
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;
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);