Bug 15645 - Snapshots created inside nested filesets at more than one level are not accessible
Summary: Snapshots created inside nested filesets at more than one level are not acces...
Status: NEW
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: File services (show other bugs)
Version: 4.19.6
Hardware: All All
: P5 regression (vote)
Target Milestone: ---
Assignee: Samba QA Contact
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-05-11 11:47 UTC by Subba Ramanna Bodda
Modified: 2024-05-11 11:47 UTC (History)
0 users

See Also:


Attachments
v4-19 test case patch for nested fileset snapshots access (3.30 KB, application/mbox)
2024-05-11 11:47 UTC, Subba Ramanna Bodda
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Subba Ramanna Bodda 2024-05-11 11:47:24 UTC
Created attachment 18301 [details]
v4-19 test case patch for nested fileset snapshots access

This problem was first observed in case of GPFS filesets. If snapshot is created within nested filesets at level greater than 1, the snapshot is not accessible.

If .snapshots is under smb_snapshots/filesetone/filesettwo, and a the snapshot has a file at smb_snapshots/filesetone/filesettwo/.snapshots/@GMT-2000.01.02-03.05.05/test.txt.

Then, this below command fails.

# smbclient   //<server>/share -U 'domain\\user%password' -c 'get filesetone\filesettwo\test.txt\@GMT-2000.01.02-03.05.05 /tmp/test.txt'
NT_STATUS_OBJECT_PATH_NOT_FOUND opening remote file \filesetone\filesettwo\test.txt\@GMT-2000.01.02-03.05.05.

Equivalent command created as testcase against v4-19-stable is as below.

# /root/repos/smb/samba2/bin/smbclient -m SMB3 -Uroot%fileserver //FILESERVER/shadow7 -I 10.53.57.35 -c 'get bar/second/foo/@GMT-2017.10.31-19.40.30 /root/repos/smb/samba2/st/fileserver/share/shadow/foo'
NT_STATUS_OBJECT_PATH_NOT_FOUND opening remote file \bar\second\foo\@GMT-2017.10.31-19.40.30

This passes with Samba 4.17, and will fail with 4.18 and 4.19.

This started coming after this commit.

f11643fee31995ea1124e4b0e53cd980d2056e5f
smbd: Fix traversing snapshot dirs that vanished in current fileset

Reason for the error
====================

Before the above commit, in source3/modules/vfs_shadow_copy2.c, code used to go into this if condition as timestamp was always 0.

        if (timestamp == 0) {
                if (is_converted) {
                        /*
                         * Just pave over the user requested mode and use
                         * O_RDONLY. Later attempts by the client to write on
                         * the handle will fail in the pwrite() syscall with
                         * EINVAL which we carefully map to EROFS. In sum, this
                         * matches Windows behaviour.
                         */
                        how.flags &= ~(O_WRONLY | O_RDWR | O_CREAT);
                }
                return SMB_VFS_NEXT_OPENAT(handle,
                                           dirfsp,
                                           smb_fname_in,
                                           fsp,
                                           &how);
        }

The converting operation shadow_copy2_do_convert gets path as 'filesetone/filesettwo/test.txt'.

Snapshots were searched as below.

Trying[snapdirseverywhere] /ibm/fs1/smb_snapshots/filesetone/filesettwo/test2.txt/.snapshots/@GMT-2000.01.02-03.05.05: -1 (Not a directory)
Trying[snapdirseverywhere] /ibm/fs1/smb_snapshots/filesetone/filesettwo/.snapshots/@GMT-2000.01.02-03.05.05/test2.txt: 0 (ok)
Found /ibm/fs1/smb_snapshots/filesetone/filesettwo/.snapshots/@GMT-2000.01.02-03.05.05/test2.txt

With latest code, we see converting stops at below point in shadow_copy2_do_convert i.e. "filesetone" and not "filesetone/filesettwo/...".

Snapshots are searched as below.

Trying[snapdirseverywhere] /ibm/fs1/smb_snapshots/filesetone/.snapshots/@GMT-2000.01.02-03.05.05: -1 (No such file or directory)
Trying[snapdirseverywhere] /ibm/fs1/smb_snapshots/.snapshots/@GMT-2000.01.02-03.05.05/filesetone: -1 (No such file or directory)
Trying[snapdirseverywhere] /ibm/fs1/.snapshots/@GMT-2000.01.02-03.05.05/smb_snapshots/filesetone: -1 (No such file or directory)

The option shadow:snapdirseverywhere = yes fails here.

Test case patch is in attachment.

Test Case Command and Output is as below.
=========================================

make test TESTS=blackbox.shadow_copy2.SMB3 SMBD_OPTIONS="-d10"


2024-05-09T22:45:45.436003+00:00 fileserver.samba.example.com log.smbd[216621]: _shadow_copy2_strip_snapshot_internal: [from shadow_copy2_openat()] Path 'bar {@GMT-2017.10.31-19.40.30}'
2024-05-09T22:45:45.436013+00:00 fileserver.samba.example.com log.smbd[216621]: _shadow_copy2_strip_snapshot_internal: abs path '/root/repos/smb/samba2/st/fileserver/share/shadow/mount/base/share/bar'
2024-05-09T22:45:45.436022+00:00 fileserver.samba.example.com log.smbd[216621]: converting 'bar'
2024-05-09T22:45:45.436039+00:00 fileserver.samba.example.com log.smbd[216621]: Trying[snapdirseverywhere] /root/repos/smb/samba2/st/fileserver/share/shadow/mount/base/share/bar/.snapshots/@GMT-2017.10.31-19.40.30: -1 (No such file or directory)
2024-05-09T22:45:45.436059+00:00 fileserver.samba.example.com log.smbd[216621]: Trying[snapdirseverywhere] /root/repos/smb/samba2/st/fileserver/share/shadow/mount/base/share/.snapshots/@GMT-2017.10.31-19.40.30/bar: -1 (No such file or directory)
2024-05-09T22:45:45.436073+00:00 fileserver.samba.example.com log.smbd[216621]: Trying[snapdirseverywhere] /root/repos/smb/samba2/st/fileserver/share/shadow/mount/base/.snapshots/@GMT-2017.10.31-19.40.30/share/bar: -1 (No such file or directory)
2024-05-09T22:45:45.436090+00:00 fileserver.samba.example.com log.smbd[216621]: Trying[snapdirseverywhere] /root/repos/smb/samba2/st/fileserver/share/shadow/mount/.snapshots/@GMT-2017.10.31-19.40.30/base/share/bar: -1 (No such file or directory)
2024-05-09T22:45:45.436099+00:00 fileserver.samba.example.com log.smbd[216621]: openat_pathref_fsp_nosymlink: SMB_VFS_OPENAT() failed: No such file or directory
2024-05-09T22:45:45.436108+00:00 fileserver.samba.example.com log.smbd[216621]: file_free: freed files structure 0 (0 used)
2024-05-09T22:45:45.436115+00:00 fileserver.samba.example.com log.smbd[216621]: filename_convert_dirfsp_nosymlink: opening directory bar/second failed: NT_STATUS_OBJECT_NAME_NOT_FOUND
2024-05-09T22:45:45.436127+00:00 fileserver.samba.example.com log.smbd[216621]: smbd_smb2_request_error_ex: smbd_smb2_request_error_ex: idx[1] status[NT_STATUS_OBJECT_PATH_NOT_FOUND] || at ../../source3/smbd/smb2_create.c:360