]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
STABLE14-background-fsync-consistency-issues-20090522
authorDerrick Brashear <shadow@dementia.org>
Fri, 22 May 2009 17:00:46 +0000 (17:00 +0000)
committerDerrick Brashear <shadow@dementia.org>
Fri, 22 May 2009 17:00:46 +0000 (17:00 +0000)
LICENSE IPL10
FIXES 124359

avoid either reopening closed vnodes and leaving cached descriptors around,
or discarding a reference we're not holding; instead, sync changes when the
fd is closed, and note such has been done; otherwise, no changes from older
code.

(cherry picked from commit 12e85227c5dbfdb1258718ee3360bffacc4f96ac)

src/vol/ihandle.c
src/vol/vnode.c

index 04c4b0b66ce4a04b8ae86252a269686f36e52817..b5ef684fe3f8bef69a6bbf25cb46897dd4951a69 100644 (file)
@@ -803,10 +803,32 @@ ih_reallyclose(IHandle_t * ihP)
        return 0;
 
     IH_LOCK;
+    ihP->ih_refcnt++;   /* must not disappear over unlock */
+    if (ihP->ih_synced) {
+       FdHandle_t *fdP;
+       IH_UNLOCK;
+       
+       fdP = IH_OPEN(ihP);
+       if (fdP) { 
+           OS_SYNC(fdP->fd_fd);
+           FDH_CLOSE(fdP);
+       }
+       
+       IH_LOCK;
+    }
+
     assert(ihP->ih_refcnt > 0);
+    ihP->ih_synced = 0;
+
     ih_fdclose(ihP);
 
-    IH_UNLOCK;
+    if (ihP->ih_refcnt > 1) {
+       ihP->ih_refcnt--;
+       IH_UNLOCK;
+    } else {
+       IH_UNLOCK;
+       ih_release(ihP);
+    }
     return 0;
 }
 
@@ -884,8 +906,10 @@ ih_sync_all() {
                IH_UNLOCK;
 
                fdP = IH_OPEN(ihP);
-               if (fdP) OS_SYNC(fdP->fd_fd);
-               FDH_CLOSE(fdP);
+               if (fdP) { 
+                   OS_SYNC(fdP->fd_fd);
+                   FDH_CLOSE(fdP);
+               }
 
                IH_LOCK;
            }
index c8b7b14133c8bd702bafba6c016218f292a383dd..dfd159db1c8711fc902c81fc3933a03ea2102d75 100644 (file)
@@ -959,7 +959,6 @@ VCloseVnodeFiles_r(Volume * vp)
        for (vnp = VnodeHashTable[i]; vnp; vnp = vnp->hashNext) {
            if (vnp->volumePtr == vp) {
                IH_REALLYCLOSE(vnp->handle);
-               IH_RELEASE(vnp->handle);
            }
        }
     }