windows-buffers-20071210
authorJeffrey Altman <jaltman@secure-endpoints.com>
Mon, 10 Dec 2007 20:33:34 +0000 (20:33 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Mon, 10 Dec 2007 20:33:34 +0000 (20:33 +0000)
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.

src/WINNT/afsd/cm_buf.c

index 9904751..16c663d 100644 (file)
@@ -654,19 +654,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
@@ -1510,7 +1514,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) {
@@ -1520,7 +1524,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;