zfs: Fix a pair of bugs in zfs_fhtovp()

This cherry-picks upstream ed566bf1cd

    - Add a zfs_exit() call in an error path, otherwise a lock is
      leaked.
    - Remove the fid_gen > 1 check.  That appears to be Linux-specific:
      zfsctl_snapdir_fid() sets fid_gen to 0 or 1 depending on whether
      the snapshot directory is mounted.  On FreeBSD it fails, making
      snapshot dirs inaccessible via NFS.

Approved by:	so
PR:		266236
Security:	FreeBSD-EN-22:24.zfs

(cherry picked from commit 6fe0a6c80a)
(cherry picked from commit 562c9ac58c)
This commit is contained in:
Mark Johnston 2022-10-24 11:55:48 -04:00
parent 752f813d6c
commit 7ab877cb3f

View File

@ -1845,7 +1845,8 @@ zfs_fhtovp(vfs_t *vfsp, fid_t *fidp, int flags, vnode_t **vpp)
return (SET_ERROR(EINVAL));
}
if (fidp->fid_len == LONG_FID_LEN && (fid_gen > 1 || setgen != 0)) {
if (fidp->fid_len == LONG_FID_LEN && setgen != 0) {
ZFS_EXIT(zfsvfs);
dprintf("snapdir fid: fid_gen (%llu) and setgen (%llu)\n",
(u_longlong_t)fid_gen, (u_longlong_t)setgen);
return (SET_ERROR(EINVAL));