Thread View: muc.lists.freebsd.current
4 messages
4 total messages
Started by Rick Macklem
Sun, 29 Nov 2026 16:57
vnode locks vs write backs in the NFS client
Author: Rick Macklem
Date: Sun, 29 Nov 2026 16:57
Date: Sun, 29 Nov 2026 16:57
48 lines
7152 bytes
7152 bytes
Hi, During testing of the RDMA code being done by the NVidia folk, they got a panic caused by VOP_STRATEGY() being called with an unlocked vnode. They had delegations enabled (and were accessing the same file from multiple mounts) along with WITNESS and INVARIANTS. The panic is not surprising, since the nfscl thread tries to do write backs without the vnode lock. This is not so much a bug as a faeture, since the NFS client has done write backs with the buffer lock held, but no vnode lock, since the code was written decades ago. (Note that LK_EXCLOTHER is a NFS related "hack", but vop_asser_locked() does not consider that case as locked.) I'm guessing people haven't been reporting this for.. - Running production kernels without DEBUG_VFS_LOCKS, INVARIANTS, WITNESS. - Not enabling delegations (for this case). I do believe that the current code is safe, in the sense that the buffer lock is sufficient to maintain consistency during write backs to the NFS server. (A "umount -N" handles this stuff ok. Not sure about "umount -f", but "umount -f' is mostly useless for the NFS client, anyhow.) So, what can we do?? I think the best approach might be to convert the NFS client to using shared vnode locks for writing (like ZFS currently does). That way, the NFS client can acquire the shared vnode lock for write-backs when other threads have the vnode shared locked for writing. --> However, this could take a while to implement. In the meantime, I think we just accept that debug kernels won't work correctly, at least when delegations are enabled. Other ideas? rick -- Posted automagically by a mail2news gateway at muc.de e.V. Please direct questions, flames, donations, etc. to news-admin@muc.de
Re: vnode locks vs write backs in the NFS client
Author: Konstantin Belousov
Date: Sun, 29 Nov 2026 17:27
Date: Sun, 29 Nov 2026 17:27
51 lines
5165 bytes
5165 bytes
On Sun, Nov 29, 2026 at 09:57:57AM -0700, Rick Macklem wrote: > Hi, > > During testing of the RDMA code being done by the NVidia folk, > they got a panic caused by VOP_STRATEGY() being called with > an unlocked vnode. > > They had delegations enabled (and were accessing the same > file from multiple mounts) along with WITNESS and INVARIANTS. > > The panic is not surprising, since the nfscl thread tries to do > write backs without the vnode lock. This is not so much a bug > as a faeture, since the NFS client has done write backs with > the buffer lock held, but no vnode lock, since the code was > written decades ago. (Note that LK_EXCLOTHER is a NFS > related "hack", but vop_asser_locked() does not consider > that case as locked.) > > I'm guessing people haven't been reporting this for.. > - Running production kernels without DEBUG_VFS_LOCKS, > INVARIANTS, WITNESS. > - Not enabling delegations (for this case). > > I do believe that the current code is safe, in the sense that > the buffer lock is sufficient to maintain consistency during > write backs to the NFS server. (A "umount -N" handles this > stuff ok. Not sure about "umount -f", but "umount -f' is mostly > useless for the NFS client, anyhow.) > > So, what can we do?? > > I think the best approach might be to convert the NFS client to > using shared vnode locks for writing (like ZFS currently > does). That way, the NFS client can acquire the shared > vnode lock for write-backs when other threads have the > vnode shared locked for writing. > --> However, this could take a while to implement. > > In the meantime, I think we just accept that debug kernels > won't work correctly, at least when delegations are enabled. > > Other ideas? Or add VOP_STRATEGY_UNLOCKED(), changing all implementations in fses to provide VOP_STRATEGY_UNLOCKED(). VOP_STRATEGY() would simply redirect to VOP_STRATEGY_UNLOCKED(). -- Posted automagically by a mail2news gateway at muc.de e.V. Please direct questions, flames, donations, etc. to news-admin@muc.de
Re: vnode locks vs write backs in the NFS client
Author: Rick Macklem
Date: Sun, 29 Nov 2026 20:45
Date: Sun, 29 Nov 2026 20:45
62 lines
8269 bytes
8269 bytes
On Sun, Nov 29, 2026 at 10:28 AM Konstantin Belousov <kib@freebsd.org> wrote: > > On Sun, Nov 29, 2026 at 09:57:57AM -0700, Rick Macklem wrote: > > Hi, > > > > During testing of the RDMA code being done by the NVidia folk, > > they got a panic caused by VOP_STRATEGY() being called with > > an unlocked vnode. > > > > They had delegations enabled (and were accessing the same > > file from multiple mounts) along with WITNESS and INVARIANTS. > > > > The panic is not surprising, since the nfscl thread tries to do > > write backs without the vnode lock. This is not so much a bug > > as a faeture, since the NFS client has done write backs with > > the buffer lock held, but no vnode lock, since the code was > > written decades ago. (Note that LK_EXCLOTHER is a NFS > > related "hack", but vop_asser_locked() does not consider > > that case as locked.) > > > > I'm guessing people haven't been reporting this for.. > > - Running production kernels without DEBUG_VFS_LOCKS, > > INVARIANTS, WITNESS. > > - Not enabling delegations (for this case). > > > > I do believe that the current code is safe, in the sense that > > the buffer lock is sufficient to maintain consistency during > > write backs to the NFS server. (A "umount -N" handles this > > stuff ok. Not sure about "umount -f", but "umount -f' is mostly > > useless for the NFS client, anyhow.) > > > > So, what can we do?? > > > > I think the best approach might be to convert the NFS client to > > using shared vnode locks for writing (like ZFS currently > > does). That way, the NFS client can acquire the shared > > vnode lock for write-backs when other threads have the > > vnode shared locked for writing. > > --> However, this could take a while to implement. > > > > In the meantime, I think we just accept that debug kernels > > won't work correctly, at least when delegations are enabled. > > > > Other ideas? > > Or add VOP_STRATEGY_UNLOCKED(), changing all implementations in fses to > provide VOP_STRATEGY_UNLOCKED(). VOP_STRATEGY() would simply redirect > to VOP_STRATEGY_UNLOCKED(). > Another possibility is to re-write ncl_flush() so that it doesn't do bwrite() and just calls the NFS code to do the write. My hesitation about doing this would be a need to track any changes (b_flags, etc.) that bwrite() handles in the NFS code. rick -- Posted automagically by a mail2news gateway at muc.de e.V. Please direct questions, flames, donations, etc. to news-admin@muc.de
Re: vnode locks vs write backs in the NFS client
Author: Rick Macklem
Date: Sun, 29 Nov 2026 22:20
Date: Sun, 29 Nov 2026 22:20
66 lines
8405 bytes
8405 bytes
On Sun, Nov 29, 2026 at 10:28 AM Konstantin Belousov <kib@freebsd.org> wrote: > > On Sun, Nov 29, 2026 at 09:57:57AM -0700, Rick Macklem wrote: > > Hi, > > > > During testing of the RDMA code being done by the NVidia folk, > > they got a panic caused by VOP_STRATEGY() being called with > > an unlocked vnode. > > > > They had delegations enabled (and were accessing the same > > file from multiple mounts) along with WITNESS and INVARIANTS. > > > > The panic is not surprising, since the nfscl thread tries to do > > write backs without the vnode lock. This is not so much a bug > > as a faeture, since the NFS client has done write backs with > > the buffer lock held, but no vnode lock, since the code was > > written decades ago. (Note that LK_EXCLOTHER is a NFS > > related "hack", but vop_asser_locked() does not consider > > that case as locked.) > > > > I'm guessing people haven't been reporting this for.. > > - Running production kernels without DEBUG_VFS_LOCKS, > > INVARIANTS, WITNESS. > > - Not enabling delegations (for this case). > > > > I do believe that the current code is safe, in the sense that > > the buffer lock is sufficient to maintain consistency during > > write backs to the NFS server. (A "umount -N" handles this > > stuff ok. Not sure about "umount -f", but "umount -f' is mostly > > useless for the NFS client, anyhow.) > > > > So, what can we do?? > > > > I think the best approach might be to convert the NFS client to > > using shared vnode locks for writing (like ZFS currently > > does). That way, the NFS client can acquire the shared > > vnode lock for write-backs when other threads have the > > vnode shared locked for writing. > > --> However, this could take a while to implement. > > > > In the meantime, I think we just accept that debug kernels > > won't work correctly, at least when delegations are enabled. > > > > Other ideas? > > Or add VOP_STRATEGY_UNLOCKED(), changing all implementations in fses to > provide VOP_STRATEGY_UNLOCKED(). VOP_STRATEGY() would simply redirect > to VOP_STRATEGY_UNLOCKED(). > This seems simple enough, but maybe a bit of an overkill to have both VOP_STRATEGY() and VOP_STRATEGY_UNLOCKED(). You guys probably won't like this hokey variant, but what about just dropping the requirement for a locked vnode from VOP_STRATEGY() and then adding an ASSERT_VOP_LOCKED() to the vop_strategy() for file systems that need to have it locked. rick -- Posted automagically by a mail2news gateway at muc.de e.V. Please direct questions, flames, donations, etc. to news-admin@muc.de
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads