Source-Changes-HG archive

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

[src/netbsd-8]: src pullup the following revisions, requested by hannken in t...



details:   https://anonhg.NetBSD.org/src/rev/48da8cadf8ec
branches:  netbsd-8
changeset: 850689:48da8cadf8ec
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Sun Jun 04 20:35:01 2017 +0000

description:
pullup the following revisions, requested by hannken in ticket #2:
        src/share/man/man9/fstrans.9                    1.25
        src/sys/kern/vfs_mount.c                        1.66
        src/sys/kern/vfs_subr.c                         1.468
        src/sys/kern/vfs_trans.c                        1.46
        src/sys/kern/vfs_vnode.c                        1.94, 1.95, 1.96
        src/sys/kern/vnode_if.c                         1.105, 1.106
        src/sys/kern/vnode_if.sh                        1.65, 1.66
        src/sys/kern/vnode_if.src                       1.76
        src/sys/miscfs/genfs/genfs_io.c                 1.69
        src/sys/miscfs/genfs/genfs_vnops.c              1.196, 1.197
        src/sys/miscfs/genfs/layer_extern.h             1.40
        src/sys/miscfs/genfs/layer_vfsops.c             1.51
        src/sys/miscfs/genfs/layer_vnops.c              1.67
        src/sys/miscfs/nullfs/null_vnops.c              1.42
        src/sys/miscfs/overlay/overlay_vnops.c          1.24
        src/sys/miscfs/umapfs/umap_vnops.c              1.60
        src/sys/rump/include/rump/rumpvnode_if.h        1.29, 1.30
        src/sys/rump/librump/rumpkern/emul.c            1.182
        src/sys/rump/librump/rumpvfs/rumpvnode_if.c     1.29, 1.30
        src/sys/sys/fstrans.h                           1.11
        src/sys/sys/vnode.h                             1.278
        src/sys/sys/vnode_if.h                          1.100, 1.101
        src/sys/sys/vnode_impl.h                        1.14, 1.15
        src/sys/ufs/lfs/lfs_pages.c                     1.12

Vnode state, lock and fstrans cleanup:
- Rename vnode state "VS_ACTIVE" to "VS_LOADED" and add synthetic
  state "VS_ACTIVE" to assert a loaded vnode with usecount > 0.

- Redo FSTRANS in vnode_if.c and use it for VOP_LOCK and VOP_UNLOCK.

- Cleanup the genfs lock operations.

- Make "struct vnode_impl" member "vi_lock" a krwlock_t again.

- Remove the lock type argument from fstrans_start and
  fstrans_start_nowait,
  remove now unused FSTRANS state "FSTRANS_SUSPENDING".

diffstat:

 share/man/man9/fstrans.9                |   63 +---
 sys/kern/vfs_mount.c                    |    8 +-
 sys/kern/vfs_subr.c                     |   10 +-
 sys/kern/vfs_trans.c                    |   39 +-
 sys/kern/vfs_vnode.c                    |  107 +++---
 sys/kern/vnode_if.c                     |  484 +++++++++++++++++++------------
 sys/kern/vnode_if.sh                    |  100 +++++-
 sys/kern/vnode_if.src                   |    6 +-
 sys/miscfs/genfs/genfs_io.c             |   10 +-
 sys/miscfs/genfs/genfs_vnops.c          |   86 +----
 sys/miscfs/genfs/layer_extern.h         |    5 +-
 sys/miscfs/genfs/layer_vfsops.c         |    7 +-
 sys/miscfs/genfs/layer_vnops.c          |    6 +-
 sys/miscfs/nullfs/null_vnops.c          |    7 +-
 sys/miscfs/overlay/overlay_vnops.c      |    9 +-
 sys/miscfs/umapfs/umap_vnops.c          |    7 +-
 sys/rump/include/rump/rumpvnode_if.h    |    6 +-
 sys/rump/librump/rumpkern/emul.c        |   18 +-
 sys/rump/librump/rumpvfs/rumpvnode_if.c |    8 +-
 sys/sys/fstrans.h                       |   17 +-
 sys/sys/vnode.h                         |    3 +-
 sys/sys/vnode_if.h                      |    6 +-
 sys/sys/vnode_impl.h                    |   32 +-
 sys/ufs/lfs/lfs_pages.c                 |    8 +-
 24 files changed, 579 insertions(+), 473 deletions(-)

diffs (truncated from 2600 to 300 lines):

