Source-Changes-HG archive

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

[src/netbsd-8]: src/sys/kern Pull up following revision(s) (requested by hann...



details:   https://anonhg.NetBSD.org/src/rev/ef6705d7d7e2
branches:  netbsd-8
changeset: 850750:ef6705d7d7e2
user:      snj <snj%NetBSD.org@localhost>
date:      Wed Jun 21 18:24:26 2017 +0000

description:
Pull up following revision(s) (requested by hannken in ticket #54):
        sys/kern/vfs_trans.c: 1.47, 1.48
Clear fstrans entries whose mount is gone from the last fstrans_done() only.
--
Make the fast path of fstrans_get_lwp_info() "static inline".

diffstat:

 sys/kern/vfs_trans.c |  61 ++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 43 insertions(+), 18 deletions(-)

diffs (121 lines):

diff -r 6f056533c74a -r ef6705d7d7e2 sys/kern/vfs_trans.c
--- a/sys/kern/vfs_trans.c      Wed Jun 21 18:18:55 2017 +0000
+++ b/sys/kern/vfs_trans.c      Wed Jun 21 18:24:26 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_trans.c,v 1.45.2.1 2017/06/04 20:35:01 bouyer Exp $        */
+/*     $NetBSD: vfs_trans.c,v 1.45.2.2 2017/06/21 18:24:26 snj 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.1 2017/06/04 20:35:01 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_trans.c,v 1.45.2.2 2017/06/21 18:24:26 snj Exp $");
 
 /*
  * File system transaction operations.
@@ -92,7 +92,10 @@
 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);
+static void fstrans_clear_lwp_info(void);
+static inline struct fstrans_lwp_info *
+    fstrans_get_lwp_info(struct mount *, bool);
+static struct fstrans_lwp_info *fstrans_alloc_lwp_info(struct mount *);
 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 *);
@@ -227,39 +230,40 @@
 }
 
 /*
- * Retrieve the per lwp info for this mount allocating if necessary.
+ * Clear mount entries whose mount is gone.
  */
-static struct fstrans_lwp_info *
-fstrans_get_lwp_info(struct mount *mp, bool do_alloc)
+static void
+fstrans_clear_lwp_info(void)
 {
-       struct fstrans_lwp_info *fli, *res;
-       struct fstrans_mount_info *fmi;
+       struct fstrans_lwp_info *fli;
 
        /*
-        * Scan our list for a match clearing entries whose mount is gone.
+        * Scan our list clearing entries whose mount is gone.
         */
-       res = NULL;
        for (fli = lwp_getspecific(lwp_data_key); fli; fli = fli->fli_succ) {
-               if (fli->fli_mount == mp) {
-                       KASSERT(res == NULL);
-                       res = fli;
-               } else if (fli->fli_mount != NULL &&
+               if (fli->fli_mount != NULL &&
                    (fli->fli_mount->mnt_iflag & IMNT_GONE) != 0 &&
                    fli->fli_trans_cnt == 0 && fli->fli_cow_cnt == 0) {
                        fstrans_mount_dtor(fli->fli_mount);
                        fli->fli_mount = NULL;
                }
        }
-       if (__predict_true(res != NULL))
-               return res;
+}
 
-       if (! do_alloc)
-               return NULL;
+/*
+ * Allocate and return per lwp info for this mount.
+ */
+static struct fstrans_lwp_info *
+fstrans_alloc_lwp_info(struct mount *mp)
+{
+       struct fstrans_lwp_info *fli;
+       struct fstrans_mount_info *fmi;
 
        /*
         * Try to reuse a cleared entry or allocate a new one.
         */
        for (fli = lwp_getspecific(lwp_data_key); fli; fli = fli->fli_succ) {
+               KASSERT(fli->fli_mount != mp);
                if (fli->fli_mount == NULL) {
                        KASSERT(fli->fli_trans_cnt == 0);
                        KASSERT(fli->fli_cow_cnt == 0);
@@ -309,6 +313,25 @@
 }
 
 /*
+ * Retrieve the per lwp info for this mount allocating if necessary.
+ */
+static inline struct fstrans_lwp_info *
+fstrans_get_lwp_info(struct mount *mp, bool do_alloc)
+{
+       struct fstrans_lwp_info *fli;
+
+       /*
+        * Scan our list for a match.
+        */
+       for (fli = lwp_getspecific(lwp_data_key); fli; fli = fli->fli_succ) {
+               if (fli->fli_mount == mp)
+                       return fli;
+       }
+
+       return (do_alloc ? fstrans_alloc_lwp_info(mp) : NULL);
+}
+
+/*
  * Check if this lock type is granted at this state.
  */
 static bool
@@ -421,6 +444,8 @@
                return;
        }
 
+       fstrans_clear_lwp_info();
+
        s = pserialize_read_enter();
        fmi = mp->mnt_transinfo;
        if (__predict_true(fmi->fmi_state == FSTRANS_NORMAL)) {



Home | Main Index | Thread Index | Old Index