From d6ec8427bc1172b3f41aafa2858d09446634abb4 Mon Sep 17 00:00:00 2001 From: Rick Macklem Date: Fri, 17 Dec 2010 22:18:09 +0000 Subject: [PATCH] Fix two vnode locking problems in nfsd_recalldelegation() in the experimental NFSv4 server. The first was a bogus use of VOP_ISLOCKED() in a KASSERT() and the second was the need to lock the vnode for the nfsrv_checkremove() call. Also, delete a "__unused" that was bogus, since the argument is used. Reviewed by: zack.kirsch at isilon.com MFC after: 2 weeks --- sys/fs/nfsserver/nfs_nfsdstate.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sys/fs/nfsserver/nfs_nfsdstate.c b/sys/fs/nfsserver/nfs_nfsdstate.c index 9f657d6948d4..9775644e864e 100644 --- a/sys/fs/nfsserver/nfs_nfsdstate.c +++ b/sys/fs/nfsserver/nfs_nfsdstate.c @@ -4275,7 +4275,7 @@ nfsrv_clientconflict(struct nfsclient *clp, int *haslockp, __unused vnode_t vp, */ static int nfsrv_delegconflict(struct nfsstate *stp, int *haslockp, NFSPROC_T *p, - __unused vnode_t vp) + vnode_t vp) { struct nfsclient *clp = stp->ls_clp; int gotlock, error, retrycnt, zapped_clp; @@ -4568,8 +4568,6 @@ nfsd_recalldelegation(vnode_t vp, NFSPROC_T *p) int32_t starttime; int error; - KASSERT(!VOP_ISLOCKED(vp), ("vp %p is locked", vp)); - /* * First, check to see if the server is currently running and it has * been called for a regular file when issuing delegations. @@ -4578,6 +4576,7 @@ nfsd_recalldelegation(vnode_t vp, NFSPROC_T *p) nfsrv_issuedelegs == 0) return; + KASSERT((VOP_ISLOCKED(vp) != LK_EXCLUSIVE), ("vp %p is locked", vp)); /* * First, get a reference on the nfsv4rootfs_lock so that an * exclusive lock cannot be acquired by another thread. @@ -4593,7 +4592,12 @@ nfsd_recalldelegation(vnode_t vp, NFSPROC_T *p) NFSGETNANOTIME(&mytime); starttime = (u_int32_t)mytime.tv_sec; do { - error = nfsrv_checkremove(vp, 0, p); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); + if ((vp->v_iflag & VI_DOOMED) == 0) + error = nfsrv_checkremove(vp, 0, p); + else + error = EPERM; + VOP_UNLOCK(vp, 0); if (error == NFSERR_DELAY) { NFSGETNANOTIME(&mytime); if (((u_int32_t)mytime.tv_sec - starttime) >