Module Name: src
Committed By: hannken
Date: Thu Feb 27 13:00:06 UTC 2014
Modified Files:
src/sys/conf: files
src/sys/kern: vfs_mount.c vfs_subr.c vfs_vnode.c
src/sys/miscfs/deadfs: dead_vnops.c
src/sys/rump/librump/rumpvfs: Makefile.rumpvfs
src/sys/sys: mount.h
Added Files:
src/sys/miscfs/deadfs: dead_vfsops.c
Log Message:
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.
To generate a diff of this commit:
cvs rdiff -u -r1.1083 -r1.1084 src/sys/conf/files
cvs rdiff -u -r1.25 -r1.26 src/sys/kern/vfs_mount.c
cvs rdiff -u -r1.441 -r1.442 src/sys/kern/vfs_subr.c
cvs rdiff -u -r1.30 -r1.31 src/sys/kern/vfs_vnode.c
cvs rdiff -u -r0 -r1.1 src/sys/miscfs/deadfs/dead_vfsops.c
cvs rdiff -u -r1.54 -r1.55 src/sys/miscfs/deadfs/dead_vnops.c
cvs rdiff -u -r1.39 -r1.40 src/sys/rump/librump/rumpvfs/Makefile.rumpvfs
cvs rdiff -u -r1.210 -r1.211 src/sys/sys/mount.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/conf/files
diff -u src/sys/conf/files:1.1083 src/sys/conf/files:1.1084
--- src/sys/conf/files:1.1083 Fri Feb 21 07:32:43 2014
+++ src/sys/conf/files Thu Feb 27 13:00:06 2014
@@ -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_vnops.c
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
Index: src/sys/kern/vfs_mount.c
diff -u src/sys/kern/vfs_mount.c:1.25 src/sys/kern/vfs_mount.c:1.26
--- src/sys/kern/vfs_mount.c:1.25 Wed Nov 27 17:25:46 2013
+++ src/sys/kern/vfs_mount.c Thu Feb 27 13:00:06 2014
@@ -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 @@ vflush(struct mount *mp, vnode_t *skipvp
}
/*
- * 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 @@ dounmount(struct mount *mp, int flags, s
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 @@ dounmount(struct mount *mp, int flags, s
return (error);
}
mutex_exit(&mp->mnt_updating);
- vfs_scrubvnlist(mp);
/*
* release mnt_umounting lock here, because other code calls
Index: src/sys/kern/vfs_subr.c
diff -u src/sys/kern/vfs_subr.c:1.441 src/sys/kern/vfs_subr.c:1.442
--- src/sys/kern/vfs_subr.c:1.441 Wed Nov 27 17:24:44 2013
+++ src/sys/kern/vfs_subr.c Thu Feb 27 13:00:06 2014
@@ -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 @@ vntblinit(void)
{
vn_initialize_syncerd();
- vfs_vnode_sysinit();
vfs_mount_sysinit();
+ vfs_vnode_sysinit();
}
/*
Index: src/sys/kern/vfs_vnode.c
diff -u src/sys/kern/vfs_vnode.c:1.30 src/sys/kern/vfs_vnode.c:1.31
--- src/sys/kern/vfs_vnode.c:1.30 Sat Dec 7 10:03:28 2013
+++ src/sys/kern/vfs_vnode.c Thu Feb 27 13:00:06 2014
@@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,
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 @@ static void vnpanic(vnode_t *, const ch
/* 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 @@ vfs_vnode_sysinit(void)
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 @@ vclean(vnode_t *vp)
/* 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);
Index: src/sys/miscfs/deadfs/dead_vnops.c
diff -u src/sys/miscfs/deadfs/dead_vnops.c:1.54 src/sys/miscfs/deadfs/dead_vnops.c:1.55
--- src/sys/miscfs/deadfs/dead_vnops.c:1.54 Fri Feb 7 15:29:22 2014
+++ src/sys/miscfs/deadfs/dead_vnops.c Thu Feb 27 13:00:06 2014
@@ -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 @@ dead_lookup(void *v)
*(ap->a_vpp) = NULL;
- return EIO;
+ return ENOENT;
}
/* ARGSUSED */
Index: src/sys/rump/librump/rumpvfs/Makefile.rumpvfs
diff -u src/sys/rump/librump/rumpvfs/Makefile.rumpvfs:1.39 src/sys/rump/librump/rumpvfs/Makefile.rumpvfs:1.40
--- src/sys/rump/librump/rumpvfs/Makefile.rumpvfs:1.39 Mon Dec 9 20:44:00 2013
+++ src/sys/rump/librump/rumpvfs/Makefile.rumpvfs Thu Feb 27 13:00:06 2014
@@ -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+= uvm_vnode.c
SRCS+= sync_subr.c sync_vnops.c
# sys/miscfs/deadfs
-SRCS+= dead_vnops.c
+SRCS+= dead_vfsops.c dead_vnops.c
# sys/miscfs
SRCS+= genfs_io.c genfs_rename.c genfs_vfsops.c genfs_vnops.c spec_vnops.c
Index: src/sys/sys/mount.h
diff -u src/sys/sys/mount.h:1.210 src/sys/sys/mount.h:1.211
--- src/sys/sys/mount.h:1.210 Sat Nov 23 13:35:36 2013
+++ src/sys/sys/mount.h Thu Feb 27 13:00:06 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: mount.h,v 1.210 2013/11/23 13:35:36 christos Exp $ */
+/* $NetBSD: mount.h,v 1.211 2014/02/27 13:00:06 hannken Exp $ */
/*
* Copyright (c) 1989, 1991, 1993
@@ -410,7 +410,6 @@ void vfs_reinit(void);
struct vfsops *vfs_getopsbyname(const char *);
void vfs_delref(struct vfsops *);
void vfs_destroy(struct mount *);
-void vfs_scrubvnlist(struct mount *);
struct mount *vfs_mountalloc(struct vfsops *, struct vnode *);
int vfs_stdextattrctl(struct mount *, int, struct vnode *,
int, const char *);
Added files:
Index: src/sys/miscfs/deadfs/dead_vfsops.c
diff -u /dev/null src/sys/miscfs/deadfs/dead_vfsops.c:1.1
--- /dev/null Thu Feb 27 13:00:06 2014
+++ src/sys/miscfs/deadfs/dead_vfsops.c Thu Feb 27 13:00:06 2014
@@ -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 }
+};