Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern Add an operation to test a mount for fstrans suppor...
details: https://anonhg.NetBSD.org/src/rev/34c06ecfac78
branches: trunk
changeset: 351873:34c06ecfac78
user: hannken <hannken%NetBSD.org@localhost>
date: Thu Mar 02 10:41:27 2017 +0000
description:
Add an operation to test a mount for fstrans support and use it for
_fstrans_start(), fstrans_done(), fstrans_is_owner(), vfs_suspend()
and vfs_resume().
Test for fstrans support before ASSERT_SLEEPABLE().
diffstat:
sys/kern/vfs_trans.c | 51 ++++++++++++++++++++++++++++++++++++---------------
1 files changed, 36 insertions(+), 15 deletions(-)
diffs (130 lines):
diff -r 229ebc2802cd -r 34c06ecfac78 sys/kern/vfs_trans.c
--- a/sys/kern/vfs_trans.c Thu Mar 02 09:48:20 2017 +0000
+++ b/sys/kern/vfs_trans.c Thu Mar 02 10:41:27 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_trans.c,v 1.37 2017/02/23 11:23:22 hannken Exp $ */
+/* $NetBSD: vfs_trans.c,v 1.38 2017/03/02 10:41: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.37 2017/02/23 11:23:22 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_trans.c,v 1.38 2017/03/02 10:41:27 hannken Exp $");
/*
* File system transaction operations.
@@ -85,6 +85,7 @@
static LIST_HEAD(fstrans_lwp_head, fstrans_lwp_info) fstrans_fli_head;
/* List of all fstrans_lwp_info. */
+static inline struct mount *fstrans_normalize_mount(struct mount *);
static void fstrans_lwp_dtor(void *);
static void fstrans_mount_dtor(struct mount *);
static struct fstrans_lwp_info *fstrans_get_lwp_info(struct mount *, bool);
@@ -115,6 +116,21 @@
}
/*
+ * Normalize mount.
+ * Return mount if file system supports fstrans, NULL otherwise.
+ */
+static inline struct mount *
+fstrans_normalize_mount(struct mount *mp)
+{
+
+ if (mp == NULL)
+ return NULL;
+ if ((mp->mnt_iflag & IMNT_HAS_TRANS) == 0)
+ return NULL;
+ return mp;
+}
+
+/*
* Deallocate lwp state.
*/
static void
@@ -199,6 +215,9 @@
fstrans_unmount(struct mount *mp)
{
+ if ((mp->mnt_iflag & IMNT_HAS_TRANS) == 0)
+ return;
+
KASSERT(mp->mnt_transinfo != NULL);
fstrans_mount_dtor(mp);
@@ -235,16 +254,6 @@
return NULL;
/*
- * Does this file system support fstrans?
- */
- mutex_enter(&fstrans_mount_lock);
- if ((mp->mnt_iflag & IMNT_HAS_TRANS) == 0) {
- mutex_exit(&fstrans_mount_lock);
- return NULL;
- }
- mutex_exit(&fstrans_mount_lock);
-
- /*
* Try to reuse a cleared entry or allocate a new one.
*/
for (fli = lwp_getspecific(lwp_data_key); fli; fli = fli->fli_succ) {
@@ -321,9 +330,12 @@
struct fstrans_lwp_info *fli;
struct fstrans_mount_info *fmi;
+ if ((mp = fstrans_normalize_mount(mp)) == NULL)
+ return 0;
+
ASSERT_SLEEPABLE();
- if (mp == NULL || (fli = fstrans_get_lwp_info(mp, true)) == NULL)
+ if ((fli = fstrans_get_lwp_info(mp, true)) == NULL)
return 0;
if (fli->fli_trans_cnt > 0) {
@@ -367,7 +379,9 @@
struct fstrans_lwp_info *fli;
struct fstrans_mount_info *fmi;
- if (mp == NULL || (fli = fstrans_get_lwp_info(mp, true)) == NULL)
+ if ((mp = fstrans_normalize_mount(mp)) == NULL)
+ return;
+ if ((fli = fstrans_get_lwp_info(mp, true)) == NULL)
return;
KASSERT(fli->fli_trans_cnt > 0);
@@ -402,7 +416,9 @@
{
struct fstrans_lwp_info *fli;
- if (mp == NULL || (fli = fstrans_get_lwp_info(mp, false)) == NULL)
+ if ((mp = fstrans_normalize_mount(mp)) == NULL)
+ return 0;
+ if ((fli = fstrans_get_lwp_info(mp, false)) == NULL)
return 0;
if (fli->fli_trans_cnt == 0)
@@ -506,6 +522,8 @@
{
int error;
+ if ((mp = fstrans_normalize_mount(mp)) == NULL)
+ return EOPNOTSUPP;
if (nowait) {
if (!mutex_tryenter(&vfs_suspend_lock))
return EWOULDBLOCK;
@@ -525,6 +543,9 @@
vfs_resume(struct mount *mp)
{
+ mp = fstrans_normalize_mount(mp);
+ KASSERT(mp != NULL);
+
VFS_SUSPENDCTL(mp, SUSPEND_RESUME);
mutex_exit(&vfs_suspend_lock);
}
Home |
Main Index |
Thread Index |
Old Index