<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.freebsd.org/bugzilla/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.freebsd.org/bugzilla/"
          
          maintainer="bugmeister@FreeBSD.org"
>

    <bug>
          <bug_id>293492</bug_id>
          
          <creation_ts>2026-02-27 17:12:02 +0000</creation_ts>
          <short_desc>p9fs: VNASSERT failed: locked not true at /usr/src/sys/kern/vfs_subr.c:5816 (assert_vop_elocked)</short_desc>
          <delta_ts>2026-03-17 00:39:10 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>Base System</product>
          <component>kern</component>
          <version>16.0-CURRENT</version>
          <rep_platform>Any</rep_platform>
          <op_sys>Any</op_sys>
          <bug_status>Closed</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>---</priority>
          <bug_severity>Affects Only Me</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Gleb Popov">arrowd</reporter>
          <assigned_to name="freebsd-fs (Nobody)">fs</assigned_to>
          <cc>ivy</cc>
    
    <cc>kib</cc>
    
    <cc>markj</cc>
    
    <cc>rcocker87</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1409227</commentid>
    <comment_count>0</comment_count>
    <who name="Gleb Popov">arrowd</who>
    <bug_when>2026-02-27 17:12:02 +0000</bug_when>
    <thetext>Playing with p9fs and bhyve I&apos;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)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1409319</commentid>
    <comment_count>1</comment_count>
    <who name="Konstantin Belousov">kib</who>
    <bug_when>2026-02-28 16:37:18 +0000</bug_when>
    <thetext>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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1409998</commentid>
    <comment_count>2</comment_count>
    <who name="Konstantin Belousov">kib</who>
    <bug_when>2026-03-05 12:39:09 +0000</bug_when>
    <thetext>D55595 + D55665 should fix this</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1410752</commentid>
    <comment_count>3</comment_count>
    <who name="">commit-hook</who>
    <bug_when>2026-03-10 12:46:28 +0000</bug_when>
    <thetext>A commit in branch main references this bug:

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

commit 2b256f00aaee4713b8e6f0e3c0f3493065f710c4
Author:     Konstantin Belousov &lt;kib@FreeBSD.org&gt;
AuthorDate: 2026-03-05 12:35:43 +0000
Commit:     Konstantin Belousov &lt;kib@FreeBSD.org&gt;
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(-)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1411104</commentid>
    <comment_count>4</comment_count>
    <who name="Gleb Popov">arrowd</who>
    <bug_when>2026-03-12 14:08:40 +0000</bug_when>
    <thetext>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&apos;s close the PR as fixed. Thanks kib for working on this!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1411800</commentid>
    <comment_count>5</comment_count>
    <who name="">commit-hook</who>
    <bug_when>2026-03-17 00:39:10 +0000</bug_when>
    <thetext>A commit in branch stable/15 references this bug:

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

commit db4caf69d73498b137070e90415c3e8b399f3544
Author:     Konstantin Belousov &lt;kib@FreeBSD.org&gt;
AuthorDate: 2026-03-05 12:35:43 +0000
Commit:     Konstantin Belousov &lt;kib@FreeBSD.org&gt;
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(-)</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>