git: c9e023541aef - main - pbuf_ctor(): lock the buffer with LK_NOWAIT
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 07 Feb 2022 19:07:50 UTC
The branch main has been updated by rew:
URL: https://cgit.FreeBSD.org/src/commit/?id=c9e023541aefdabf0b602e1fd62f5e21a6f8ffa2
commit c9e023541aefdabf0b602e1fd62f5e21a6f8ffa2
Author: Robert Wing <rew@FreeBSD.org>
AuthorDate: 2022-02-07 19:05:20 +0000
Commit: Robert Wing <rew@FreeBSD.org>
CommitDate: 2022-02-07 19:05:20 +0000
pbuf_ctor(): lock the buffer with LK_NOWAIT
This LOR happens when reading from a file backed MD device:
lock order reversal:
1st 0xfffffe00431eaac0 pbufwait (pbufwait, lockmgr) @ /cobra/src/sys/vm/vm_pager.c:471
2nd 0xfffff80003f17930 ufs (ufs, lockmgr) @ /cobra/src/sys/dev/md/md.c:977
lock order pbufwait -> ufs attempted at:
#0 0xffffffff80c78ead at witness_checkorder+0xbdd
#1 0xffffffff80bd6a52 at lockmgr_lock_flags+0x182
#2 0xffffffff80f52d5c at ffs_lock+0x6c
#3 0xffffffff80d0f3f4 at _vn_lock+0x54
#4 0xffffffff80708629 at mdstart_vnode+0x499
#5 0xffffffff807060ec at md_kthread+0x20c
#6 0xffffffff80bbfcd0 at fork_exit+0x80
#7 0xffffffff810b809e at fork_trampoline+0xe
This LOR was previously blessed by witness before commit 531f8cfea06b
("Use dedicated lock name for pbufs").
Instead of blessing ufs and pbufwait, use LK_NOWAIT to prevent recording
the lock order. LK_NOWAIT will be a nop here as the lock is dropped in
pbuf_dtor(). The takes the same approach as 5875b94c7493 ("buf_alloc():
lock the buffer with LK_NOWAIT").
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D34183
---
sys/vm/vm_pager.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sys/vm/vm_pager.c b/sys/vm/vm_pager.c
index 7dba1c45143d..9b66964b8d8f 100644
--- a/sys/vm/vm_pager.c
+++ b/sys/vm/vm_pager.c
@@ -467,7 +467,7 @@ pbuf_ctor(void *mem, int size, void *arg, int flags)
bp->b_ioflags = 0;
bp->b_iodone = NULL;
bp->b_error = 0;
- BUF_LOCK(bp, LK_EXCLUSIVE, NULL);
+ BUF_LOCK(bp, LK_EXCLUSIVE | LK_NOWAIT, NULL);
return (0);
}