Source-Changes-HG archive

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

[src/trunk]: src/sys/ufs/lfs Don't lfs_writer_enter while holding v_interlock.



details:   https://anonhg.NetBSD.org/src/rev/7cef3af816c7
branches:  trunk
changeset: 745131:7cef3af816c7
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Feb 23 08:40:27 2020 +0000

description:
Don't lfs_writer_enter while holding v_interlock.

There's no need to lfs_writer_enter at all here, as far as I can see.
lfs_flush_fs will do it for us.

diffstat:

 sys/ufs/lfs/lfs_pages.c |  27 ++++++++++++++-------------
 1 files changed, 14 insertions(+), 13 deletions(-)

diffs (60 lines):

diff -r 27e8cacf66e8 -r 7cef3af816c7 sys/ufs/lfs/lfs_pages.c
--- a/sys/ufs/lfs/lfs_pages.c   Sun Feb 23 08:40:19 2020 +0000
+++ b/sys/ufs/lfs/lfs_pages.c   Sun Feb 23 08:40:27 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lfs_pages.c,v 1.20 2020/01/15 17:55:44 ad Exp $        */
+/*     $NetBSD: lfs_pages.c,v 1.21 2020/02/23 08:40:27 riastradh Exp $ */
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003, 2019 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lfs_pages.c,v 1.20 2020/01/15 17:55:44 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_pages.c,v 1.21 2020/02/23 08:40:27 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -671,29 +671,30 @@
            (vp->v_uflag & VU_DIROP)) {
                DLOG((DLOG_PAGE, "lfs_putpages: flushing VU_DIROP\n"));
 
-               lfs_writer_enter(fs, "ppdirop");
+               /*
+                * NB: lfs_flush_fs can recursively call lfs_putpages,
+                * but it won't reach this branch because it passes
+                * PGO_LOCKED.
+                */
 
-               /* Note if we hold the vnode locked */
-               if (VOP_ISLOCKED(vp) == LK_EXCLUSIVE)
-               {
-                   DLOG((DLOG_PAGE, "lfs_putpages: dirop inode already locked\n"));
-               } else {
-                   DLOG((DLOG_PAGE, "lfs_putpages: dirop inode not locked\n"));
-               }
                mutex_exit(vp->v_interlock);
-
                mutex_enter(&lfs_lock);
                lfs_flush_fs(fs, sync ? SEGM_SYNC : 0);
                mutex_exit(&lfs_lock);
-
                mutex_enter(vp->v_interlock);
-               lfs_writer_leave(fs);
 
                /*
                 * The flush will have cleaned out this vnode as well,
                 *  no need to do more to it.
                 *  XXX then why are we falling through and continuing?
                 */
+
+               /*
+                * XXX State may have changed while we dropped the
+                * lock; start over just in case.  The above comment
+                * suggests this should maybe instead be goto out.
+                */
+               goto retry;
        }
 
        /*



Home | Main Index | Thread Index | Old Index