#define CM_BUF_CMSTORING 2 /* storing this buffer */
#define CM_BUF_CMFULLYFETCHED 4 /* read-while-fetching optimization */
#define CM_BUF_CMWRITING 8 /* writing to this buffer */
-#define CM_BUF_CMBKGFETCH 16 /* background fetch queued by
- * prefetch or redirector */
/* waiting is done based on scp->flags. Removing bits from cmFlags
should be followed by waking the scp. */
bp = buf_Find(&scp->fid, &tbase);
/* We cheat slightly by not locking the bp mutex. */
if (bp) {
- if ((bp->cmFlags & (CM_BUF_CMFETCHING | CM_BUF_CMSTORING | CM_BUF_CMBKGFETCH)) == 0
+ if ((bp->cmFlags & (CM_BUF_CMFETCHING | CM_BUF_CMSTORING)) == 0
&& (bp->dataVersion < scp->bufDataVersionLow || bp->dataVersion > scp->dataVersion))
stop = 1;
buf_Release(bp);
lock_ObtainWrite(&scp->rw);
rxheld = 1;
}
- _InterlockedAnd(&bp->cmFlags, ~CM_BUF_CMBKGFETCH);
buf_Release(bp);
bp = NULL;
continue;
if (code == 0)
fetched = LargeIntegerAdd(fetched, tblocksize);
buf_Release(bp);
- _InterlockedAnd(&bp->cmFlags, ~CM_BUF_CMBKGFETCH);
}
if (!rxheld) {
rxheld = 1;
}
- /* Clear flag from any remaining buffers */
- for ( ;
- LargeIntegerLessThan(offset, end);
- offset = LargeIntegerAdd(offset, tblocksize) )
- {
- bp = buf_Find(scp, &offset);
- if (bp) {
- _InterlockedAnd(&bp->cmFlags, ~CM_BUF_CMBKGFETCH);
- buf_Release(bp);
- }
- }
cm_ClearPrefetchFlag(LargeIntegerGreaterThanZero(fetched) ? 0 : code,
scp, &base, &fetched);
osi_hyper_t readBase;
osi_hyper_t readLength;
osi_hyper_t readEnd;
- osi_hyper_t offset;
osi_hyper_t tblocksize; /* a long long temp variable */
- cm_buf_t *bp;
tblocksize = ConvertLongToLargeInteger(cm_data.buf_blockSize);
readEnd = LargeIntegerAdd(realBase, readLength);
- /*
- * Mark each buffer in the range as queued for a
- * background fetch
- */
- for ( offset = realBase;
- LargeIntegerLessThan(offset, readEnd);
- offset = LargeIntegerAdd(offset, tblocksize) )
- {
- if (rwheld) {
- lock_ReleaseWrite(&scp->rw);
- rwheld = 0;
- }
-
- bp = buf_Find(scp, &offset);
- if (!bp)
- continue;
-
- if (!rwheld) {
- lock_ObtainWrite(&scp->rw);
- rwheld = 1;
- }
-
- _InterlockedOr(&bp->cmFlags, CM_BUF_CMBKGFETCH);
- buf_Release(bp);
- }
-
if (rwheld)
lock_ReleaseWrite(&scp->rw);