Source-Changes-HG archive

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

[src/trunk]: src/sys Currently dead vnodes still reside on the vnodelist of t...



details:   https://anonhg.NetBSD.org/src/rev/c855e4b877a7
branches:  trunk
changeset: 327102:c855e4b877a7
user:      hannken <hannken%NetBSD.org@localhost>
date:      Thu Feb 27 13:00:06 2014 +0000

description:
Currently dead vnodes still reside on the vnodelist of the file system
they have been removed from.

Create a "dead mount" that takes dead vnodes until they get freed.

Discussed on tech-kern.

diffstat:

 sys/conf/files                            |   3 +-
 sys/kern/vfs_mount.c                      |  31 +-----------
 sys/kern/vfs_subr.c                       |   6 +-
 sys/kern/vfs_vnode.c                      |  20 ++++---
 sys/miscfs/deadfs/dead_vfsops.c           |  80 +++++++++++++++++++++++++++++++
 sys/miscfs/deadfs/dead_vnops.c            |   6 +-
 sys/rump/librump/rumpvfs/Makefile.rumpvfs |   4 +-
 sys/sys/mount.h                           |   3 +-
 8 files changed, 105 insertions(+), 48 deletions(-)

diffs (truncated from 319 to 300 lines):

diff -r ca49b2463e7b -r c855e4b877a7 sys/conf/files
--- a/sys/conf/files    Thu Feb 27 10:42:30 2014 +0000
+++ b/sys/conf/files    Thu Feb 27 13:00:06 2014 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files,v 1.1083 2014/02/21 07:32:43 matt Exp $
+#      $NetBSD: files,v 1.1084 2014/02/27 13:00:06 hannken Exp $
 #      @(#)files.newconf       7.5 (Berkeley) 5/10/93
 
 version        20100430
@@ -1649,6 +1649,7 @@
 file   kern/vfs_wapbl.c                wapbl
 file   kern/vfs_xattr.c
 file   kern/vnode_if.c
+file   miscfs/deadfs/dead_vfsops.c
 file   miscfs/deadfs/dead_vnops.c
 file   miscfs/fifofs/fifo_vnops.c
 file   miscfs/genfs/genfs_io.c
diff -r ca49b2463e7b -r c855e4b877a7 sys/kern/vfs_mount.c
--- a/sys/kern/vfs_mount.c      Thu Feb 27 10:42:30 2014 +0000
+++ b/sys/kern/vfs_mount.c      Thu Feb 27 13:00:06 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_mount.c,v 1.25 2013/11/27 17:25:46 christos Exp $  */
+/*     $NetBSD: vfs_mount.c,v 1.26 2014/02/27 13:00:06 hannken Exp $   */
 
 /*-
  * Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.25 2013/11/27 17:25:46 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.26 2014/02/27 13:00:06 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -525,31 +525,6 @@
 }
 
 /*
- * Remove clean vnodes from a mountpoint's vnode list.
- */
-void
-vfs_scrubvnlist(struct mount *mp)
-{
-       vnode_t *vp, *nvp;
-
-retry:
-       mutex_enter(&mntvnode_lock);
-       TAILQ_FOREACH_SAFE(vp, &mp->mnt_vnodelist, v_mntvnodes, nvp) {
-               mutex_enter(vp->v_interlock);
-               if ((vp->v_iflag & VI_CLEAN) != 0) {
-                       TAILQ_REMOVE(&mp->mnt_vnodelist, vp, v_mntvnodes);
-                       vp->v_mount = NULL;
-                       mutex_exit(&mntvnode_lock);
-                       mutex_exit(vp->v_interlock);
-                       vfs_destroy(mp);
-                       goto retry;
-               }
-               mutex_exit(vp->v_interlock);
-       }
-       mutex_exit(&mntvnode_lock);
-}
-
-/*
  * Mount a file system.
  */
 
@@ -829,7 +804,6 @@
        if ((mp->mnt_flag & MNT_RDONLY) == 0) {
                error = VFS_SYNC(mp, MNT_WAIT, l->l_cred);
        }
