From 4d0797d6d9fa6d92efbcac9afb72383f0cd7fa32 Mon Sep 17 00:00:00 2001 From: Derrick Brashear Date: Thu, 2 Dec 2010 01:55:34 -0500 Subject: [PATCH] freebsd: properly track vcache references previously both root and reclaim could end up leaking refs. fix it. Reviewed-on: http://gerrit.openafs.org/3424 Reviewed-by: Benjamin Kaduk Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear (cherry picked from commit 6eb1088aad9163ab8d4a4dda513444290c55daa6) Change-Id: I0c5c8554caf777e8c97529a7d640a79211a0300c Reviewed-on: http://gerrit.openafs.org/3450 --- src/afs/FBSD/osi_vfsops.c | 20 +++++++++++++++++--- src/afs/FBSD/osi_vnodeops.c | 6 ++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/afs/FBSD/osi_vfsops.c b/src/afs/FBSD/osi_vfsops.c index d3e6c57a4..32a8feb43 100644 --- a/src/afs/FBSD/osi_vfsops.c +++ b/src/afs/FBSD/osi_vfsops.c @@ -189,19 +189,33 @@ afs_unmount(struct mount *mp, int flags, struct thread *p) { int error = 0; + AFS_GLOCK(); + if (afs_globalVp && + ((flags & MNT_FORCE) || !VREFCOUNT_GT(afs_globalVp, 1))) { + /* Put back afs_root's ref */ + struct vcache *gvp = afs_globalVp; + afs_globalVp = NULL; + afs_PutVCache(gvp); + } + if (afs_globalVp) + error = EBUSY; + AFS_GUNLOCK(); + /* * Release any remaining vnodes on this mount point. * The `1' means that we hold one extra reference on * the root vnode (this is just a guess right now). * This has to be done outside the global lock. */ + if (!error) { #if defined(AFS_FBSD80_ENV) - error = vflush(mp, 1, (flags & MNT_FORCE) ? FORCECLOSE : 0, curthread); + error = vflush(mp, 1, (flags & MNT_FORCE) ? FORCECLOSE : 0, curthread); #elif defined(AFS_FBSD53_ENV) - error = vflush(mp, 1, (flags & MNT_FORCE) ? FORCECLOSE : 0, p); + error = vflush(mp, 1, (flags & MNT_FORCE) ? FORCECLOSE : 0, p); #else - error = vflush(mp, 1, (flags & MNT_FORCE) ? FORCECLOSE : 0); + error = vflush(mp, 1, (flags & MNT_FORCE) ? FORCECLOSE : 0); #endif + } if (error) goto out; AFS_GLOCK(); diff --git a/src/afs/FBSD/osi_vnodeops.c b/src/afs/FBSD/osi_vnodeops.c index cbd94d797..5bb5f658d 100644 --- a/src/afs/FBSD/osi_vnodeops.c +++ b/src/afs/FBSD/osi_vnodeops.c @@ -1486,6 +1486,12 @@ afs_vop_reclaim(struct vop_reclaim_args *ap) ObtainWriteLock(&afs_xvcache, 901); /* reclaim the vnode and the in-memory vcache, but keep the on-disk vcache */ code = afs_FlushVCache(avc, &slept); + + if (avc->f.states & CVInit) { + avc->f.states &= ~CVInit; + afs_osi_Wakeup(&avc->f.states); + } + if (!haveVlock) ReleaseWriteLock(&afs_xvcache); if (!haveGlock) -- 2.39.5