I came across 15805 when looking for people reporting similar issues, and I think this bug is very related. I did try running 4.24.0rc1 to see if the patches for that would help here and they do not. It used to be samba would display the contents of the <dataset root>/.zfs/snapshots/<snapshot name> directory when you navigated to that path on a share. Now the directories are shown as empty. I'm not really sure when exactly this started, but we noticed it after we moved to el9 from el7. It's rare for our users to view snapshots in this manner, usually they use the 'previous versions' tab in properties to view snapshots, which still works, but people using linux clients don't have that functionality. When you navigate to a snapshot directory in a shell on the machine with the dataset the underlying snapshot is automatically mounted at that path. I assume that samba is no longer triggering the automount behavior just like in 15805. If I understand the test program and patch series in 15805 correctly the issue with autofs is being worked around by handling autofs as a special case and retrying to open the path the old way (without O_PATH). If I adapt the test program from 15805 to this directory structure I'm able to reproduce the issue, and if I add a case to match the zfs magic number entries in the snapshot enumerate as expected. However I'm not sure if that's a reasonable way to approach the problem.
Do you want to augment the (sbuf.f_type == AUTOFS_SUPER_MAGIC) line with some value that your file system sets? I don't see anything for ZFS in /usr/include/linux/magic.h.
That is probably the easiest way to go about it. However in the case of ZFS I'm not really sure the best way to get the magic number. ZFS_SUPER_MAGIC is 0x2fc12fc1 and is defined in the ZFS source at include/sys/fs/zfs.h, but requiring the ZFS source won't help people on distributions that package samba but not OpenZFS. ZFS_SUPER_MAGIC has not changed values since it was defined (as far as I can tell).
Created attachment 18822 [details] simple patch to fix zfs automounting of snapshots
If you think that'd be acceptable I can work out how to submit it, it does fix my issue. I don't know how folks would feel about just throwing the ZFS magic number in there.
Created attachment 18824 [details] Patch in git-am format Attached find a patch in git-format. We'd also want a developer declaration according to https://www.samba.org/samba/devel/copyright-policy.html One caveat though: Is the ZFS_MAGIC value copyrightable, i.e. does that number fall under the CDDL, which is incompatible with the GPL? I don't know if we can even include that. Can others chime in here?
I've reached out on the OpenZFS slack as well for input regarding the license question.
The general vibe of responses I've gotten on the OpenZFS slack is 'it's probably fine'. The value of ZFS_SUPER_MAGIC is just a number and probably not copyrightable, but even if it were this use of it would likely be fair use. I am not a lawyer, nor are the folks that responded there.