From owner-svn-src-head@FreeBSD.ORG Mon Jan 3 00:33:33 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 23CC4106564A; Mon, 3 Jan 2011 00:33:33 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EC7038FC13; Mon, 3 Jan 2011 00:33:32 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p030XWif063412; Mon, 3 Jan 2011 00:33:32 GMT (envelope-from rmacklem@svn.freebsd.org) Received: (from rmacklem@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p030XWG9063409; Mon, 3 Jan 2011 00:33:32 GMT (envelope-from rmacklem@svn.freebsd.org) Message-Id: <201101030033.p030XWG9063409@svn.freebsd.org> From: Rick Macklem Date: Mon, 3 Jan 2011 00:33:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r216897 - head/sys/fs/nfsserver X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Jan 2011 00:33:33 -0000 Author: rmacklem Date: Mon Jan 3 00:33:32 2011 New Revision: 216897 URL: http://svn.freebsd.org/changeset/base/216897 Log: Modify the experimental NFSv4 server so that the lookup ops return a locked vnode. This ensures that the associated mount point will always be valid for the code that follows the operation. Also add a couple of additional checks for non-error to the other functions that create file objects. MFC after: 2 weeks Modified: head/sys/fs/nfsserver/nfs_nfsdserv.c head/sys/fs/nfsserver/nfs_nfsdsocket.c Modified: head/sys/fs/nfsserver/nfs_nfsdserv.c ============================================================================== --- head/sys/fs/nfsserver/nfs_nfsdserv.c Mon Jan 3 00:11:10 2011 (r216896) +++ head/sys/fs/nfsserver/nfs_nfsdserv.c Mon Jan 3 00:33:32 2011 (r216897) @@ -470,12 +470,10 @@ nfsrvd_lookup(struct nfsrv_descript *nd, nd->nd_repstat = nfsvno_getfh(vp, fhp, p); if (!(nd->nd_flag & ND_NFSV4) && !nd->nd_repstat) nd->nd_repstat = nfsvno_getattr(vp, &nva, nd->nd_cred, p, 1); - if (vpp) { - NFSVOPUNLOCK(vp, 0, p); + if (vpp != NULL && nd->nd_repstat == 0) *vpp = vp; - } else { + else vput(vp); - } if (dirp) { if (nd->nd_flag & ND_NFSV3) dattr_ret = nfsvno_getattr(dirp, &dattr, nd->nd_cred, @@ -1218,12 +1216,11 @@ nfsrvd_mknod(struct nfsrv_descript *nd, if ((nd->nd_flag & ND_NFSV3) && !nd->nd_repstat) nd->nd_repstat = nfsvno_getattr(vp, &nva, nd->nd_cred, p, 1); - if (vpp) { - NFSVOPUNLOCK(vp, 0, p); + if (vpp != NULL && nd->nd_repstat == 0) { + VOP_UNLOCK(vp, 0); *vpp = vp; - } else { + } else vput(vp); - } } diraft_ret = nfsvno_getattr(dirp, &diraft, nd->nd_cred, p, 0); @@ -1706,12 +1703,11 @@ nfsrvd_symlinksub(struct nfsrv_descript nd->nd_repstat = nfsvno_getattr(ndp->ni_vp, nvap, nd->nd_cred, p, 1); } - if (vpp) { - NFSVOPUNLOCK(ndp->ni_vp, 0, p); + if (vpp != NULL && nd->nd_repstat == 0) { + VOP_UNLOCK(ndp->ni_vp, 0); *vpp = ndp->ni_vp; - } else { + } else vput(ndp->ni_vp); - } } if (dirp) { *diraft_retp = nfsvno_getattr(dirp, diraftp, nd->nd_cred, p, 0); Modified: head/sys/fs/nfsserver/nfs_nfsdsocket.c ============================================================================== --- head/sys/fs/nfsserver/nfs_nfsdsocket.c Mon Jan 3 00:11:10 2011 (r216896) +++ head/sys/fs/nfsserver/nfs_nfsdsocket.c Mon Jan 3 00:33:32 2011 (r216897) @@ -861,10 +861,14 @@ nfsrvd_compound(struct nfsrv_descript *n nfsvno_lockvfs(mp); } } + if (op == NFSV4OP_LOOKUP || op == NFSV4OP_LOOKUPP) + /* Lookup ops return a locked vnode */ + VOP_UNLOCK(nvp, 0); if (!nd->nd_repstat) { vrele(vp); vp = nvp; - } + } else + vrele(nvp); } if (nfsv4_opflag[op].modifyfs) NFS_ENDWRITE(mp);