diff -r 037411ae6081 -r 48da8cadf8ec share/man/man9/fstrans.9
--- a/share/man/man9/fstrans.9  Sun Jun 04 07:12:09 2017 +0000
+++ b/share/man/man9/fstrans.9  Sun Jun 04 20:35:01 2017 +0000
@@ -1,4 +1,4 @@
-.\"     $NetBSD: fstrans.9,v 1.24 2017/05/29 08:03:13 wiz Exp $
+.\"     $NetBSD: fstrans.9,v 1.24.2.1 2017/06/04 20:35:01 bouyer 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 May 29, 2017
+.Dd June 4, 2017
 .Dt FSTRANS 9
 .Os
 .Sh NAME
@@ -46,9 +46,9 @@
 .In sys/mount.h
 .In sys/fstrans.h
 .Ft void
-.Fn fstrans_start "struct mount *mp" "enum fstrans_lock_type lock_type"
+.Fn fstrans_start "struct mount *mp"
 .Ft int
-.Fn fstrans_start_nowait "struct mount *mp" "enum fstrans_lock_type lock_type"
+.Fn fstrans_start_nowait "struct mount *mp"
 .Ft void
 .Fn fstrans_done "struct mount *mp"
 .Ft int
@@ -81,17 +81,6 @@
 transaction, which is blocked by suspending the file system and while
 it is suspended.
 .Pp
-Operations needed to sync the file system to its backing store must be
-bracketed by
-.Fn fstrans_start
-and
-.Fn fstrans_done
-in a
-.Em lazy
-transaction, which is allowed while suspending the file system in order
-to sync it to its backing store, 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
@@ -108,12 +97,8 @@
 .Bl -dash
 .It
 enter the
-.Dv FSTRANS_SUSPENDING
-to suspend all normal operations but allow syncing,
-.It
-enter the
 .Dv FSTRANS_SUSPENDED
-state to suspend all operations once synced, and
+state to suspend all operations, and
 .It
 restore to the
 .Dv FSTRANS_NORMAL
@@ -140,24 +125,14 @@
 when the file system is done with it.
 .Sh FUNCTIONS
 .Bl -tag -width abcd
-.It Fn fstrans_start "mp" "lock_type"
-Enter a transaction of type
-.Fa lock_type
-on the file system
+.It Fn fstrans_start "mp"
+Enter a transaction on the file system
 .Fa mp
 in the current thread.
 If the file system is in a state that blocks such transactions, wait
 until it changes state to one that does not.
-.Bl -tag -width FSTRANS_SHARED
-.It Dv FSTRANS_SHARED
-If the file system is suspending or suspended, wait until it is
-resumed.
-Intended for normal file system operations.
-.It Dv FSTRANS_LAZY
+.Pp
 If the file system is suspended, wait until it is resumed.
-Intended for operations needed to sync the file system to its backing
-store in order to suspend it.
-.El
 .Pp
 However, if the current thread is already in a transaction on
 .Fa mp ,
@@ -166,14 +141,12 @@
 waiting.
 .Pp
 May sleep.
-.It Fn fstrans_start_nowait "mp" "lock_type"
+.It Fn fstrans_start_nowait "mp"
 Like
 .Fn fstrans_start ,
 but return
 .Dv EBUSY
-immediately if
-.Fa lock_type
-transactions are blocked in its current state.
+immediately if transactions are blocked in its current state.
 .Pp
 May sleep nevertheless on internal locks.
 .It Fn fstrans_done "mp"
@@ -192,15 +165,9 @@
 and wait for all transactions not allowed in
 .Fa new_state
 to complete.
-.Bl -tag -width FSTRANS_SUSPENDING
+.Bl -tag -width FSTRANS_SUSPENDED
 .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
