Source-Changes-HG archive

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

[src/trunk]: src Operations fstrans_start() and fstrans_start_nowait() now al...



details:   https://anonhg.NetBSD.org/src/rev/cfdf27645847
branches:  trunk
changeset: 354108:cfdf27645847
user:      hannken <hannken%NetBSD.org@localhost>
date:      Sun Jun 04 08:05:41 2017 +0000

description:
Operations fstrans_start() and fstrans_start_nowait() now always
use FSTRANS_SHARED as lock type so remove the lock type argument.

File system state FSTRANS_SUSPENDING is now unused so remove it.

Regen vnode_if files.

Ride 8.99.1 less than a hour ago.

diffstat:

 share/man/man9/fstrans.9                |  63 ++++++--------------------------
 sys/kern/vfs_mount.c                    |   8 ++--
 sys/kern/vfs_trans.c                    |  39 +++++++++++++------
 sys/kern/vfs_vnode.c                    |  10 ++--
 sys/kern/vnode_if.c                     |  10 ++--
 sys/miscfs/genfs/genfs_io.c             |  10 ++--
 sys/miscfs/genfs/layer_vnops.c          |   6 +-
 sys/rump/include/rump/rumpvnode_if.h    |   4 +-
 sys/rump/librump/rumpkern/emul.c        |  18 ++++++--
 sys/rump/librump/rumpvfs/rumpvnode_if.c |   6 +-
 sys/sys/fstrans.h                       |  17 +-------
 sys/sys/vnode_if.h                      |   4 +-
 sys/ufs/lfs/lfs_pages.c                 |   8 ++--
 13 files changed, 87 insertions(+), 116 deletions(-)

diffs (truncated from 632 to 300 lines):

diff -r c0c6dafd2ac9 -r cfdf27645847 share/man/man9/fstrans.9
--- a/share/man/man9/fstrans.9  Sun Jun 04 08:03:26 2017 +0000
+++ b/share/man/man9/fstrans.9  Sun Jun 04 08:05:41 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.25 2017/06/04 08:05:41 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 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 c0c6dafd2ac9 -r cfdf27645847 sys/kern/vfs_mount.c
--- a/sys/kern/vfs_mount.c      Sun Jun 04 08:03:26 2017 +0000
+++ b/sys/kern/vfs_mount.c      Sun Jun 04 08:05:41 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.66 2017/06/04 08:05:42 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.65 2017/06/01 02:45:13 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.66 2017/06/04 08:05:42 hannken 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 c0c6dafd2ac9 -r cfdf27645847 sys/kern/vfs_trans.c
--- a/sys/kern/vfs_trans.c      Sun Jun 04 08:03:26 2017 +0000
+++ b/sys/kern/vfs_trans.c      Sun Jun 04 08:05:41 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.46 2017/06/04 08:05:42 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.45 2017/05/07 08:24:20 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_trans.c,v 1.46 2017/06/04 08:05:42 hannken 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)
-                       fstrans_start(mp, FSTRANS_EXCL);
+                       _fstrans_start(mp, FSTRANS_EXCL, 1);
                if (new_state == FSTRANS_NORMAL)
                        fstrans_done(mp);
        }
@@ -805,9 +824,6 @@
                        printf(" -");
                } else {
                        switch (fli->fli_lock_type) {
-                       case FSTRANS_LAZY:
-                               printf(" lazy");
-                               break;
                        case FSTRANS_SHARED:
                                printf(" shared");
                                break;
@@ -842,9 +858,6 @@
        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 c0c6dafd2ac9 -r cfdf27645847 sys/kern/vfs_vnode.c
--- a/sys/kern/vfs_vnode.c      Sun Jun 04 08:03:26 2017 +0000
+++ b/sys/kern/vfs_vnode.c      Sun Jun 04 08:05:41 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_vnode.c,v 1.95 2017/06/04 08:02:26 hannken Exp $   */
+/*     $NetBSD: vfs_vnode.c,v 1.96 2017/06/04 08:05:42 hannken Exp $   */
 
 /*-
  * Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
@@ -156,7 +156,7 @@



Home | Main Index | Thread Index | Old Index