nullfs: lock the vnode with LK_SHARED in null_vptocnp

null_nodeget which follows almost always finds the target vnode in the hash,
avoiding insmntque1 altogether. Should it be needed, it already checks if the
lock needs to be upgraded.

Reviewed by:	kib
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D20244
This commit is contained in:
mjg 2019-08-21 23:24:40 +00:00
parent e0205845c3
commit 3075c81a9f
2 changed files with 1 additions and 8 deletions

@ -222,9 +222,6 @@ null_nodeget(mp, lowervp, vpp)
* provide ready to use vnode.
*/
if (VOP_ISLOCKED(lowervp) != LK_EXCLUSIVE) {
KASSERT((MOUNTTONULLMOUNT(mp)->nullm_flags & NULLM_CACHE) != 0,
("lowervp %p is not excl locked and cache is disabled",
lowervp));
vn_lock(lowervp, LK_UPGRADE | LK_RETRY);
if ((lowervp->v_iflag & VI_DOOMED) != 0) {
vput(lowervp);

@ -893,11 +893,7 @@ null_vptocnp(struct vop_vptocnp_args *ap)
return (ENOENT);
}
/*
* Exclusive lock is required by insmntque1 call in
* null_nodeget()
*/
error = vn_lock(ldvp, LK_EXCLUSIVE);
error = vn_lock(ldvp, LK_SHARED);
if (error != 0) {
vrele(ldvp);
vn_lock(vp, locked | LK_RETRY);