Index: sys/kern/vfs_vnode.c =================================================================== RCS file: /cvsroot/src/sys/kern/vfs_vnode.c,v retrieving revision 1.30 diff -p -u -4 -r1.30 vfs_vnode.c --- sys/kern/vfs_vnode.c 7 Dec 2013 10:03:28 -0000 1.30 +++ sys/kern/vfs_vnode.c 23 Feb 2014 12:37:21 -0000 @@ -149,8 +149,9 @@ __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 * references and one for those which do (i.e. v_holdcnt is non-zero). @@ -177,8 +178,9 @@ static void vnpanic(vnode_t *, const ch __printflike(2, 3); /* 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) { @@ -187,8 +189,12 @@ vfs_vnode_sysinit(void) vnode_cache = pool_cache_init(sizeof(vnode_t), 0, 0, 0, "vnodepl", 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); TAILQ_INIT(&vrele_list); @@ -998,14 +1004,12 @@ 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); if (doclose) { Index: sys/sys/mount.h =================================================================== RCS file: /cvsroot/src/sys/sys/mount.h,v retrieving revision 1.210 diff -p -u -4 -r1.210 mount.h --- sys/sys/mount.h 23 Nov 2013 13:35:36 -0000 1.210 +++ sys/sys/mount.h 23 Feb 2014 12:37:22 -0000 @@ -409,9 +409,8 @@ int vfs_detach(struct vfsops *); 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 *); void vfs_insmntque(struct vnode *, struct mount *); Index: sys/kern/vfs_mount.c =================================================================== RCS file: /cvsroot/src/sys/kern/vfs_mount.c,v retrieving revision 1.25 diff -p -u -4 -r1.25 vfs_mount.c --- sys/kern/vfs_mount.c 27 Nov 2013 17:25:46 -0000 1.25 +++ sys/kern/vfs_mount.c 23 Feb 2014 12:37:20 -0000 @@ -524,33 +524,8 @@ vflush(struct mount *mp, vnode_t *skipvp return (0); } /* - * 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. */ /* @@ -828,9 +803,8 @@ dounmount(struct mount *mp, int flags, s error = 0; 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); } if (error) { @@ -844,9 +818,8 @@ dounmount(struct mount *mp, int flags, s mutex_exit(&syncer_mutex); return (error); } mutex_exit(&mp->mnt_updating); - vfs_scrubvnlist(mp); /* * release mnt_umounting lock here, because other code calls * vfs_busy() while holding the mountlist_lock. Index: sys/kern/vfs_subr.c =================================================================== RCS file: /cvsroot/src/sys/kern/vfs_subr.c,v retrieving revision 1.441 diff -p -u -4 -r1.441 vfs_subr.c --- sys/kern/vfs_subr.c 27 Nov 2013 17:24:44 -0000 1.441 +++ sys/kern/vfs_subr.c 23 Feb 2014 12:37:20 -0000 @@ -130,10 +130,10 @@ void vntblinit(void) { vn_initialize_syncerd(); - vfs_vnode_sysinit(); vfs_mount_sysinit(); + vfs_vnode_sysinit(); } /* * Flush out and invalidate all buffers associated with a vnode. Index: sys/miscfs/deadfs/dead_vnops.c =================================================================== RCS file: /cvsroot/src/sys/miscfs/deadfs/dead_vnops.c,v retrieving revision 1.54 diff -p -u -4 -r1.54 dead_vnops.c --- sys/miscfs/deadfs/dead_vnops.c 7 Feb 2014 15:29:22 -0000 1.54 +++ sys/miscfs/deadfs/dead_vnops.c 23 Feb 2014 12:37:21 -0000 @@ -145,9 +145,9 @@ dead_lookup(void *v) } */ *ap = v; *(ap->a_vpp) = NULL; - return EIO; + return ENOENT; } /* ARGSUSED */ int --- /dev/null 2014-02-23 11:07:09.000000000 +0100 +++ dead_vfsops.c 2014-02-23 10:31:09.000000000 +0100 @@ -0,0 +1,80 @@ +/* $NetBSD: $ */ + +/*- + * 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 +__KERNEL_RCSID(0, "$NetBSD: $"); + +#include +#include +#include +#include + +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 } +}; Index: sys/conf/files =================================================================== RCS file: /cvsroot/src/sys/conf/files,v retrieving revision 1.1082 diff -p -u -4 -r1.1082 files --- sys/conf/files 9 Dec 2013 16:45:23 -0000 1.1082 +++ sys/conf/files 23 Feb 2014 12:37:17 -0000 @@ -1647,8 +1647,9 @@ file kern/vfs_vnode.c 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 file miscfs/genfs/genfs_rename.c Index: sys/rump/librump/rumpvfs/Makefile.rumpvfs =================================================================== RCS file: /cvsroot/src/sys/rump/librump/rumpvfs/Makefile.rumpvfs,v retrieving revision 1.39 diff -p -u -4 -r1.39 Makefile.rumpvfs --- sys/rump/librump/rumpvfs/Makefile.rumpvfs 9 Dec 2013 20:44:00 -0000 1.39 +++ sys/rump/librump/rumpvfs/Makefile.rumpvfs 23 Feb 2014 12:37:22 -0000 @@ -40,9 +40,9 @@ SRCS+= uvm_vnode.c # sys/miscfs/syncfs 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