diff --git a/sys/fs/nfsclient/nfs_clvnops.c b/sys/fs/nfsclient/nfs_clvnops.c --- a/sys/fs/nfsclient/nfs_clvnops.c +++ b/sys/fs/nfsclient/nfs_clvnops.c @@ -4111,14 +4111,6 @@ int attrflag, content, error, ret; bool eof = false; /* shut up compiler. */ - if (vp->v_type != VREG) - return (ENOTTY); - nmp = VFSTONFS(vp->v_mount); - if (!NFSHASNFSV4(nmp) || nmp->nm_minorvers < NFSV42_MINORVERSION) { - error = vop_stdioctl(ap); - return (error); - } - /* Do the actual NFSv4.2 RPC. */ switch (ap->a_command) { case FIOSEEKDATA: @@ -4134,6 +4126,18 @@ error = vn_lock(vp, LK_SHARED); if (error != 0) return (EBADF); + + if (vp->v_type != VREG) { + VOP_UNLOCK(vp); + return (ENOTTY); + } + nmp = VFSTONFS(vp->v_mount); + if (!NFSHASNFSV4(nmp) || nmp->nm_minorvers < NFSV42_MINORVERSION) { + VOP_UNLOCK(vp); + error = vop_stdioctl(ap); + return (error); + } + attrflag = 0; if (*((off_t *)ap->a_data) >= VTONFS(vp)->n_size) error = ENXIO;