Source-Changes-HG archive

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

[src/trunk]: src/sys/kern Clear fstrans entries whose mount is gone from the ...



details:   https://anonhg.NetBSD.org/src/rev/9eaf1a21ea38
branches:  trunk
changeset: 824789:9eaf1a21ea38
user:      hannken <hannken%NetBSD.org@localhost>
date:      Sun Jun 18 13:59:45 2017 +0000

description:
Clear fstrans entries whose mount is gone from the last fstrans_done() only.

diffstat:

 sys/kern/vfs_trans.c |  44 +++++++++++++++++++++++++++++---------------
 1 files changed, 29 insertions(+), 15 deletions(-)

diffs (91 lines):

diff -r 2ec6b6605ffd -r 9eaf1a21ea38 sys/kern/vfs_trans.c
--- a/sys/kern/vfs_trans.c      Sun Jun 18 07:50:46 2017 +0000
+++ b/sys/kern/vfs_trans.c      Sun Jun 18 13:59:45 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_trans.c,v 1.46 2017/06/04 08:05:42 hannken Exp $   */
+/*     $NetBSD: vfs_trans.c,v 1.47 2017/06/18 13:59:45 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.46 2017/06/04 08:05:42 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_trans.c,v 1.47 2017/06/18 13:59:45 hannken Exp $");
 
 /*
  * File system transaction operations.
@@ -92,6 +92,7 @@
 static inline struct mount *fstrans_normalize_mount(struct mount *);
 static void fstrans_lwp_dtor(void *);
 static void fstrans_mount_dtor(struct mount *);
+static void fstrans_clear_lwp_info(void);
 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);
@@ -227,31 +228,42 @@
 }
 
 /*
- * 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;
+}
+
+/*
+ * Retrieve the per lwp info for this mount allocating if necessary.
+ */
+static struct fstrans_lwp_info *
+fstrans_get_lwp_info(struct mount *mp, bool do_alloc)
+{
+       struct fstrans_lwp_info *fli;
+       struct fstrans_mount_info *fmi;
+
+       /*
+        * 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;
+       }
 
        if (! do_alloc)
                return NULL;
@@ -421,6 +433,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