Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-8]: src Pull up following revision(s) (requested by hannken in ti...



details:   https://anonhg.NetBSD.org/src/rev/79fe5a94f384
branches:  netbsd-8
changeset: 435300:79fe5a94f384
user:      martin <martin%NetBSD.org@localhost>
date:      Tue Oct 09 09:58:08 2018 +0000

description:
Pull up following revision(s) (requested by hannken in ticket #1052):

        sys/kern/vfs_trans.c: revision 1.51
        distrib/sets/lists/comp/mi: revision 1.2233
        share/man/man9/fstrans.9: revision 1.27
        share/man/man9/Makefile: revision 1.431
        sys/sys/fstrans.h: revision 1.12
        sys/rump/librump/rumpkern/emul.c: revision 1.187
        sys/dev/vnd.c: revision 1.266
        sys/miscfs/genfs/genfs_vfsops.c: revision 1.8

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 31dc8cc81037 -r 79fe5a94f384 distrib/sets/lists/comp/mi
--- a/distrib/sets/lists/comp/mi        Tue Oct 09 09:53:20 2018 +0000
+++ b/distrib/sets/lists/comp/mi        Tue Oct 09 09:58:08 2018 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: mi,v 1.2138.2.6 2018/06/07 18:24:15 martin Exp $
+#      $NetBSD: mi,v 1.2138.2.7 2018/10/09 09:58:08 martin Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 ./etc/mtree/set.comp                           comp-sys-root
@@ -10567,6 +10567,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
@@ -18033,6 +18034,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
@@ -25645,6 +25647,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 31dc8cc81037 -r 79fe5a94f384 share/man/man9/Makefile
--- a/share/man/man9/Makefile   Tue Oct 09 09:53:20 2018 +0000
+++ b/share/man/man9/Makefile   Tue Oct 09 09:58:08 2018 +0000
@@ -1,4 +1,4 @@
-#       $NetBSD: Makefile,v 1.414.2.1 2018/06/07 18:24:15 martin Exp $
+#       $NetBSD: Makefile,v 1.414.2.2 2018/10/09 09:58:09 martin Exp $
 
 #      Makefile for section 9 (kernel function and variable) manual pages.
 
@@ -356,6 +356,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 31dc8cc81037 -r 79fe5a94f384 share/man/man9/fstrans.9
--- a/share/man/man9/fstrans.9  Tue Oct 09 09:53:20 2018 +0000
+++ b/share/man/man9/fstrans.9  Tue Oct 09 09:58:08 2018 +0000
@@ -1,4 +1,4 @@
-.\"     $NetBSD: fstrans.9,v 1.24.2.1 2017/06/04 20:35:01 bouyer Exp $
+.\"     $NetBSD: fstrans.9,v 1.24.2.2 2018/10/09 09:58:09 martin 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 31dc8cc81037 -r 79fe5a94f384 sys/dev/vnd.c
--- a/sys/dev/vnd.c     Tue Oct 09 09:53:20 2018 +0000
+++ b/sys/dev/vnd.c     Tue Oct 09 09:58:08 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vnd.c,v 1.259.6.1 2017/08/08 16:12:56 martin Exp $     */
+/*     $NetBSD: vnd.c,v 1.259.6.2 2018/10/09 09:58:09 martin 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.259.6.1 2017/08/08 16:12:56 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.259.6.2 2018/10/09 09:58:09 martin 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>
@@ -805,6 +806,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,
@@ -816,6 +820,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 31dc8cc81037 -r 79fe5a94f384 sys/kern/vfs_trans.c
--- a/sys/kern/vfs_trans.c      Tue Oct 09 09:53:20 2018 +0000
+++ b/sys/kern/vfs_trans.c      Tue Oct 09 09:58:08 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_trans.c,v 1.45.2.2 2017/06/21 18:24:26 snj Exp $   */
+/*     $NetBSD: vfs_trans.c,v 1.45.2.3 2018/10/09 09:58:08 martin 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.45.2.2 2017/06/21 18:24:26 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_trans.c,v 1.45.2.3 2018/10/09 09:58:08 martin 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 31dc8cc81037 -r 79fe5a94f384 sys/miscfs/genfs/genfs_vfsops.c
--- a/sys/miscfs/genfs/genfs_vfsops.c   Tue Oct 09 09:53:20 2018 +0000
+++ b/sys/miscfs/genfs/genfs_vfsops.c   Tue Oct 09 09:58:08 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.7.2.1 2018/10/09 09:58:09 martin 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.7.2.1 2018/10/09 09:58:09 martin 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 31dc8cc81037 -r 79fe5a94f384 sys/rump/librump/rumpkern/emul.c
--- a/sys/rump/librump/rumpkern/emul.c  Tue Oct 09 09:53:20 2018 +0000
+++ b/sys/rump/librump/rumpkern/emul.c  Tue Oct 09 09:58:08 2018 +0000
@@ -1,4 +1,4 @@



Home | Main Index | Thread Index | Old Index