From 61f45ca2da55b304f28ccd643ed0f4650b8c304e Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Wed, 16 Feb 2022 17:30:17 +0200 Subject: [PATCH] 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 Approved by: re (gjb) Sponsored by: The FreeBSD Foundation (cherry picked from commit 1fb00c8f1060e18fed621f13d31db7b336d2267e) (cherry picked from commit dd54e44a279fab567374d2eec9dd9cd6d04b7a43) --- 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; -- 2.39.5