HomeFreeBSD

pbuf_ctor(): lock the buffer with LK_NOWAIT

Description

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

Details

Provenance
rewAuthored on Feb 7 2022, 7:05 PM
Reviewer
kib
Differential Revision
D34183: pbuf_ctor(): lock the buffer with LK_NOWAIT
Parents
rG379797d4b486: usb(4): Belatedly add a PCI device ID for AMD Bolton chipset
Branches
Unknown
Tags
Unknown