-       vfs_scrubvnlist(mp);
        if (error == 0 || (flags & MNT_FORCE)) {
                error = VFS_UNMOUNT(mp, flags);
        }
@@ -845,7 +819,6 @@
                return (error);
        }
        mutex_exit(&mp->mnt_updating);
-       vfs_scrubvnlist(mp);
 
        /*
         * release mnt_umounting lock here, because other code calls
diff -r ca49b2463e7b -r c855e4b877a7 sys/kern/vfs_subr.c
--- a/sys/kern/vfs_subr.c       Thu Feb 27 10:42:30 2014 +0000
+++ b/sys/kern/vfs_subr.c       Thu Feb 27 13:00:06 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_subr.c,v 1.441 2013/11/27 17:24:44 christos Exp $  */
+/*     $NetBSD: vfs_subr.c,v 1.442 2014/02/27 13:00:06 hannken Exp $   */
 
 /*-
  * Copyright (c) 1997, 1998, 2004, 2005, 2007, 2008 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.441 2013/11/27 17:24:44 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.442 2014/02/27 13:00:06 hannken Exp $");
 
 #include "opt_ddb.h"
 #include "opt_compat_netbsd.h"
@@ -131,8 +131,8 @@
 {
 
        vn_initialize_syncerd();
+       vfs_mount_sysinit();
        vfs_vnode_sysinit();
-       vfs_mount_sysinit();
 }
 
 /*
diff -r ca49b2463e7b -r c855e4b877a7 sys/kern/vfs_vnode.c
--- a/sys/kern/vfs_vnode.c      Thu Feb 27 10:42:30 2014 +0000
+++ b/sys/kern/vfs_vnode.c      Thu Feb 27 13:00:06 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_vnode.c,v 1.30 2013/12/07 10:03:28 hannken Exp $   */
+/*     $NetBSD: vfs_vnode.c,v 1.31 2014/02/27 13:00:06 hannken Exp $   */
 
 /*-
  * Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
@@ -116,7 +116,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.30 2013/12/07 10:03:28 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.31 2014/02/27 13:00:06 hannken Exp $");
 
 #define _VFS_VNODE_PRIVATE
 
@@ -150,6 +150,7 @@
 u_int                  numvnodes               __cacheline_aligned;
 
 static pool_cache_t    vnode_cache             __read_mostly;
+static struct mount    *dead_mount;
 
 /*
  * There are two free lists: one is for vnodes which have no buffer/page
@@ -178,6 +179,7 @@
 
 /* Routines having to do with the management of the vnode table. */
 extern int             (**dead_vnodeop_p)(void *);
+extern struct vfsops   dead_vfsops;
 
 void
 vfs_vnode_sysinit(void)
@@ -188,6 +190,10 @@
            NULL, IPL_NONE, NULL, NULL, NULL);
        KASSERT(vnode_cache != NULL);
 
+       dead_mount = vfs_mountalloc(&dead_vfsops, NULL);
+       KASSERT(dead_mount != NULL);
+       dead_mount->mnt_iflag = IMNT_MPSAFE;
+
        mutex_init(&vnode_free_list_lock, MUTEX_DEFAULT, IPL_NONE);
        TAILQ_INIT(&vnode_free_list);
        TAILQ_INIT(&vnode_hold_list);
@@ -999,12 +1005,10 @@
        /* Purge name cache. */
        cache_purge(vp);
 
-       /*
-        * The vnode isn't clean, but still resides on the mount list.  Remove
-        * it. XXX This is a bit dodgy.
-        */
-       if (! doclose)
-               vfs_insmntque(vp, NULL);
+       /* Move to dead mount. */
+       vp->v_vflag &= ~VV_ROOT;
+       atomic_inc_uint(&dead_mount->mnt_refcnt);
+       vfs_insmntque(vp, dead_mount);
 
        /* Done with purge, notify sleepers of the grim news. */
        mutex_enter(vp->v_interlock);
