Source-Changes-HG archive

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

[src/trunk]: src/sys/kern Suspend file system while revoking a vnode. This w...



details:   https://anonhg.NetBSD.org/src/rev/e04f82f2d72d
branches:  trunk
changeset: 823982:e04f82f2d72d
user:      hannken <hannken%NetBSD.org@localhost>
date:      Wed May 17 12:46:14 2017 +0000

description:
Suspend file system while revoking a vnode.  This way no operations run
on the mounted file system during revoke and all operations see
the state before or after the revoke.

diffstat:

 sys/kern/vfs_vnode.c |  33 +++++++++++++++++++++++++--------
 1 files changed, 25 insertions(+), 8 deletions(-)

diffs (73 lines):

diff -r 1a3ebe26565f -r e04f82f2d72d sys/kern/vfs_vnode.c
--- a/sys/kern/vfs_vnode.c      Wed May 17 12:45:03 2017 +0000
+++ b/sys/kern/vfs_vnode.c      Wed May 17 12:46:14 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_vnode.c,v 1.87 2017/04/17 08:32:01 hannken Exp $   */
+/*     $NetBSD: vfs_vnode.c,v 1.88 2017/05/17 12:46:14 hannken 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.87 2017/04/17 08:32:01 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.88 2017/05/17 12:46:14 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -950,31 +950,48 @@
 void
 vrevoke(vnode_t *vp)
 {
+       int error;
+       struct mount *mp;
        vnode_t *vq;
        enum vtype type;
        dev_t dev;
 
        KASSERT(vp->v_usecount > 0);
 
+       mp = vp->v_mount;
+       error = vfs_suspend(mp, 0);
+       KASSERT(error == 0 || error == EOPNOTSUPP);
+       if (error)
+               mp = NULL;
+
        mutex_enter(vp->v_interlock);
        VSTATE_WAIT_STABLE(vp);
        if (VSTATE_GET(vp) == VS_RECLAIMED) {
                mutex_exit(vp->v_interlock);
-               return;
        } else if (vp->v_type != VBLK && vp->v_type != VCHR) {
                atomic_inc_uint(&vp->v_usecount);
                mutex_exit(vp->v_interlock);
                vgone(vp);
-               return;
        } else {
                dev = vp->v_rdev;
                type = vp->v_type;
                mutex_exit(vp->v_interlock);
+
+               while (spec_node_lookup_by_dev(type, dev, &vq) == 0) {
+                       if (mp != vq->v_mount) {
+                               if (mp)
+                                       vfs_resume(mp);
+                               mp = vp->v_mount;
+                               error = vfs_suspend(mp, 0);
+                               KASSERT(error == 0 || error == EOPNOTSUPP);
+                               if (error)
+                                       mp = NULL;
+                       }
+                       vgone(vq);
+               }
        }
-
-       while (spec_node_lookup_by_dev(type, dev, &vq) == 0) {
-               vgone(vq);
-       }
+       if (mp)
+               vfs_resume(mp);
 }
 
 /*



Home | Main Index | Thread Index | Old Index