Bug 14573 - Unable to list previous versions of directory using vfs_shadow_copy2 with GlusterFS snapshots
Summary: Unable to list previous versions of directory using vfs_shadow_copy2 with Glu...
Status: RESOLVED FIXED
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: VFS Modules (show other bugs)
Version: 4.13.2
Hardware: All All
: P5 major (vote)
Target Milestone: ---
Assignee: Karolin Seeger
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-11-12 06:31 UTC by Anoop C S
Modified: 2021-01-14 08:34 UTC (History)
2 users (show)

See Also:


Attachments
git-am fix for 4.13.next. (1.66 KB, patch)
2020-11-12 19:57 UTC, Jeremy Allison
gd: review+
anoopcs: review+
Details
patch for v4-12 and v4-11 (1.70 KB, patch)
2020-11-12 22:33 UTC, Guenther Deschner
anoopcs: review+
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Anoop C S 2020-11-12 06:31:10 UTC
In a setup where GlusterFS snapshots are browsed to list previous versions of a directory, it says "There are no previous versions available". Following is the configuration:

# testparm -s
Load smb config files from /usr/local/etc/samba/smb.conf
Loaded services file OK.
Weak crypto is allowed
Server role: ROLE_STANDALONE

# Global parameters
[global]
	clustering = Yes
	load printers = No
	log file = /usr/local/var/log/samba/log.%I
	netbios name = GFS-SMB-CLUSTER
	security = USER
	server string = Samba Server
	idmap config * : backend = tdb


[gluster-vol]
	comment = For samba share of volume vol
	kernel share modes = No
	path = /
	read only = No
	vfs objects = shadow_copy2 glusterfs
	shadow:format = _GMT-%Y.%m.%d-%H.%M.%S
	shadow:snapprefix = ^s[A-Za-z0-9]*p$
	shadow:sort = desc
	shadow:basedir = /
	shadow:snapdir = /.snaps
	glusterfs:loglevel = 7
	glusterfs:logfile = /usr/local/var/log/samba/glusterfs-vol.%M.log
	glusterfs:volume = vol

As a side effect snapshot directories are not browsable from SMB clients: 

# smbclient \\\\192.168.122.101\\gluster-vol -U anoopcs%smb
Try "help" to get a list of possible commands.
smb: \> cd .snaps\
smb: \.snaps\> ls
  .                                   D        0  Thu Nov 12 10:44:49 2020
  ..                                  D        0  Wed Nov  4 16:11:30 2020
  snap_GMT-2020.10.09-09.48.22        D        0  Fri Oct  9 15:17:41 2020
  snap_GMT-2020.10.12-11.05.59        D        0  Fri Oct  9 15:17:41 2020

		1044984 blocks of size 1024. 970284 blocks available
smb: \.snaps\> cd snap_GMT-2020.10.12-11.05.59
cd \.snaps\snap_GMT-2020.10.12-11.05.59\: NT_STATUS_FILE_IS_A_DIRECTORY
smb: \.snaps\> exit

Steps to reproduce:
1. Have a GlusterFS-Samba setup
2. Create some files and directories
3. Create and activate snapshots using `gluster` command line utility
4. Try to list Previous versions by right clicking on directories.

Additional info:
[2020/11/11 16:04:59.437798, 10, pid=99412, effective(1001, 1001), real(1001, 0)] ../../source3/smbd/open.c:813(fd_open)
  fd_open: name .snaps/snap_GMT-2020.10.12-11.05.59, flags = 0200000 mode = 00, fd = -1. Is a directory
[2020/11/11 16:04:59.437840,  5, pid=99412, effective(1001, 1001), real(1001, 0)] ../../source3/smbd/open.c:4534(open_directory)
  open_directory: Could not open fd for .snaps/snap_GMT-2020.10.12-11.05.59 (NT_STATUS_FILE_IS_A_DIRECTORY)
. . .
[2020/11/11 16:04:59.438458, 10, pid=99412, effective(1001, 1001), real(1001, 0)] ../../source3/smbd/open.c:5854(create_file_unixpath)
  create_file_unixpath: NT_STATUS_FILE_IS_A_DIRECTORY
[2020/11/11 16:04:59.438489, 10, pid=99412, effective(1001, 1001), real(1001, 0)] ../../source3/smbd/open.c:6046(create_file_default)
  create_file: NT_STATUS_FILE_IS_A_DIRECTORY
Comment 1 Anoop C S 2020-11-12 10:10:35 UTC
vfs_shadow_copy2_openat() replaces received open flags with just O_RDONLY which results in calling glfs_open() instead of glfs_opendir() causing EISDIR while trying to open "."
Comment 2 Samba QA Contact 2020-11-12 17:24:04 UTC
This bug was referenced in samba master:

e9e06a11daf036abf7a7022ebc8eaefde178aa52
Comment 3 Jeremy Allison 2020-11-12 19:57:49 UTC
Created attachment 16334 [details]
git-am fix for 4.13.next.
Comment 4 Jeremy Allison 2020-11-12 19:58:41 UTC
Comment on attachment 16334 [details]
git-am fix for 4.13.next.

Cherry-pick from master.
Comment 5 Guenther Deschner 2020-11-12 22:31:54 UTC
Comment on attachment 16334 [details]
git-am fix for 4.13.next.

LGTM
Comment 6 Guenther Deschner 2020-11-12 22:33:09 UTC
Created attachment 16335 [details]
patch for v4-12 and v4-11

Backports for older versions since the overwrite with O_RDONLY is present as well.
Comment 7 Guenther Deschner 2020-11-17 12:08:21 UTC
Karolin, please add to the relevant branches. Thanks!
Comment 8 Karolin Seeger 2020-11-19 09:56:47 UTC
(In reply to Guenther Deschner from comment #7)
Pushed to autobuild-v4-{13,12}-test.
Comment 9 Samba QA Contact 2020-11-19 11:25:30 UTC
This bug was referenced in samba v4-13-test:

8c82d0fd49b0406b34e60f49fd4c3b2ff95cb049
Comment 10 Samba QA Contact 2020-11-19 14:10:47 UTC
This bug was referenced in samba v4-12-test:

b3665f70109b634564974de966d255807c0547f0
Comment 11 Karolin Seeger 2020-11-24 11:18:34 UTC
Pushed to both branches.
Closing out bug report.

Thanks!
Comment 12 Samba QA Contact 2020-12-16 12:22:01 UTC
This bug was referenced in samba v4-13-stable (Release samba-4.13.3):

8c82d0fd49b0406b34e60f49fd4c3b2ff95cb049
Comment 13 Samba QA Contact 2021-01-14 08:34:51 UTC
This bug was referenced in samba v4-12-stable (Release samba-4.12.11):

b3665f70109b634564974de966d255807c0547f0