]> xenbits.xensource.com Git - people/royger/freebsd.git/commitdiff
buf_alloc(): Stop using LK_NOWAIT, use LK_NOWITNESS
authorKonstantin Belousov <kib@FreeBSD.org>
Wed, 16 Feb 2022 15:30:17 +0000 (17:30 +0200)
committerMark Johnston <markj@FreeBSD.org>
Mon, 14 Mar 2022 15:47:12 +0000 (11:47 -0400)
Despite the buffer taken from cache or free list, it still can be
locked, due to 'lockless lookup' in getblkx() potentially operating on
the freed buffers.  The lock is transient, but prevents the use of
LK_NOWAIT there for the goal of neutralizing WITNESS.

Just use LK_NOWITNESS.

Reported and tested by: pho
Approved by: re (gjb)
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 1fb00c8f1060e18fed621f13d31db7b336d2267e)
(cherry picked from commit dd54e44a279fab567374d2eec9dd9cd6d04b7a43)

sys/kern/vfs_bio.c

index 3798d9137d3bafc568e0f10ea880ebe34e6ba0b0..c23f6c35e136e802320070bc2b7eedfe5693d5f1 100644 (file)
@@ -1709,7 +1709,7 @@ buf_alloc(struct bufdomain *bd)
        if (freebufs == bd->bd_lofreebuffers)
                bufspace_daemon_wakeup(bd);
 
-       error = BUF_LOCK(bp, LK_EXCLUSIVE | LK_NOWAIT, NULL);
+       error = BUF_LOCK(bp, LK_EXCLUSIVE | LK_NOWITNESS, NULL);
        KASSERT(error == 0, ("%s: BUF_LOCK on free buf %p: %d.", __func__, bp,
            error));
        (void)error;