Do not drop NFS vnode lock when performing consistency checks.
authorkib <kib@FreeBSD.org>
Sun, 20 Aug 2017 10:08:45 +0000 (10:08 +0000)
committerkib <kib@FreeBSD.org>
Sun, 20 Aug 2017 10:08:45 +0000 (10:08 +0000)
commit8b66e16967c47fa4bb4761e9f7fc639f80a06100
treea0714fd4831283c40a2b0c7a4d30cce7aac869e0
parentb8035d686eae55068f027e714749b4da24639970
Do not drop NFS vnode lock when performing consistency checks.

Currently several paths in the NFS client upgrade the shared vnode
lock to exclusive, which might cause temporal dropping of the lock.
This action appears to be fatal for nullfs mounts over NFS. If the
operation is performed over nullfs vnode, then bypassed down to NFS
VOP, and the lock is dropped, other thread might reclaim the upper
nullfs vnode.  Since on reclaim the nullfs vnode lock and NFS vnode
lock are split, the original lock state of the nullfs vnode is not
restored.  As result, VFS operations receive not locked vnode after a
VOP call.

Stop upgrading the vnode lock when we check the consistency or flush
buffers as result of detected inconsistency.  Instead, allocate a new
lockmgr lock for each NFS node, which is locked exclusive instead of
the vnode lock upgrade.  In other words, the other parallel
modification of the vnode are excluded by either vnode lock conflict
or exclusivity of the new lock when the vnode lock is shared.

Also revert r316529 because now the vnode cannot be reclaimed during
ncl_vinvalbuf().

In collaboration with: pho
Reviewed by: rmacklem
Reported and tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D12083
sys/fs/nfsclient/nfs_clbio.c
sys/fs/nfsclient/nfs_clnode.c
sys/fs/nfsclient/nfs_clport.c
sys/fs/nfsclient/nfs_clsubs.c
sys/fs/nfsclient/nfs_clvnops.c
sys/fs/nfsclient/nfsnode.h