shadow_copy2: previous versions of nested directories fail with catia and disables the RESOLVE_NO_SYMLINKS fast path

There are two problems in this report. The second one turned up while debugging the first.

  1. Previous versions of nested directories fail when catia comes before shadow_copy2

When catia is listed before shadow_copy2 in vfs objects, opening previous versions fails for paths that are a few directories deep. With the modules in the opposite order it works.

Example share:

[shadow] path = /srv/samba/test/snapshots-test vfs objects = catia shadow_copy2 shadow:mountpoint = /srv/samba/test/snapshots-test shadow:snapdir = snapshots

with a snapshot at snapshots/@GMT-2026.10.28-15.15.30/ containing a/b/c/d/file.txt.

$ smbclient //server/shadow -c "allinfo a/b/c/d" ... @GMT-2026.10.28-15.15.30 pathinfo(@GMT-2026.10.28-15.15.30\a\b\c\d) failed: NT_STATUS_OBJECT_PATH_NOT_FOUND

Paths with only one or two directory levels work.

Cause: for snapshot paths, in openat_pathref_fsp_nosymlink() smbd opens the path one directory at a time and reuses file handles. vfs_catia caches a translated name per file handle and doesn't notice that a reused handle now stands for a different directory. It then hands a stale directory name down to shadow_copy2, which builds the wrong snapshot path. The fix is to drop the VFS module state of a handle when it gets reused during the path walk.

  1. shadow_copy2 disables the fast path lookup for the whole share

Just having shadow_copy2 in the VFS stack disables the fastpath lookup via openat2() with RESOLVE_NO_SYMLINKS for every path on the share, not only for snapshot paths. shadow_copy2 rejected the flag unconditionally, so smbd always tried the fast lookup first, failed, and fell back to opening the path one directory at a time. The fix lets non-snapshot opens pass straight through shadow_copy2, so only snapshot paths still take the slow route.

Merge request reports

Loading
Loading