diff options
| author | hannken <hannken@NetBSD.org> | 2019-02-20 10:07:27 +0000 |
|---|---|---|
| committer | hannken <hannken@NetBSD.org> | 2019-02-20 10:07:27 +0000 |
| commit | 6e9babeafb4daee9b1e48bd176b97ff6cd7ef15e (patch) | |
| tree | 172b12a1bad7386f87a9ea7bbc63627183203bde /sys/kern | |
| parent | ca0c60e428c1d3a1d408761e3a455791464d1ebc (diff) | |
Attach "mnt_transinfo" to "dead_rootmount" so every mount has a
valid "mnt_transinfo" and remove now unneeded flag IMNT_HAS_TRANS.
Run fstrans_start()/fstrans_done() on dead_rootmount if FSTRANS_DEAD_ENABLED.
Should become the default for DIAGNOSTIC in the future.
Diffstat (limited to 'sys/kern')
| -rw-r--r-- | sys/kern/init_main.c | 9 | ||||
| -rw-r--r-- | sys/kern/vfs_mount.c | 12 | ||||
| -rw-r--r-- | sys/kern/vfs_trans.c | 41 | ||||
| -rw-r--r-- | sys/kern/vfs_vnode.c | 12 |
4 files changed, 42 insertions, 32 deletions
diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index 5aab68065ea..f9a1bf384b7 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -1,4 +1,4 @@ -/* $NetBSD: init_main.c,v 1.502 2019/01/23 13:38:30 kamil Exp $ */ +/* $NetBSD: init_main.c,v 1.503 2019/02/20 10:07:27 hannken Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -97,7 +97,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.502 2019/01/23 13:38:30 kamil Exp $"); +__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.503 2019/02/20 10:07:27 hannken Exp $"); #include "opt_ddb.h" #include "opt_inet.h" @@ -466,12 +466,13 @@ main(void) if (usevnodes > desiredvnodes) desiredvnodes = usevnodes; #endif - vfsinit(); - lf_init(); /* Initialize fstrans. */ fstrans_init(); + vfsinit(); + lf_init(); + /* Initialize the file descriptor system. */ fd_sys_init(); diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c index 8eda7f71c88..8e7f1992d6e 100644 --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.c @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_mount.c,v 1.68 2019/02/05 09:49:44 hannken Exp $ */ +/* $NetBSD: vfs_mount.c,v 1.69 2019/02/20 10:07:27 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.68 2019/02/05 09:49:44 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.69 2019/02/20 10:07:27 hannken Exp $"); #include <sys/param.h> #include <sys/kernel.h> @@ -149,7 +149,6 @@ vfs_mountalloc(struct vfsops *vfsops, vnode_t *vp) { struct mount *mp; int error __diagused; - extern struct vfsops dead_vfsops; mp = kmem_zalloc(sizeof(*mp), KM_SLEEP); mp->mnt_op = vfsops; @@ -159,10 +158,9 @@ vfs_mountalloc(struct vfsops *vfsops, vnode_t *vp) mutex_init(&mp->mnt_updating, MUTEX_DEFAULT, IPL_NONE); mp->mnt_vnodecovered = vp; mount_initspecific(mp); - if (vfsops != &dead_vfsops) { - error = fstrans_mount(mp); - KASSERT(error == 0); - } + + error = fstrans_mount(mp); + KASSERT(error == 0); mutex_enter(&mountgen_lock); mp->mnt_gen = mountgen++; diff --git a/sys/kern/vfs_trans.c b/sys/kern/vfs_trans.c index c8f75bebf47..da8899cd665 100644 --- a/sys/kern/vfs_trans.c +++ b/sys/kern/vfs_trans.c @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_trans.c,v 1.51 2018/10/05 09:51:55 hannken Exp $ */ +/* $NetBSD: vfs_trans.c,v 1.52 2019/02/20 10:07:27 hannken Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: vfs_trans.c,v 1.51 2018/10/05 09:51:55 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_trans.c,v 1.52 2019/02/20 10:07:27 hannken Exp $"); /* * File system transaction operations. @@ -104,6 +104,8 @@ static bool cow_state_change_done(const struct mount *); static void cow_change_enter(const struct mount *); static void cow_change_done(const struct mount *); +extern struct mount *dead_rootmount; + /* * Initialize. */ @@ -136,8 +138,6 @@ fstrans_normalize_mount(struct mount *mp) mp = mp->mnt_lower; if (mp == NULL) return NULL; - if ((mp->mnt_iflag & IMNT_HAS_TRANS) == 0) - return NULL; return mp; } @@ -182,7 +182,6 @@ fstrans_mount_dtor(struct mount *mp) KASSERT(fmi->fmi_state == FSTRANS_NORMAL); KASSERT(LIST_FIRST(&fmi->fmi_cow_handler) == NULL); - mp->mnt_iflag &= ~IMNT_HAS_TRANS; mp->mnt_transinfo = NULL; mutex_exit(&fstrans_mount_lock); @@ -207,7 +206,6 @@ fstrans_mount(struct mount *mp) mutex_enter(&fstrans_mount_lock); mp->mnt_transinfo = newfmi; - mp->mnt_iflag |= IMNT_HAS_TRANS; mutex_exit(&fstrans_mount_lock); vfs_ref(mp); @@ -222,9 +220,6 @@ void fstrans_unmount(struct mount *mp) { - if ((mp->mnt_iflag & IMNT_HAS_TRANS) == 0) - return; - KASSERT(mp->mnt_transinfo != NULL); fstrans_mount_dtor(mp); @@ -361,6 +356,11 @@ _fstrans_start(struct mount *mp, enum fstrans_lock_type lock_type, int wait) struct fstrans_lwp_info *fli; struct fstrans_mount_info *fmi; +#ifndef FSTRANS_DEAD_ENABLED + if (mp == dead_rootmount) + return 0; +#endif + if ((lmp = fstrans_normalize_mount(mp)) == NULL) return 0; @@ -444,6 +444,11 @@ fstrans_done(struct mount *mp) struct fstrans_lwp_info *fli; struct fstrans_mount_info *fmi; +#ifndef FSTRANS_DEAD_ENABLED + if (mp == dead_rootmount) + return; +#endif + if ((mp = fstrans_normalize_mount(mp)) == NULL) return; if ((fli = fstrans_get_lwp_info(mp, false)) == NULL) @@ -482,6 +487,8 @@ fstrans_is_owner(struct mount *mp) { struct fstrans_lwp_info *fli; + KASSERT(mp != dead_rootmount); + if ((mp = fstrans_normalize_mount(mp)) == NULL) return 0; if ((fli = fstrans_get_lwp_info(mp, false)) == NULL) @@ -532,6 +539,8 @@ fstrans_setstate(struct mount *mp, enum fstrans_state new_state) enum fstrans_state old_state; struct fstrans_mount_info *fmi; + KASSERT(mp != dead_rootmount); + fmi = mp->mnt_transinfo; old_state = fmi->fmi_state; if (old_state == new_state) @@ -574,6 +583,8 @@ fstrans_getstate(struct mount *mp) { struct fstrans_mount_info *fmi; + KASSERT(mp != dead_rootmount); + fmi = mp->mnt_transinfo; KASSERT(fmi != NULL); @@ -588,6 +599,8 @@ vfs_suspend(struct mount *mp, int nowait) { int error; + KASSERT(mp != dead_rootmount); + if ((mp = fstrans_normalize_mount(mp)) == NULL) return EOPNOTSUPP; if (nowait) { @@ -609,6 +622,8 @@ void vfs_resume(struct mount *mp) { + KASSERT(mp != dead_rootmount); + mp = fstrans_normalize_mount(mp); KASSERT(mp != NULL); @@ -702,8 +717,7 @@ fscow_establish(struct mount *mp, int (*func)(void *, struct buf *, bool), struct fstrans_mount_info *fmi; struct fscow_handler *newch; - if ((mp->mnt_iflag & IMNT_HAS_TRANS) == 0) - return EINVAL; + KASSERT(mp != dead_rootmount); fmi = mp->mnt_transinfo; KASSERT(fmi != NULL); @@ -729,8 +743,7 @@ fscow_disestablish(struct mount *mp, int (*func)(void *, struct buf *, bool), struct fstrans_mount_info *fmi; struct fscow_handler *hp = NULL; - if ((mp->mnt_iflag & IMNT_HAS_TRANS) == 0) - return EINVAL; + KASSERT(mp != dead_rootmount); fmi = mp->mnt_transinfo; KASSERT(fmi != NULL); @@ -773,7 +786,7 @@ fscow_run(struct buf *bp, bool data_valid) mp = spec_node_getmountedfs(bp->b_vp); else mp = bp->b_vp->v_mount; - if (mp == NULL || (mp->mnt_iflag & IMNT_HAS_TRANS) == 0) { + if (mp == NULL || mp == dead_rootmount) { bp->b_flags |= B_COWDONE; return 0; } diff --git a/sys/kern/vfs_vnode.c b/sys/kern/vfs_vnode.c index 8b6a4152a20..35be3e0f581 100644 --- a/sys/kern/vfs_vnode.c +++ b/sys/kern/vfs_vnode.c @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_vnode.c,v 1.102 2019/02/20 10:06:33 hannken Exp $ */ +/* $NetBSD: vfs_vnode.c,v 1.103 2019/02/20 10:07:27 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.102 2019/02/20 10:06:33 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.103 2019/02/20 10:07:27 hannken Exp $"); #include <sys/param.h> #include <sys/kernel.h> @@ -382,7 +382,7 @@ vfs_vnode_sysinit(void) dead_rootmount = vfs_mountalloc(&dead_vfsops, NULL); KASSERT(dead_rootmount != NULL); - dead_rootmount->mnt_iflag = IMNT_MPSAFE; + dead_rootmount->mnt_iflag |= IMNT_MPSAFE; mutex_init(&vdrain_lock, MUTEX_DEFAULT, IPL_NONE); TAILQ_INIT(&lru_free_list); @@ -1030,8 +1030,7 @@ void vgone(vnode_t *vp) { - KASSERT((vp->v_mount->mnt_iflag & IMNT_HAS_TRANS) == 0 || - fstrans_is_owner(vp->v_mount)); + KASSERT(vp->v_mount == dead_rootmount || fstrans_is_owner(vp->v_mount)); vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); mutex_enter(vp->v_interlock); @@ -1684,8 +1683,7 @@ vcache_make_anon(vnode_t *vp) bool recycle; KASSERT(vp->v_type == VBLK || vp->v_type == VCHR); - KASSERT((vp->v_mount->mnt_iflag & IMNT_HAS_TRANS) == 0 || - fstrans_is_owner(vp->v_mount)); + KASSERT(vp->v_mount == dead_rootmount || fstrans_is_owner(vp->v_mount)); VSTATE_ASSERT_UNLOCKED(vp, VS_ACTIVE); /* Remove from vnode cache. */ |
