Module Name: src Committed By: hannken Date: Mon Apr 16 20:27:38 UTC 2018
Modified Files: src/sys/miscfs/procfs: procfs_subr.c Log Message: 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.111 -r1.112 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.111 src/sys/miscfs/procfs/procfs_subr.c:1.112 --- src/sys/miscfs/procfs/procfs_subr.c:1.111 Sun Dec 31 03:29:18 2017 +++ src/sys/miscfs/procfs/procfs_subr.c Mon Apr 16 20:27:38 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: procfs_subr.c,v 1.111 2017/12/31 03:29:18 christos Exp $ */ +/* $NetBSD: procfs_subr.c,v 1.112 2018/04/16 20:27:38 hannken 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.111 2017/12/31 03:29:18 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: procfs_subr.c,v 1.112 2018/04/16 20:27:38 hannken 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> @@ -368,6 +369,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; @@ -375,14 +378,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); }