Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 14 Mar 2022 14:11:19 GMT
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: dd54e44a279f - stable/13 - buf_alloc(): Stop using LK_NOWAIT, use LK_NOWITNESS
Message-ID:  <202203141411.22EEBJZR008877@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=dd54e44a279fab567374d2eec9dd9cd6d04b7a43

commit dd54e44a279fab567374d2eec9dd9cd6d04b7a43
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2022-02-16 15:30:17 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2022-03-14 14:10:23 +0000

    buf_alloc(): Stop using LK_NOWAIT, use LK_NOWITNESS
    
    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
    Sponsored by:   The FreeBSD Foundation
    
    (cherry picked from commit 1fb00c8f1060e18fed621f13d31db7b336d2267e)
---
 sys/kern/vfs_bio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c
index 3798d9137d3b..c23f6c35e136 100644
--- a/sys/kern/vfs_bio.c
+++ b/sys/kern/vfs_bio.c
@@ -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;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202203141411.22EEBJZR008877>