Module Name:    src
Committed By:   hannken
Date:           Mon Nov 21 09:08:00 UTC 2011

Modified Files:
        src/sys/nfs: nfs_serv.c

Log Message:
nfsrv_lookup(): Defer the postopattr lookup on dirp until the
                child node is unlocked.

Ok: YAMAMOTO Takashi <y...@netbsd.org>


To generate a diff of this commit:
cvs rdiff -u -r1.161 -r1.162 src/sys/nfs/nfs_serv.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/nfs/nfs_serv.c
diff -u src/sys/nfs/nfs_serv.c:1.161 src/sys/nfs/nfs_serv.c:1.162
--- src/sys/nfs/nfs_serv.c:1.161	Sun Oct 30 12:00:27 2011
+++ src/sys/nfs/nfs_serv.c	Mon Nov 21 09:07:59 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_serv.c,v 1.161 2011/10/30 12:00:27 hannken Exp $	*/
+/*	$NetBSD: nfs_serv.c,v 1.162 2011/11/21 09:07:59 hannken Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -55,7 +55,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.161 2011/10/30 12:00:27 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.162 2011/11/21 09:07:59 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -453,15 +453,6 @@ nfsrv_lookup(struct nfsrv_descript *nfsd
 		}
 	}
 
-	if (dirp) {
-		if (v3) {
-			vn_lock(dirp, LK_SHARED | LK_RETRY);
-			dirattr_ret = VOP_GETATTR(dirp, &dirattr, cred);
-			VOP_UNLOCK(dirp);
-		}
-		vrele(dirp);
-	}
-
 	if (error) {
 		if (nd.ni_pathbuf != NULL) {
 			pathbuf_destroy(nd.ni_pathbuf);
@@ -469,6 +460,14 @@ nfsrv_lookup(struct nfsrv_descript *nfsd
 		if (ipb != NULL) {
 			pathbuf_destroy(ipb);
 		}
+		if (dirp) {
+			if (v3) {
+				vn_lock(dirp, LK_SHARED | LK_RETRY);
+				dirattr_ret = VOP_GETATTR(dirp, &dirattr, cred);
+				vput(dirp);
+			} else
+				vrele(dirp);
+		}
 		nfsm_reply(NFSX_POSTOPATTR(v3));
 		nfsm_srvpostop_attr(dirattr_ret, &dirattr);
 		return (0);
@@ -484,6 +483,14 @@ nfsrv_lookup(struct nfsrv_descript *nfsd
 	if (!error)
 		error = VOP_GETATTR(vp, &va, cred);
 	vput(vp);
+	if (dirp) {
+		if (v3) {
+			vn_lock(dirp, LK_SHARED | LK_RETRY);
+			dirattr_ret = VOP_GETATTR(dirp, &dirattr, cred);
+			vput(dirp);
+		} else
+			vrele(dirp);
+	}
 	nfsm_reply(NFSX_SRVFH(&nsfh, v3) + NFSX_POSTOPORFATTR(v3) +
 	    NFSX_POSTOPATTR(v3));
 	if (error) {

Reply via email to