From: Derrick Brashear Date: Fri, 22 May 2009 17:00:35 +0000 (+0000) Subject: DEVEL15-background-fsync-consistency-issues-20090522 X-Git-Tag: openafs-devel-1_5_60~26 X-Git-Url: http://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=4742ef5e40b43b11362c92cb5ad03404d0617a5f DEVEL15-background-fsync-consistency-issues-20090522 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) --- diff --git a/src/vol/ihandle.c b/src/vol/ihandle.c index 743ddb8..b61c2b0 100644 --- a/src/vol/ihandle.c +++ b/src/vol/ihandle.c @@ -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; } @@ -885,8 +907,10 @@ ih_sync_all(void) { 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; } diff --git a/src/vol/vnode.c b/src/vol/vnode.c index 9c1677b..c7cf6c9 100644 --- a/src/vol/vnode.c +++ b/src/vol/vnode.c @@ -1659,7 +1659,6 @@ VCloseVnodeFiles_r(Volume * vp) for (i = 0; i < vec_len; i++) { IH_REALLYCLOSE(ih_vec[i]); - IH_RELEASE(ih_vec[i]); } free(ih_vec);