From aab0703b292374dc21d2de6f13c54a3f67ad3308 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Mon, 14 Dec 2009 13:33:02 -0500 Subject: [PATCH] Windows: remove CM_BUF_CMBKGFETCH flag The processing of the CM_BUF_CMBKGFETCH flag adds more overhead than it prevents. Get rid of it. LICENSE MIT Reviewed-on: http://gerrit.openafs.org/5359 Tested-by: BuildBot Tested-by: Jeffrey Altman Reviewed-by: Jeffrey Altman (cherry picked from commit b6f23864ffa380923f50d424063ad0804e407f4a) Change-Id: I423aa105bad99c70942d6b967a1dde70216fb096 Reviewed-on: http://gerrit.openafs.org/6033 Tested-by: BuildBot Reviewed-by: Jeffrey Altman Tested-by: Jeffrey Altman --- src/WINNT/afsd/cm_buf.h | 2 -- src/WINNT/afsd/cm_dcache.c | 43 +------------------------------------- 2 files changed, 1 insertion(+), 44 deletions(-) diff --git a/src/WINNT/afsd/cm_buf.h b/src/WINNT/afsd/cm_buf.h index 8503dbd39..04edecab3 100644 --- a/src/WINNT/afsd/cm_buf.h +++ b/src/WINNT/afsd/cm_buf.h @@ -95,8 +95,6 @@ typedef struct cm_buf { #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. */ diff --git a/src/WINNT/afsd/cm_dcache.c b/src/WINNT/afsd/cm_dcache.c index d5db0bb17..c0ae110a3 100644 --- a/src/WINNT/afsd/cm_dcache.c +++ b/src/WINNT/afsd/cm_dcache.c @@ -686,7 +686,7 @@ cm_CheckFetchRange(cm_scache_t *scp, osi_hyper_t *startBasep, osi_hyper_t *lengt bp = buf_Find(scp, &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); @@ -839,7 +839,6 @@ cm_BkgPrefetch(cm_scache_t *scp, afs_uint32 p1, afs_uint32 p2, afs_uint32 p3, af lock_ObtainWrite(&scp->rw); rxheld = 1; } - _InterlockedAnd(&bp->cmFlags, ~CM_BUF_CMBKGFETCH); buf_Release(bp); bp = NULL; continue; @@ -854,7 +853,6 @@ cm_BkgPrefetch(cm_scache_t *scp, afs_uint32 p1, afs_uint32 p2, afs_uint32 p3, af if (code == 0) fetched = LargeIntegerAdd(fetched, tblocksize); buf_Release(bp); - _InterlockedAnd(&bp->cmFlags, ~CM_BUF_CMBKGFETCH); } if (!rxheld) { @@ -862,17 +860,6 @@ cm_BkgPrefetch(cm_scache_t *scp, afs_uint32 p1, afs_uint32 p2, afs_uint32 p3, af 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); @@ -902,9 +889,7 @@ void cm_ConsiderPrefetch(cm_scache_t *scp, osi_hyper_t *offsetp, afs_uint32 coun 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); @@ -940,32 +925,6 @@ void cm_ConsiderPrefetch(cm_scache_t *scp, osi_hyper_t *offsetp, afs_uint32 coun 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); -- 2.39.5