DEVEL15-inactivevcache-hold-lock-20061109
authorChas Williams <chas@cmf.nrl.navy.mil>
Thu, 9 Nov 2006 23:03:15 +0000 (23:03 +0000)
committerDerrick Brashear <shadow@dementia.org>
Thu, 9 Nov 2006 23:03:15 +0000 (23:03 +0000)
FIXES 42798

hold a lock while we are in InactiveVCache

(cherry picked from commit 6975fcb202f2a599814ce9f26cda1999163050f8)

src/afs/afs_vcache.c

index 2c74d4b..72e40e5 100644 (file)
@@ -286,6 +286,7 @@ void
 afs_InactiveVCache(struct vcache *avc, struct AFS_UCRED *acred)
 {
     AFS_STATCNT(afs_inactive);
+    ObtainWriteLock(&avc->lock, 50);
     if (avc->states & CDirty) {
        /* we can't keep trying to push back dirty data forever.  Give up. */
        afs_InvalidateAllSegments(avc); /* turns off dirty bit */
@@ -295,11 +296,16 @@ afs_InactiveVCache(struct vcache *avc, struct AFS_UCRED *acred)
     if (avc->states & CUnlinked) {
        if (CheckLock(&afs_xvcache) || CheckLock(&afs_xdcache)) {
            avc->states |= CUnlinkedDel;
-           return;
+           goto unlock;
        }
+       ReleaseWriteLock(&avc->lock);
        afs_remunlink(avc, 1);  /* ignore any return code */
     }
+    return;
 
+ unlock:
+    ReleaseWriteLock(&avc->lock);
+    return;
 }
 #endif