diff -r ca49b2463e7b -r c855e4b877a7 sys/miscfs/deadfs/dead_vfsops.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/miscfs/deadfs/dead_vfsops.c   Thu Feb 27 13:00:06 2014 +0000
@@ -0,0 +1,80 @@
+/*     $NetBSD: dead_vfsops.c,v 1.1 2014/02/27 13:00:06 hannken Exp $  */
+
+/*-
+ * Copyright (c) 2014 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Juergen Hannken-Illjes.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: dead_vfsops.c,v 1.1 2014/02/27 13:00:06 hannken Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/vnode.h>
+#include <sys/mount.h>
+
+extern const struct vnodeopv_desc dead_vnodeop_opv_desc;
+
+static const struct vnodeopv_desc * const dead_vnodeopv_descs[] = {
+       &dead_vnodeop_opv_desc,
+       NULL
+};
+
+static void
+dead_panic(void)
+{
+
+       panic("dead fs operation used");
+}
+
+struct vfsops dead_vfsops = {
+       "dead",
+       0,
+       (void *)dead_panic,                     /* vfs_mount */
+       (void *)dead_panic,                     /* vfs_start */
+       (void *)dead_panic,                     /* vfs_unmount */
+       (void *)dead_panic,                     /* vfs_root */
+       (void *)dead_panic,                     /* vfs_quotactl */
+       (void *)dead_panic,                     /* vfs_statvfs */
+       (void *)dead_panic,                     /* vfs_sync */
+       (void *)dead_panic,                     /* vfs_vget */
+       (void *)dead_panic,                     /* vfs_fhtovp */
+       (void *)dead_panic,                     /* vfs_vptofh */
+       (void *)dead_panic,                     /* vfs_init */
+       (void *)dead_panic,                     /* vfs_reinit */
+       (void *)dead_panic,                     /* vfs_done */
+       (void *)dead_panic,                     /* vfs_mountroot */
+       (void *)dead_panic,                     /* vfs_snapshot */
+       (void *)dead_panic,                     /* vfs_extattrctl */
+       (void *)dead_panic,                     /* vfs_suspendctl */
+       (void *)dead_panic,                     /* vfs_renamelock_enter */
+       (void *)dead_panic,                     /* vfs_renamelock_exit */
+       (void *)eopnotsupp,                     /* vfs_fsync */
+       dead_vnodeopv_descs,
+       0,
+       { NULL, NULL }
+};
diff -r ca49b2463e7b -r c855e4b877a7 sys/miscfs/deadfs/dead_vnops.c
--- a/sys/miscfs/deadfs/dead_vnops.c    Thu Feb 27 10:42:30 2014 +0000
+++ b/sys/miscfs/deadfs/dead_vnops.c    Thu Feb 27 13:00:06 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dead_vnops.c,v 1.54 2014/02/07 15:29:22 hannken Exp $  */
+/*     $NetBSD: dead_vnops.c,v 1.55 2014/02/27 13:00:06 hannken Exp $  */
 
 /*
  * Copyright (c) 1989, 1993
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dead_vnops.c,v 1.54 2014/02/07 15:29:22 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dead_vnops.c,v 1.55 2014/02/27 13:00:06 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -146,7 +146,7 @@
 
        *(ap->a_vpp) = NULL;
 
-       return EIO;
+       return ENOENT;
 }
 
 /* ARGSUSED */
diff -r ca49b2463e7b -r c855e4b877a7 sys/rump/librump/rumpvfs/Makefile.rumpvfs
--- a/sys/rump/librump/rumpvfs/Makefile.rumpvfs Thu Feb 27 10:42:30 2014 +0000
+++ b/sys/rump/librump/rumpvfs/Makefile.rumpvfs Thu Feb 27 13:00:06 2014 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.rumpvfs,v 1.39 2013/12/09 20:44:00 pooka Exp $
+#      $NetBSD: Makefile.rumpvfs,v 1.40 2014/02/27 13:00:06 hannken Exp $
 #
 
 .include "${RUMPTOP}/Makefile.rump"
@@ -41,7 +41,7 @@
 SRCS+= sync_subr.c sync_vnops.c
 
 # sys/miscfs/deadfs
-SRCS+= dead_vnops.c
+SRCS+= dead_vfsops.c dead_vnops.c
 



Home | Main Index | Thread Index | Old Index