Module Name:    src
Committed By:   martin
Date:           Tue Apr 17 08:36:11 UTC 2018

Modified Files:
        src/sys/miscfs/procfs [netbsd-8]: procfs_subr.c

Log Message:
Pull up following revision(s) (requested by hannken in ticket #772):

        sys/miscfs/procfs/procfs_subr.c: revision 1.112

Change procfs_revoke_vnodes() to use vrecycle()/vgone() instead
of VOP_REVOKE().

Gets rid of a bunch of suspensions on /proc as vrecycle() will
succeed most time and we suspend at most once per call.


To generate a diff of this commit:
cvs rdiff -u -r1.108.6.1 -r1.108.6.2 src/sys/miscfs/procfs/procfs_subr.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/miscfs/procfs/procfs_subr.c
diff -u src/sys/miscfs/procfs/procfs_subr.c:1.108.6.1 src/sys/miscfs/procfs/procfs_subr.c:1.108.6.2
--- src/sys/miscfs/procfs/procfs_subr.c:1.108.6.1	Thu Apr 12 13:42:48 2018
+++ src/sys/miscfs/procfs/procfs_subr.c	Tue Apr 17 08:36:11 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_subr.c,v 1.108.6.1 2018/04/12 13:42:48 martin Exp $	*/
+/*	$NetBSD: procfs_subr.c,v 1.108.6.2 2018/04/17 08:36:11 martin Exp $	*/
 
 /*-
  * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -102,13 +102,14 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: procfs_subr.c,v 1.108.6.1 2018/04/12 13:42:48 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_subr.c,v 1.108.6.2 2018/04/17 08:36:11 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/time.h>
 #include <sys/kernel.h>
 #include <sys/proc.h>
+#include <sys/fstrans.h>
 #include <sys/vnode.h>
 #include <sys/stat.h>
 #include <sys/file.h>
@@ -363,6 +364,8 @@ procfs_revoke_selector(void *arg, struct
 void
 procfs_revoke_vnodes(struct proc *p, void *arg)
 {
+	int error;
+	bool suspended;
 	struct vnode *vp;
 	struct vnode_iterator *marker;
 	struct mount *mp = (struct mount *)arg;
@@ -370,14 +373,29 @@ procfs_revoke_vnodes(struct proc *p, voi
 	if (!(p->p_flag & PK_SUGID))
 		return;
 
+	suspended = false;
 	vfs_vnode_iterator_init(mp, &marker);
 
 	while ((vp = vfs_vnode_iterator_next(marker,
 	    procfs_revoke_selector, p)) != NULL) {
-		VOP_REVOKE(vp, REVOKEALL);
-		vrele(vp);
+		if (vrecycle(vp))
+			continue;
+		/* Vnode is busy, we have to suspend the mount for vgone(). */
+		while (! suspended) {
+			error = vfs_suspend(mp, 0);
+			if (error == 0) {
+				suspended = true;
+			} else if (error != EINTR && error != ERESTART) {
+				KASSERT(error == EOPNOTSUPP);
+				break;
+			}
+		}
+		vgone(vp);
 	}
 
+	if (suspended)
+		vfs_resume(mp);
+
 	vfs_vnode_iterator_destroy(marker);
 }
 

Reply via email to