Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

src: Change procfs_revoke_vnodes() to use vrecycle()/vgone() ins...



details:   https://anonhg.NetBSD.org/src/rev/ae1c13baf7e2
branches:  trunk
changeset: 318256:ae1c13baf7e2
user:      hannken <hannken%NetBSD.org@localhost>
date:      Mon Apr 16 20:27:38 2018 +0000
description:
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.

diffstat:

 sys/miscfs/procfs/procfs_subr.c |  26 ++++++++++++++++++++++----
 1 files changed, 22 insertions(+), 4 deletions(-)

diffs (66 lines):

diff -r cffd77cdd659 -r ae1c13baf7e2 sys/miscfs/procfs/procfs_subr.c
--- a/sys/miscfs/procfs/procfs_subr.c   Mon Apr 16 20:25:21 2018 +0000
+++ b/sys/miscfs/procfs/procfs_subr.c   Mon Apr 16 20:27:38 2018 +0000
@@ -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 @@
 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 @@
        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);
 }
 



Home | Main Index | Thread Index | Old Index