diff options
author | iedowse <iedowse@FreeBSD.org> | 2001-05-16 18:04:37 +0000 |
---|---|---|
committer | iedowse <iedowse@FreeBSD.org> | 2001-05-16 18:04:37 +0000 |
commit | dafd513732df8c8fa7b8c5069ae3af2203853494 (patch) | |
tree | 57e0aeed936a6069b4a1048d66e40c879871f601 /sys/nfs | |
parent | 7faffe08a53e9fd2e664451fb6634f6377a33a46 (diff) | |
download | FreeBSD-src-dafd513732df8c8fa7b8c5069ae3af2203853494.zip FreeBSD-src-dafd513732df8c8fa7b8c5069ae3af2203853494.tar.gz |
Change the second argument of vflush() to an integer that specifies
the number of references on the filesystem root vnode to be both
expected and released. Many filesystems hold an extra reference on
the filesystem root vnode, which must be accounted for when
determining if the filesystem is busy and then released if it isn't
busy. The old `skipvp' approach required individual filesystem
xxx_unmount functions to re-implement much of vflush()'s logic to
deal with the root vnode.
All 9 filesystems that hold an extra reference on the root vnode
got the logic wrong in the case of forced unmounts, so `umount -f'
would always fail if there were any extra root vnode references.
Fix this issue centrally in vflush(), now that we can.
This commit also fixes a vnode reference leak in devfs, which could
result in idle devfs filesystems that refuse to unmount.
Reviewed by: phk, bp
Diffstat (limited to 'sys/nfs')
-rw-r--r-- | sys/nfs/nfs_vfsops.c | 32 |
1 files changed, 4 insertions, 28 deletions
diff --git a/sys/nfs/nfs_vfsops.c b/sys/nfs/nfs_vfsops.c index d5e8972..3c76ed5 100644 --- a/sys/nfs/nfs_vfsops.c +++ b/sys/nfs/nfs_vfsops.c @@ -953,8 +953,6 @@ nfs_unmount(mp, mntflags, p) struct proc *p; { register struct nfsmount *nmp; - struct nfsnode *np; - struct vnode *vp; int error, flags = 0; if (mntflags & MNT_FORCE) @@ -962,36 +960,20 @@ nfs_unmount(mp, mntflags, p) nmp = VFSTONFS(mp); /* * Goes something like this.. - * - Check for activity on the root vnode (other than ourselves). - * - Call vflush() to clear out vnodes for this file system, - * except for the root vnode. - * - Decrement reference on the vnode representing remote root. + * - Call vflush() to clear out vnodes for this file system * - Close the socket * - Free up the data structures */ /* - * We need to decrement the ref. count on the nfsnode representing - * the remote root. See comment in mountnfs(). The VFS unmount() - * has done vput on this vnode, otherwise we would get deadlock! - */ - error = nfs_nget(mp, (nfsfh_t *)nmp->nm_fh, nmp->nm_fhsize, &np); - if (error) - return(error); - vp = NFSTOV(np); - if (vp->v_usecount > 2) { - vput(vp); - return (EBUSY); - } - - /* * Must handshake with nqnfs_clientd() if it is active. */ nmp->nm_state |= NFSSTA_DISMINPROG; while (nmp->nm_inprog != NULLVP) (void) tsleep((caddr_t)&lbolt, PSOCK, "nfsdism", 0); - error = vflush(mp, vp, flags); + + /* We hold 1 extra ref on the root vnode; see comment in mountnfs(). */ + error = vflush(mp, 1, flags); if (error) { - vput(vp); nmp->nm_state &= ~NFSSTA_DISMINPROG; return (error); } @@ -1003,12 +985,6 @@ nfs_unmount(mp, mntflags, p) if (nmp->nm_flag & (NFSMNT_NQNFS | NFSMNT_KERB)) nmp->nm_state |= NFSSTA_DISMNT; - /* - * There are two reference counts and one lock to get rid of here. - */ - vput(vp); - vrele(vp); - vgone(vp); nfs_disconnect(nmp); FREE(nmp->nm_nam, M_SONAME); |