Source-Changes-HG archive

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

[src/trunk]: src/sys/kern Handle the case where the mount is gone and its mnt...



details:   https://anonhg.NetBSD.org/src/rev/81b06ffed166
branches:  trunk
changeset: 823750:81b06ffed166
user:      hannken <hannken%NetBSD.org@localhost>
date:      Sun May 07 08:23:28 2017 +0000

description:
Handle the case where the mount is gone and its mnt_transinfo is NULL.

diffstat:

 sys/kern/vfs_trans.c |  20 +++++++++++---------
 1 files changed, 11 insertions(+), 9 deletions(-)

diffs (58 lines):

diff -r 99d3877c3e20 -r 81b06ffed166 sys/kern/vfs_trans.c
--- a/sys/kern/vfs_trans.c      Sun May 07 08:21:57 2017 +0000
+++ b/sys/kern/vfs_trans.c      Sun May 07 08:23:28 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_trans.c,v 1.43 2017/04/17 08:32:01 hannken Exp $   */
+/*     $NetBSD: vfs_trans.c,v 1.44 2017/05/07 08:23:28 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.43 2017/04/17 08:32:01 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_trans.c,v 1.44 2017/05/07 08:23:28 hannken Exp $");
 
 /*
  * File system transaction operations.
@@ -293,13 +293,16 @@
        }
 
        /*
-        * Attach the entry to the mount.
+        * Attach the entry to the mount if its mnt_transinfo is valid.
         */
        mutex_enter(&fstrans_mount_lock);
        fmi = mp->mnt_transinfo;
-       KASSERT(fmi != NULL);
-       fli->fli_mount = mp;
-       fmi->fmi_ref_cnt += 1;
+       if (__predict_true(fmi != NULL)) {
+               fli->fli_mount = mp;
+               fmi->fmi_ref_cnt += 1;
+       } else {
+               fli = NULL;
+       }
        mutex_exit(&fstrans_mount_lock);
 
        return fli;
@@ -346,7 +349,6 @@
         */
        for (lmp = mp; lmp->mnt_lower; lmp = lmp->mnt_lower) {
                fli = fstrans_get_lwp_info(lmp, true);
-               KASSERT(fli != NULL);
        }
 
        if ((fli = fstrans_get_lwp_info(lmp, true)) == NULL)
@@ -395,8 +397,8 @@
 
        if ((mp = fstrans_normalize_mount(mp)) == NULL)
                return;
-       fli = fstrans_get_lwp_info(mp, false);
-       KASSERT(fli != NULL);
+       if ((fli = fstrans_get_lwp_info(mp, false)) == NULL)
+               return;
        KASSERT(fli->fli_trans_cnt > 0);
 
        if (fli->fli_trans_cnt > 1) {



Home | Main Index | Thread Index | Old Index