@@ -277,12 +244,6 @@
 
        switch (cmd) {
        case SUSPEND_SUSPEND:
-               error = fstrans_setstate(mp, FSTRANS_SUSPENDING);
-               if (error)
-                       return error;
-
-               /* Sync file system state to disk. */
-
                return fstrans_setstate(mp, FSTRANS_SUSPENDED);
 
        case SUSPEND_RESUME:
@@ -303,7 +264,7 @@
        struct mount *mp = ap-\*[Gt]a_dvp-\*[Gt]v_mount;
        int error;
 
-       fstrans_start(mp, FSTRANS_SHARED);
+       fstrans_start(mp);
 
        /* Actually create the node. */
 
diff -r 037411ae6081 -r 48da8cadf8ec sys/kern/vfs_mount.c
--- a/sys/kern/vfs_mount.c      Sun Jun 04 07:12:09 2017 +0000
+++ b/sys/kern/vfs_mount.c      Sun Jun 04 20:35:01 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_mount.c,v 1.65 2017/06/01 02:45:13 chs Exp $       */
+/*     $NetBSD: vfs_mount.c,v 1.65.2.1 2017/06/04 20:35:01 bouyer 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.65 2017/06/01 02:45:13 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.65.2.1 2017/06/04 20:35:01 bouyer Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -319,9 +319,9 @@
        KASSERT(mp->mnt_refcnt > 0);
 
        if (wait) {
-               fstrans_start(mp, FSTRANS_SHARED);
+               fstrans_start(mp);
        } else {
-               if (fstrans_start_nowait(mp, FSTRANS_SHARED))
+               if (fstrans_start_nowait(mp))
                        return EBUSY;
        }
        if (__predict_false((mp->mnt_iflag & IMNT_GONE) != 0)) {
diff -r 037411ae6081 -r 48da8cadf8ec sys/kern/vfs_subr.c
--- a/sys/kern/vfs_subr.c       Sun Jun 04 07:12:09 2017 +0000
+++ b/sys/kern/vfs_subr.c       Sun Jun 04 20:35:01 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_subr.c,v 1.467 2017/05/26 14:34:19 riastradh Exp $ */
+/*     $NetBSD: vfs_subr.c,v 1.467.2.1 2017/06/04 20:35:01 bouyer Exp $        */
 
 /*-
  * Copyright (c) 1997, 1998, 2004, 2005, 2007, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.467 2017/05/26 14:34:19 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.467.2.1 2017/06/04 20:35:01 bouyer Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -1055,12 +1055,14 @@
 {
 
        switch (state) {
+       case VS_ACTIVE:
+               return "ACTIVE";
        case VS_MARKER:
                return "MARKER";
        case VS_LOADING:
                return "LOADING";
-       case VS_ACTIVE:
-               return "ACTIVE";
+       case VS_LOADED:
+               return "LOADED";
        case VS_BLOCKED:
                return "BLOCKED";
        case VS_RECLAIMING:
diff -r 037411ae6081 -r 48da8cadf8ec sys/kern/vfs_trans.c
--- a/sys/kern/vfs_trans.c      Sun Jun 04 07:12:09 2017 +0000
+++ b/sys/kern/vfs_trans.c      Sun Jun 04 20:35:01 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_trans.c,v 1.45 2017/05/07 08:24:20 hannken Exp $   */
+/*     $NetBSD: vfs_trans.c,v 1.45.2.1 2017/06/04 20:35:01 bouyer 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 2017/05/07 08:24:20 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_trans.c,v 1.45.2.1 2017/06/04 20:35:01 bouyer Exp $");
 
 /*
  * File system transaction operations.
@@ -48,12 +48,16 @@
 #include <sys/mount.h>
 #include <sys/pserialize.h>
 #include <sys/vnode.h>
-#define _FSTRANS_API_PRIVATE
 #include <sys/fstrans.h>
 #include <sys/proc.h>
 
 #include <miscfs/specfs/specdev.h>
 
+enum fstrans_lock_type {
+       FSTRANS_SHARED,                 /* Granted while not suspending */
+       FSTRANS_EXCL                    /* Internal: exclusive lock */
+};
+
 struct fscow_handler {
        LIST_ENTRY(fscow_handler) ch_list;
        int (*ch_func)(void *, struct buf *, bool);
@@ -89,6 +93,7 @@
 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);
+static inline int _fstrans_start(struct mount *, enum fstrans_lock_type, int);
 static bool grant_lock(const enum fstrans_state, const enum fstrans_lock_type);
 static bool state_change_done(const struct mount *);
 static bool cow_state_change_done(const struct mount *);
@@ -314,8 +319,6 @@
                return true;
        if (type == FSTRANS_EXCL)
                return true;
-       if  (state == FSTRANS_SUSPENDING && type == FSTRANS_LAZY)
-               return true;
 
        return false;
 }
@@ -324,7 +327,7 @@
  * Start a transaction.  If this thread already has a transaction on this
  * file system increment the reference counter.
  */
-int
+static inline int
 _fstrans_start(struct mount *mp, enum fstrans_lock_type lock_type, int wait)
 {
        int s;
@@ -380,6 +383,22 @@
        return 0;
 }
 
+void
+fstrans_start(struct mount *mp)
+{
+       int error __diagused;
+
+       error = _fstrans_start(mp, FSTRANS_SHARED, 1);
+       KASSERT(error == 0);
+}
+
+int
+fstrans_start_nowait(struct mount *mp)
+{
+
+       return _fstrans_start(mp, FSTRANS_SHARED, 0);
+}
+
 /*
  * Finish a transaction.
  */
@@ -502,7 +521,7 @@
 
        if (old_state != new_state) {
                if (old_state == FSTRANS_NORMAL)



Home | Main Index | Thread Index | Old Index