[Bug 266236] ZFS NFS : .zfs/snapshot : Stale file handle

From: <bugzilla-noreply_at_freebsd.org>
Date: Thu, 06 Oct 2022 16:54:22 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=266236

Mark Johnston <markj@FreeBSD.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |freqlabs@FreeBSD.org,
                   |                            |markj@FreeBSD.org,
                   |                            |mav@FreeBSD.org

--- Comment #13 from Mark Johnston <markj@FreeBSD.org> ---
Reverting https://github.com/openzfs/zfs/pull/12905 does fix the problem for
me.  There is an additional bug there in that there is a missing zfs_exit()
call before the return, which causes a lock leak.

In my case, we end up with fid_gen == 4 and setgen == 0.  I don't understand
where that generation number comes from. zfs_fid() sets it from a ZPL
attribute, and "stat -f '%v'" on the snapshot dir prints 0.  

To repro, I just enabled an NFSv3 server in a VM:

mountd_enable="YES"                                                             
mountd_flags="-n"                                                               
nfs_server_enable="YES"                                                         
rpc_locked_enable="YES"                                                         
rpc_statd_enable="YES"                                                          
rpcbind_enable="YES"
zfs_enable="YES"

Create a dataset with a snapshot and export it:

# zfs snapshot test@1
# zfs set sharenfs=on test

Mount it locally and check .zfs/snapshot:

# mount localhost:/test /mnt
# ls /mnt/.zfs/snapshot
1
# ls /mnt/.zfs/snapshot/1
snapdir fid: fid_gen (4) and setgen (0)
snapdir fid: fid_gen (4) and setgen (0)
snapdir fid: fid_gen (4) and setgen (0)
ls: /mnt/.zfs/snapshot/1: Stale NFS file handle

-- 
You are receiving this mail because:
You are the assignee for the bug.