Skip to content

Draft: s3:modules: Add vfs_autofs module to always trigger automounts

TL;DR; If a share contains an untriggered automount point and autofs's browse_mode is enabled, an attempt to open the directory fails with NT_STATUS_OBJECT_NAME_NOT_FOUND.

Consider the following scenario:

# grep -v "^#" /etc/autofs.conf
[ autofs ]
timeout = 30
browse_mode = yes

# cat /etc/auto.master
/data/zzz    /etc/auto.zzz

#cat /etc/auto.zzz
testdir1     localhost:/export/data/testdir1

And a samba share defined as:

[zzz]
        path = /data/zzz

Then:

# smbclient //localhost/zzz -U...
Try "help" to get a list of possible commands.
smb: \> ls
  .                                   D        0  Tue Sep 26 17:37:32 2023
  ..                                  D        0  Tue Sep 26 17:37:32 2023
  testdir1                            D        0  Tue Sep 26 17:37:32 2023

                20480 blocks of size 1024. 0 blocks available
smb: \> cd testdir1
smb: \testdir1\> ls
NT_STATUS_OBJECT_NAME_NOT_FOUND listing \testdir1\*
smb: \testdir1\>

The trace is:

openat(24, "testdir1", O_RDONLY|O_PATH) gives 32
...
fstat(32, ...) which says this is a directory
...
openat(AT_FDCWD, "/proc/self/fd/32", O_RDONLY|O_DIRECTORY) failed with ENOENT.

I wrote a simple test program reproducing steps and /proc/self/fd/xx does exists, so the ENOENT error might be returned because it is an untriggered automount point. The reason why autofs does not mount it on the first openat(24, "testdir1", O_RDONLY|O_PATH) call is documented in man 2 openat:

If pathname refers to an automount point that has not yet been triggered, so no 
other filesystem is mounted on it, then the call returns a file descriptor referring 
to the  automount  directory without triggering a mount.  fstatfs(2) can then be used to 
determine if it is, in fact, an untriggered automount point (.f_type == AUTOFS_SUPER_MAGIC).

@jrasamba, we briefly discussed this issue at SMB3 IOLAB the past week, but after reading man 2 openat I am not sure this is a bug in the automounter but a consequence on how Samba works after the VFS interface changes, and a new VFS module to make sure automounts are triggered is the less intrusive way to fix it. In any case I mark it as draft for now to hear others opinions.

Checklist

  • Commits have Signed-off-by: with name/author being identical to the commit author
  • (optional) This MR is just one part towards a larger feature.
  • (optional, if backport required) Bugzilla bug filed and BUG: tag added
  • Test suite updated with functionality tests
  • Test suite updated with negative tests
  • Documentation updated
  • CI timeout is 3h or higher (see Settings/CICD/General pipelines/ Timeout)

Reviewer's checklist:

  • There is a test suite reasonably covering new functionality or modifications
  • Function naming, parameters, return values, types, etc., are consistent and according to README.Coding.md
  • This feature/change has adequate documentation added
  • No obvious mistakes in the code

Merge request reports