Source-Changes-HG archive

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

[src/trunk]: src/sys/kern fix wapbl_discard() to actually discard the queued ...



details:   https://anonhg.NetBSD.org/src/rev/c5fa0286fdf6
branches:  trunk
changeset: 1009094:c5fa0286fdf6
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Sun Apr 12 17:02:52 2020 +0000

description:
fix wapbl_discard() to actually discard the queued bufs properly - need
to set BC_INVAL for them, and also need to explicitly remove them
from the BQ_LOCKED queue

fixes DIAGNOSTIC panic when force unmounting unresponsive disk device
PR kern/51178 by Michael van Elst

diffstat:

 sys/kern/vfs_wapbl.c |  12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diffs (37 lines):

diff -r 5f435eb879b3 -r c5fa0286fdf6 sys/kern/vfs_wapbl.c
--- a/sys/kern/vfs_wapbl.c      Sun Apr 12 15:55:53 2020 +0000
+++ b/sys/kern/vfs_wapbl.c      Sun Apr 12 17:02:52 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_wapbl.c,v 1.107 2020/04/12 08:51:41 jdolecek Exp $ */
+/*     $NetBSD: vfs_wapbl.c,v 1.108 2020/04/12 17:02:52 jdolecek Exp $ */
 
 /*-
  * Copyright (c) 2003, 2008, 2009 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
 #define WAPBL_INTERNAL
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_wapbl.c,v 1.107 2020/04/12 08:51:41 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_wapbl.c,v 1.108 2020/04/12 17:02:52 jdolecek Exp $");
 
 #include <sys/param.h>
 #include <sys/bitops.h>
@@ -777,12 +777,16 @@
        mutex_enter(&wl->wl_mtx);
        while ((bp = TAILQ_FIRST(&wl->wl_bufs)) != NULL) {
                if (bbusy(bp, 0, 0, &wl->wl_mtx) == 0) {
+                       KASSERT(bp->b_flags & B_LOCKED);
+                       KASSERT(bp->b_oflags & BO_DELWRI);
                        /*
+                        * Buffer is already on BQ_LOCKED queue.
                         * The buffer will be unlocked and
-                        * removed from the transaction in brelse
+                        * removed from the transaction in brelsel()
                         */
                        mutex_exit(&wl->wl_mtx);
-                       brelsel(bp, 0);
+                       bremfree(bp);
+                       brelsel(bp, BC_INVAL);
                        mutex_enter(&wl->wl_mtx);
                }
        }



Home | Main Index | Thread Index | Old Index