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 | |
| 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')
| -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 | ||||
| -rw-r--r-- | sys/miscfs/genfs/genfs_vfsops.c | 7 | ||||
| -rw-r--r-- | sys/rump/librump/rumpvfs/rump_vfs.c | 6 | ||||
| -rw-r--r-- | sys/sys/fstypes.h | 4 |
7 files changed, 48 insertions, 43 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. */ diff --git a/sys/miscfs/genfs/genfs_vfsops.c b/sys/miscfs/genfs/genfs_vfsops.c index 33e3d7e3d9e..98ee6110650 100644 --- a/sys/miscfs/genfs/genfs_vfsops.c +++ b/sys/miscfs/genfs/genfs_vfsops.c @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_vfsops.c,v 1.8 2018/10/05 09:51:55 hannken Exp $ */ +/* $NetBSD: genfs_vfsops.c,v 1.9 2019/02/20 10:07:27 hannken Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: genfs_vfsops.c,v 1.8 2018/10/05 09:51:55 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfs_vfsops.c,v 1.9 2019/02/20 10:07:27 hannken Exp $"); #include <sys/types.h> #include <sys/mount.h> @@ -78,9 +78,6 @@ genfs_suspendctl(struct mount *mp, int cmd) int error; int error2 __diagused; - if ((mp->mnt_iflag & IMNT_HAS_TRANS) == 0) - return EOPNOTSUPP; - switch (cmd) { case SUSPEND_SUSPEND: error = fstrans_setstate(mp, FSTRANS_SUSPENDING); diff --git a/sys/rump/librump/rumpvfs/rump_vfs.c b/sys/rump/librump/rumpvfs/rump_vfs.c index b89db731957..d7dac85c14f 100644 --- a/sys/rump/librump/rumpvfs/rump_vfs.c +++ b/sys/rump/librump/rumpvfs/rump_vfs.c @@ -1,4 +1,4 @@ -/* $NetBSD: rump_vfs.c,v 1.87 2017/04/01 19:35:57 riastradh Exp $ */ +/* $NetBSD: rump_vfs.c,v 1.88 2019/02/20 10:07:27 hannken Exp $ */ /* * Copyright (c) 2008 Antti Kantee. All Rights Reserved. @@ -29,7 +29,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rump_vfs.c,v 1.87 2017/04/01 19:35:57 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rump_vfs.c,v 1.88 2019/02/20 10:07:27 hannken Exp $"); #include <sys/param.h> #include <sys/buf.h> @@ -122,12 +122,12 @@ RUMP_COMPONENT(RUMP__FACTION_VFS) } bufq_init(); + fstrans_init(); vfsinit(); bufinit(); cwd_sys_init(); lf_init(); spec_init(); - fstrans_init(); root_device = &rump_rootdev; diff --git a/sys/sys/fstypes.h b/sys/sys/fstypes.h index 94689d15711..04829272a52 100644 --- a/sys/sys/fstypes.h +++ b/sys/sys/fstypes.h @@ -1,4 +1,4 @@ -/* $NetBSD: fstypes.h,v 1.36 2018/01/09 03:31:13 christos Exp $ */ +/* $NetBSD: fstypes.h,v 1.37 2019/02/20 10:07:27 hannken Exp $ */ /* * Copyright (c) 1989, 1991, 1993 @@ -221,7 +221,6 @@ typedef struct fhandle fhandle_t; #define IMNT_WANTRDWR 0x00000004 /* upgrade to read/write requested */ #define IMNT_WANTRDONLY 0x00000008 /* upgrade to readonly requested */ #define IMNT_DTYPE 0x00000040 /* returns d_type fields */ -#define IMNT_HAS_TRANS 0x00000080 /* supports transactions */ #define IMNT_MPSAFE 0x00000100 /* file system code MP safe */ #define IMNT_CAN_RWTORO 0x00000200 /* can downgrade fs to from rw to r/o */ #define IMNT_ONWORKLIST 0x00000400 /* on syncer worklist */ @@ -272,7 +271,6 @@ typedef struct fhandle fhandle_t; "\13IMNT_ONWORKLIST" \ "\12IMNT_CAN_RWTORO" \ "\11IMNT_MPSAFE" \ - "\10IMNT_HAS_TRANS" \ "\07IMNT_DTYPE" \ "\04IMNT_WANTRDONLY" \ "\03IMNT_WANTRDWR" \ |
