Module Name:    src
Committed By:   riastradh
Date:           Sat Apr 15 23:16:53 UTC 2017

Modified Files:
        src/sys/kern: vfs_vnode.c vnode_if.src

Log Message:
Keep vnode locked during VOP_RECLAIM.

No bump because it wouldn't have been possible to acquire the lock in
VOP_RECLAIM anyway -- instant deadlock because vn_lock waits to
transition out of the RECLAIMING state first.  Benefit is that we can
now assert ownership of the lock in any operations called by
VOP_RECLAIM.

Discussed on tech-kern:

https://mail-index.netbsd.org/tech-kern/2017/04/01/msg021751.html


To generate a diff of this commit:
cvs rdiff -u -r1.83 -r1.84 src/sys/kern/vfs_vnode.c
cvs rdiff -u -r1.71 -r1.72 src/sys/kern/vnode_if.src

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

Modified files:

Index: src/sys/kern/vfs_vnode.c
diff -u src/sys/kern/vfs_vnode.c:1.83 src/sys/kern/vfs_vnode.c:1.84
--- src/sys/kern/vfs_vnode.c:1.83	Tue Apr 11 14:45:46 2017
+++ src/sys/kern/vfs_vnode.c	Sat Apr 15 23:16:53 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_vnode.c,v 1.83 2017/04/11 14:45:46 riastradh Exp $	*/
+/*	$NetBSD: vfs_vnode.c,v 1.84 2017/04/15 23:16:53 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
@@ -156,7 +156,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.83 2017/04/11 14:45:46 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.84 2017/04/15 23:16:53 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -1554,10 +1554,10 @@ vcache_reclaim(vnode_t *vp)
 	 * Note that the VOP_INACTIVE will not unlock the vnode.
 	 */
 	VOP_INACTIVE(vp, &recycle);
-	VOP_UNLOCK(vp);
 	if (VOP_RECLAIM(vp)) {
 		vnpanic(vp, "%s: cannot reclaim", __func__);
 	}
+	VOP_UNLOCK(vp);
 
 	KASSERT(vp->v_data == NULL);
 	KASSERT(vp->v_uobj.uo_npages == 0);

Index: src/sys/kern/vnode_if.src
diff -u src/sys/kern/vnode_if.src:1.71 src/sys/kern/vnode_if.src:1.72
--- src/sys/kern/vnode_if.src:1.71	Tue Apr 11 14:25:00 2017
+++ src/sys/kern/vnode_if.src	Sat Apr 15 23:16:53 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: vnode_if.src,v 1.71 2017/04/11 14:25:00 riastradh Exp $
+#	$NetBSD: vnode_if.src,v 1.72 2017/04/15 23:16:53 riastradh Exp $
 #
 # Copyright (c) 1992, 1993
 #	The Regents of the University of California.  All rights reserved.
@@ -393,11 +393,11 @@ vop_inactive {
 };
 
 #
-#% reclaim    vp      U U U
+#% reclaim    vp      L L L
 #
 vop_reclaim {
 	FSTRANS=NO
-	IN LOCKED=NO struct vnode *vp;
+	IN LOCKED=YES struct vnode *vp;
 };
 
 #

Reply via email to