vnode locks vs write backs in the NFS client

From: Rick Macklem <rick.macklem_at_gmail.com>
Date: Sun, 29 Nov 2026 16:57:57 UTC
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