Playing with p9fs and bhyve I've the following crash: VNASSERT failed: locked not true at /usr/src/sys/kern/vfs_subr.c:5816 (assert_vop_elocked) 0xfffff80026d99898: type VREG state VSTATE_CONSTRUCTED op 0xffffffff827a5480 usecount 1, writecount 0, refcount 1 seqc users 0 hold count flags () flags () v_object 0xfffff8002ae61870 ref 0 pages 0 cleanbuf 0 dirtybuf 0 lock type p9fs: SHARED (count 1) panic: vnode_pager_setsize and not locked vnode: vnode is not exclusive locked but should be cpuid = 0 time = 1772222915 KDB: stack backtrace: db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe004ad75630 vpanic() at vpanic+0x136/frame 0xfffffe004ad75760 panic() at panic+0x43/frame 0xfffffe004ad757c0 assert_vop_elocked() at assert_vop_elocked+0x86/frame 0xfffffe004ad757f0 vnode_pager_setsize() at vnode_pager_setsize+0x3c/frame 0xfffffe004ad75830 p9fs_stat_vnode_dotl() at p9fs_stat_vnode_dotl+0x45/frame 0xfffffe004ad75860 p9fs_reload_stats_dotl() at p9fs_reload_stats_dotl+0xfe/frame 0xfffffe004ad758a0 p9fs_vget_common() at p9fs_vget_common+0x10b/frame 0xfffffe004ad75950 p9fs_lookup() at p9fs_lookup+0x4ad/frame 0xfffffe004ad75aa0 VOP_LOOKUP_APV() at VOP_LOOKUP_APV+0x57/frame 0xfffffe004ad75ad0 vfs_lookup() at vfs_lookup+0x5aa/frame 0xfffffe004ad75b60 namei() at namei+0x35d/frame 0xfffffe004ad75bc0 kern_statat() at kern_statat+0x13c/frame 0xfffffe004ad75d00 sys_fstatat() at sys_fstatat+0x27/frame 0xfffffe004ad75e00 amd64_syscall() at amd64_syscall+0x169/frame 0xfffffe004ad75f30 fast_syscall_common() at fast_syscall_common+0xf8/frame 0xfffffe004ad75f30 --- syscall (552, FreeBSD ELF64, fstatat), rip = 0x988ea977a0a, rsp = 0x988e7ecf6d8, rbp = 0x988e7ecf800 --- KDB: enter: panic [ thread pid 5748 tid 100113 ] Stopped at kdb_enter+0x33: movq $0,0x15ea8a2(%rip)
This is systematic issue with our networking file systems. I handled this once for nfs client, and propose to generalize the infra to reuse the same solution for other filesystems. https://reviews.freebsd.org/D55595 Note that this is not a fix for p9fs, it is only code that would allow the relatively simple fix to be written later.
D55595 + D55665 should fix this
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=2b256f00aaee4713b8e6f0e3c0f3493065f710c4 commit 2b256f00aaee4713b8e6f0e3c0f3493065f710c4 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2026-03-05 12:35:43 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2026-03-10 12:44:34 +0000 p9fs: locking improvements for p9fs_stat_vnode_dotl() If the vnode is share-locked: - Use vn_delayed_setsize() to avoid calling vnode_pager_setsize() with the vnode only shared locked. - Interlock the vnode to get exclusive mode for updating the node fields. Reciprocally, interlock the vnode in p9fs_getattr_dotl() to observe the consistent values on read. PR: 293492 Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D55665 sys/fs/p9fs/p9fs_vnops.c | 42 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-)
I initially bumped into this panic while trying to compile the devel/qt6-base port on a p9fs-mounted file system. I retried this after applying relevant patches and the process managed to finish successfully. I think this was a good stress test for p9fs, so let's close the PR as fixed. Thanks kib for working on this!
A commit in branch stable/15 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=db4caf69d73498b137070e90415c3e8b399f3544 commit db4caf69d73498b137070e90415c3e8b399f3544 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2026-03-05 12:35:43 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2026-03-15 06:58:57 +0000 p9fs: locking improvements for p9fs_stat_vnode_dotl() PR: 293492 (cherry picked from commit 2b256f00aaee4713b8e6f0e3c0f3493065f710c4) sys/fs/p9fs/p9fs_vnops.c | 42 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-)