Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Attach "mnt_transinfo" to "dead_rootmount" so every moun...
details: https://anonhg.NetBSD.org/src/rev/3c16a5b1c282
branches: trunk
changeset: 449061:3c16a5b1c282
user: hannken <hannken%NetBSD.org@localhost>
date: Wed Feb 20 10:07:27 2019 +0000
description:
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:
sys/kern/init_main.c | 9 ++++---
sys/kern/vfs_mount.c | 12 ++++------
sys/kern/vfs_trans.c | 41 ++++++++++++++++++++++++------------
sys/kern/vfs_vnode.c | 12 ++++------
sys/miscfs/genfs/genfs_vfsops.c | 7 +----
sys/rump/librump/rumpvfs/rump_vfs.c | 6 ++--
sys/sys/fstypes.h | 4 +--
7 files changed, 48 insertions(+), 43 deletions(-)
diffs (truncated from 366 to 300 lines):
diff -r fba9d9b82a52 -r 3c16a5b1c282 sys/kern/init_main.c
--- a/sys/kern/init_main.c Wed Feb 20 10:06:33 2019 +0000
+++ b/sys/kern/init_main.c Wed Feb 20 10:07:27 2019 +0000
@@ -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 @@
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 -r fba9d9b82a52 -r 3c16a5b1c282 sys/kern/vfs_mount.c
--- a/sys/kern/vfs_mount.c Wed Feb 20 10:06:33 2019 +0000
+++ b/sys/kern/vfs_mount.c Wed Feb 20 10:07:27 2019 +0000
@@ -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 @@
{
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 @@
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 -r fba9d9b82a52 -r 3c16a5b1c282 sys/kern/vfs_trans.c
--- a/sys/kern/vfs_trans.c Wed Feb 20 10:06:33 2019 +0000
+++ b/sys/kern/vfs_trans.c Wed Feb 20 10:07:27 2019 +0000
@@ -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 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
{
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 @@
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 @@
{
struct fstrans_mount_info *fmi;
+ KASSERT(mp != dead_rootmount);
+
fmi = mp->mnt_transinfo;
KASSERT(fmi != NULL);
@@ -588,6 +599,8 @@
{
int error;
+ KASSERT(mp != dead_rootmount);
+
if ((mp = fstrans_normalize_mount(mp)) == NULL)
return EOPNOTSUPP;
if (nowait) {
@@ -609,6 +622,8 @@
vfs_resume(struct mount *mp)
{
+ KASSERT(mp != dead_rootmount);
+
mp = fstrans_normalize_mount(mp);
KASSERT(mp != NULL);
@@ -702,8 +717,7 @@
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 @@
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 @@
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 -r fba9d9b82a52 -r 3c16a5b1c282 sys/kern/vfs_vnode.c
--- a/sys/kern/vfs_vnode.c Wed Feb 20 10:06:33 2019 +0000
+++ b/sys/kern/vfs_vnode.c Wed Feb 20 10:07:27 2019 +0000
@@ -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 @@
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 @@
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 @@
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 -r fba9d9b82a52 -r 3c16a5b1c282 sys/miscfs/genfs/genfs_vfsops.c
--- a/sys/miscfs/genfs/genfs_vfsops.c Wed Feb 20 10:06:33 2019 +0000
+++ b/sys/miscfs/genfs/genfs_vfsops.c Wed Feb 20 10:07:27 2019 +0000
@@ -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 @@
Home |
Main Index |
Thread Index |
Old Index