From fd7856fa5d60775aae763350317eea4c14964812 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Mon, 10 Dec 2007 20:35:06 +0000 Subject: [PATCH] DEVEL15-windows-buffers-20071210 LICENSE MIT after removing cm_buf_t objects from the hash tables, clear the HT list pointers to make debugging easier. when modifying data version values in buf_ForceDataVersion() grab a read lock on buf_globalLock instead of a write lock. A write lock is only required if the hash table linked lists are being modified. The dataVersion itself is protected by the cm_scache_t mx mutex being held. (cherry picked from commit ef5e9a4dd7a4977d7d9f41266f2a0c491720e387) --- src/WINNT/afsd/cm_buf.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/WINNT/afsd/cm_buf.c b/src/WINNT/afsd/cm_buf.c index 52658f18e4..dc7b4aefc9 100644 --- a/src/WINNT/afsd/cm_buf.c +++ b/src/WINNT/afsd/cm_buf.c @@ -700,19 +700,23 @@ void buf_Recycle(cm_buf_t *bp) i = BUF_HASH(&bp->fid, &bp->offset); lbpp = &(cm_data.buf_scacheHashTablepp[i]); for(tbp = *lbpp; tbp; lbpp = &tbp->hashp, tbp = *lbpp) { - if (tbp == bp) break; + if (tbp == bp) + break; } /* we better find it */ osi_assertx(tbp != NULL, "buf_Recycle: hash table screwup"); *lbpp = bp->hashp; /* hash out */ + bp->hashp = NULL; /* Remove from file hash */ i = BUF_FILEHASH(&bp->fid); prevBp = bp->fileHashBackp; + bp->fileHashBackp = NULL; nextBp = bp->fileHashp; + bp->fileHashp = NULL; if (prevBp) prevBp->fileHashp = nextBp; else @@ -1560,7 +1564,7 @@ long buf_ForceDataVersion(cm_scache_t * scp, afs_uint64 fromVersion, afs_uint64 i = BUF_FILEHASH(&scp->fid); - lock_ObtainWrite(&buf_globalLock); + lock_ObtainRead(&buf_globalLock); for (bp = cm_data.buf_fileHashTablepp[i]; bp; bp = bp->fileHashp) { if (cm_FidCmp(&bp->fid, &scp->fid) == 0) { @@ -1570,7 +1574,7 @@ long buf_ForceDataVersion(cm_scache_t * scp, afs_uint64 fromVersion, afs_uint64 } } } - lock_ReleaseWrite(&buf_globalLock); + lock_ReleaseRead(&buf_globalLock); if (found) return 0;