Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/sys Bring back three state file system suspension:
details: https://anonhg.NetBSD.org/src/rev/587a688f419e
branches: trunk
changeset: 993853:587a688f419e
user: hannken <hannken%NetBSD.org@localhost>
date: Fri Oct 05 09:51:55 2018 +0000
description:
Bring back three state file system suspension:
NORMAL -> SUSPENDING -> SUSPENDED
and add operation fstrans_start_lazy() that only blocks while SUSPENDED.
Change vndthread() support operation handle_with_rdwr() to bracket
its file system operations by fstrans_start_lazy() and fstrans_done().
PR kern/53624 (dom0 freeze on domU exit)
diffstat:
distrib/sets/lists/comp/mi | 5 ++++-
share/man/man9/Makefile | 3 ++-
share/man/man9/fstrans.9 | 37 ++++++++++++++++++++++++++++++++++---
sys/dev/vnd.c | 10 ++++++++--
sys/kern/vfs_trans.c | 22 ++++++++++++++++++++--
sys/miscfs/genfs/genfs_vfsops.c | 7 +++++--
sys/rump/librump/rumpkern/emul.c | 13 +++++++++++--
sys/sys/fstrans.h | 6 ++++--
8 files changed, 88 insertions(+), 15 deletions(-)
diffs (truncated from 355 to 300 lines):
diff -r 2fa6faade66c -r 587a688f419e distrib/sets/lists/comp/mi
--- a/distrib/sets/lists/comp/mi Fri Oct 05 09:49:23 2018 +0000
+++ b/distrib/sets/lists/comp/mi Fri Oct 05 09:51:55 2018 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.2232 2018/09/26 12:59:37 rin Exp $
+# $NetBSD: mi,v 1.2233 2018/10/05 09:51:55 hannken Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
./etc/mtree/set.comp comp-sys-root
@@ -10988,6 +10988,7 @@
./usr/share/man/cat9/fstrans_is_owner.0 comp-sys-catman .cat
./usr/share/man/cat9/fstrans_setstate.0 comp-sys-catman .cat
./usr/share/man/cat9/fstrans_start.0 comp-sys-catman .cat
+./usr/share/man/cat9/fstrans_start_lazy.0 comp-sys-catman .cat
./usr/share/man/cat9/fstrans_start_nowait.0 comp-sys-catman .cat
./usr/share/man/cat9/fubyte.0 comp-sys-catman .cat
./usr/share/man/cat9/fuibyte.0 comp-sys-catman .cat
@@ -18801,6 +18802,7 @@
./usr/share/man/html9/fstrans_is_owner.html comp-sys-htmlman html
./usr/share/man/html9/fstrans_setstate.html comp-sys-htmlman html
./usr/share/man/html9/fstrans_start.html comp-sys-htmlman html
+./usr/share/man/html9/fstrans_start_lazy.html comp-sys-htmlman html
./usr/share/man/html9/fstrans_start_nowait.html comp-sys-htmlman html
./usr/share/man/html9/fubyte.html comp-sys-htmlman html
./usr/share/man/html9/fuibyte.html comp-sys-htmlman html
@@ -26760,6 +26762,7 @@
./usr/share/man/man9/fstrans_is_owner.9 comp-sys-man .man
./usr/share/man/man9/fstrans_setstate.9 comp-sys-man .man
./usr/share/man/man9/fstrans_start.9 comp-sys-man .man
+./usr/share/man/man9/fstrans_start_lazy.9 comp-sys-man .man
./usr/share/man/man9/fstrans_start_nowait.9 comp-sys-man .man
./usr/share/man/man9/fubyte.9 comp-sys-man .man
./usr/share/man/man9/fuibyte.9 comp-sys-man .man
diff -r 2fa6faade66c -r 587a688f419e share/man/man9/Makefile
--- a/share/man/man9/Makefile Fri Oct 05 09:49:23 2018 +0000
+++ b/share/man/man9/Makefile Fri Oct 05 09:51:55 2018 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.430 2018/09/20 06:54:36 rin Exp $
+# $NetBSD: Makefile,v 1.431 2018/10/05 09:51:55 hannken Exp $
# Makefile for section 9 (kernel function and variable) manual pages.
@@ -357,6 +357,7 @@
fstrans.9 fstrans_getstate.9 \
fstrans.9 fstrans_setstate.9 \
fstrans.9 fstrans_start.9 \
+ fstrans.9 fstrans_start_lazy.9 \
fstrans.9 fstrans_start_nowait.9 \
fstrans.9 fscow_establish.9 \
fstrans.9 fscow_disestablish.9 \
diff -r 2fa6faade66c -r 587a688f419e share/man/man9/fstrans.9
--- a/share/man/man9/fstrans.9 Fri Oct 05 09:49:23 2018 +0000
+++ b/share/man/man9/fstrans.9 Fri Oct 05 09:51:55 2018 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: fstrans.9,v 1.26 2017/07/03 21:28:48 wiz Exp $
+.\" $NetBSD: fstrans.9,v 1.27 2018/10/05 09:51:55 hannken Exp $
.\"
.\" Copyright (c) 2007 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -27,7 +27,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd June 4, 2017
+.Dd October 4, 2018
.Dt FSTRANS 9
.Os
.Sh NAME
@@ -36,6 +36,7 @@
.Nm fstrans_getstate ,
.Nm fstrans_start ,
.Nm fstrans_start_nowait ,
+.Nm fstrans_start_lazy ,
.Nm fstrans_done ,
.Nm fstrans_is_owner ,
.Nm fscow_establish ,
@@ -50,6 +51,8 @@
.Ft int
.Fn fstrans_start_nowait "struct mount *mp"
.Ft void
+.Fn fstrans_start_lazy "struct mount *mp"
+.Ft void
.Fn fstrans_done "struct mount *mp"
.Ft int
.Fn fstrans_setstate "struct mount *mp" "enum fstrans_state new_state"
@@ -81,6 +84,15 @@
transaction, which is blocked by suspending the file system and while
it is suspended.
.Pp
+Operations needed while suspending the file system must be bracketed by
+.Fn fstrans_start_lazy
+and
+.Fn fstrans_done
+in a
+.Em lazy
+transaction, which is allowed while suspending the file system, but
+blocked while the file system is suspended.
+.Pp
Transactions are per-thread and nestable: if a thread is already in a
transaction, it can enter another transaction without blocking.
Each
@@ -97,6 +109,10 @@
.Bl -dash
.It
enter the
+.Dv FSTRANS_SUSPENDING
+to suspend all normal operations but allow lazy transactions,
+.It
+enter the
.Dv FSTRANS_SUSPENDED
state to suspend all operations, and
.It
@@ -149,6 +165,12 @@
immediately if transactions are blocked in its current state.
.Pp
May sleep nevertheless on internal locks.
+.It Fn fstrans_start_lazy "mp"
+Like
+.Fn fstrans_start ,
+but will not block while suspending.
+.Pp
+May sleep.
.It Fn fstrans_done "mp"
End the current transaction on
.Fa mp .
@@ -165,9 +187,15 @@
and wait for all transactions not allowed in
.Fa new_state
to complete.
-.Bl -tag -width FSTRANS_SUSPENDED
+.Bl -tag -width FSTRANS_SUSPENDING
.It Dv FSTRANS_NORMAL
Allow all transactions.
+.It Dv FSTRANS_SUSPENDING
+Block
+.Dv FSTRANS_SHARED
+transactions but allow
+.Dv FSTRANS_LAZY
+transactions.
.It Dv FSTRANS_SUSPENDED
Block all transactions.
.El
@@ -244,6 +272,9 @@
switch (cmd) {
case SUSPEND_SUSPEND:
+ error = fstrans_setstate(mp, FSTRANS_SUSPENDING);
+ if (error)
+ return error;
return fstrans_setstate(mp, FSTRANS_SUSPENDED);
case SUSPEND_RESUME:
diff -r 2fa6faade66c -r 587a688f419e sys/dev/vnd.c
--- a/sys/dev/vnd.c Fri Oct 05 09:49:23 2018 +0000
+++ b/sys/dev/vnd.c Fri Oct 05 09:51:55 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vnd.c,v 1.265 2018/09/20 07:18:38 mlelstv Exp $ */
+/* $NetBSD: vnd.c,v 1.266 2018/10/05 09:51:55 hannken Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc.
@@ -91,7 +91,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.265 2018/09/20 07:18:38 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.266 2018/10/05 09:51:55 hannken Exp $");
#if defined(_KERNEL_OPT)
#include "opt_vnd.h"
@@ -114,6 +114,7 @@
#include <sys/stat.h>
#include <sys/mount.h>
#include <sys/vnode.h>
+#include <sys/fstrans.h>
#include <sys/file.h>
#include <sys/uio.h>
#include <sys/conf.h>
@@ -802,6 +803,9 @@
bp->b_bcount);
#endif
+ /* Make sure the request succeeds while suspending this fs. */
+ fstrans_start_lazy(vp->v_mount);
+
/* Issue the read or write operation. */
bp->b_error =
vn_rdwr(doread ? UIO_READ : UIO_WRITE,
@@ -813,6 +817,8 @@
(void) VOP_PUTPAGES(vp, 0, 0,
PGO_ALLPAGES | PGO_CLEANIT | PGO_FREE | PGO_SYNCIO);
+ fstrans_done(vp->v_mount);
+
/* We need to increase the number of outputs on the vnode if
* there was any write to it. */
if (!doread) {
diff -r 2fa6faade66c -r 587a688f419e sys/kern/vfs_trans.c
--- a/sys/kern/vfs_trans.c Fri Oct 05 09:49:23 2018 +0000
+++ b/sys/kern/vfs_trans.c Fri Oct 05 09:51:55 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_trans.c,v 1.50 2018/10/05 01:25:38 manu Exp $ */
+/* $NetBSD: vfs_trans.c,v 1.51 2018/10/05 09:51:55 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.50 2018/10/05 01:25:38 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_trans.c,v 1.51 2018/10/05 09:51:55 hannken Exp $");
/*
* File system transaction operations.
@@ -54,6 +54,7 @@
#include <miscfs/specfs/specdev.h>
enum fstrans_lock_type {
+ FSTRANS_LAZY, /* Granted while not suspended */
FSTRANS_SHARED, /* Granted while not suspending */
FSTRANS_EXCL /* Internal: exclusive lock */
};
@@ -342,6 +343,8 @@
return true;
if (type == FSTRANS_EXCL)
return true;
+ if (state == FSTRANS_SUSPENDING && type == FSTRANS_LAZY)
+ return true;
return false;
}
@@ -422,6 +425,15 @@
return _fstrans_start(mp, FSTRANS_SHARED, 0);
}
+void
+fstrans_start_lazy(struct mount *mp)
+{
+ int error __diagused;
+
+ error = _fstrans_start(mp, FSTRANS_LAZY, 1);
+ KASSERT(error == 0);
+}
+
/*
* Finish a transaction.
*/
@@ -849,6 +861,9 @@
printf(" -");
} else {
switch (fli->fli_lock_type) {
+ case FSTRANS_LAZY:
+ printf(" lazy");
+ break;
case FSTRANS_SHARED:
printf(" shared");
break;
@@ -883,6 +898,9 @@
case FSTRANS_NORMAL:
printf("state normal\n");
break;
+ case FSTRANS_SUSPENDING:
+ printf("state suspending\n");
+ break;
case FSTRANS_SUSPENDED:
printf("state suspended\n");
break;
diff -r 2fa6faade66c -r 587a688f419e sys/miscfs/genfs/genfs_vfsops.c
--- a/sys/miscfs/genfs/genfs_vfsops.c Fri Oct 05 09:49:23 2018 +0000
+++ b/sys/miscfs/genfs/genfs_vfsops.c Fri Oct 05 09:51:55 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: genfs_vfsops.c,v 1.7 2017/05/24 09:53:55 hannken Exp $ */
+/* $NetBSD: genfs_vfsops.c,v 1.8 2018/10/05 09:51:55 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.7 2017/05/24 09:53:55 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_vfsops.c,v 1.8 2018/10/05 09:51:55 hannken Exp $");
#include <sys/types.h>
#include <sys/mount.h>
@@ -83,6 +83,9 @@
switch (cmd) {
case SUSPEND_SUSPEND:
+ error = fstrans_setstate(mp, FSTRANS_SUSPENDING);
+ if (error)
+ return error;
error = fstrans_setstate(mp, FSTRANS_SUSPENDED);
if (error == 0) {
if ((mp->mnt_iflag & IMNT_GONE) != 0)
diff -r 2fa6faade66c -r 587a688f419e sys/rump/librump/rumpkern/emul.c
--- a/sys/rump/librump/rumpkern/emul.c Fri Oct 05 09:49:23 2018 +0000
+++ b/sys/rump/librump/rumpkern/emul.c Fri Oct 05 09:51:55 2018 +0000
@@ -1,4 +1,4 @@
Home |
Main Index |
Thread Index |
Old Index