Module Name:    src
Committed By:   ad
Date:           Thu Jan 23 19:28:39 UTC 2020

Modified Files:
        src/sys/kern [ad-namecache]: vfs_vnode.c

Log Message:
vcache_reclaim(): purge namecache immediately after setting vnode to
VS_RECLAIMED.


To generate a diff of this commit:
cvs rdiff -u -r1.105.2.3 -r1.105.2.4 src/sys/kern/vfs_vnode.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/kern/vfs_vnode.c
diff -u src/sys/kern/vfs_vnode.c:1.105.2.3 src/sys/kern/vfs_vnode.c:1.105.2.4
--- src/sys/kern/vfs_vnode.c:1.105.2.3	Fri Jan 17 21:55:13 2020
+++ src/sys/kern/vfs_vnode.c	Thu Jan 23 19:28:39 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_vnode.c,v 1.105.2.3 2020/01/17 21:55:13 ad Exp $	*/
+/*	$NetBSD: vfs_vnode.c,v 1.105.2.4 2020/01/23 19:28:39 ad Exp $	*/
 
 /*-
  * Copyright (c) 1997-2011, 2019 The NetBSD Foundation, Inc.
@@ -145,7 +145,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.105.2.3 2020/01/17 21:55:13 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.105.2.4 2020/01/23 19:28:39 ad Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -1582,6 +1582,13 @@ vcache_reclaim(vnode_t *vp)
 	vp->v_iflag &= ~(VI_TEXT|VI_EXECMAP);
 	mutex_exit(vp->v_interlock);
 
+	/*
+	 * With vnode state set to reclaiming, purge name cache immediately
+	 * to prevent new handles on vnode, and wait for existing threads
+	 * trying to get a handle to notice VS_RECLAIMED status and abort.
+	 */
+	cache_purge(vp);
+
 	/* Replace the vnode key with a temporary copy. */
 	if (vip->vi_key.vk_key_len > sizeof(temp_buf)) {
 		temp_key = kmem_alloc(temp_key_len, KM_SLEEP);
@@ -1635,9 +1642,6 @@ vcache_reclaim(vnode_t *vp)
 		vp->v_ractx = NULL;
 	}
 
-	/* Purge name cache. */
-	cache_purge(vp);
-
 	if (vip->vi_key.vk_key_len > 0) {
 	/* Remove from vnode cache. */
 		hash = vcache_hash(&vip->vi_key);

Reply via email to