fix for possible bug in shadow_copy2 (4.7.5) plus minor enhancement

Thomas Nau Thomas.Nau at uni-ulm.de
Fri Mar 9 10:14:01 UTC 2018


Dear all

I found an issue when running 4.7.5 on a Solaris 11.3 server.
It relates to the use of regex patterns in the shadow-copy2
VFS module. When having set "shadow: localtime = yes"
the Window7 client from time to time complains about a vanished
or not existing snapshot while others work fine. Snapshots
are created hourly and daily by the Solaris time-slider and
named like
	pool/data at zfs-auto-snap_secretly-hourly-2018-02-07-15h14
	pool/data at zfs-auto-snap_secretly-daily-2018-03-07-16h14


Debugging lead to the following and I hope you can confirm.
When using this feature the code path is slightly different
when a client selects a snapshot from the list. Samba has to
lookup the pattern in an internal list which seems to be setup
being based on GMT time information.

The ZFS snapshots created by time-slider in Solaris, and probably
by most other tools too, are using localtime for the filename
being created. Samba does the required conversion to GMT when
setting up the list and before sending it to the client. The
information being sent back by the client is GMT too.
Given that we should not convert to localtime before searching
through the list.
If you are not on GMT but use hourly snapshots windows might
actually present you a folder or file but it will not be for
the timestamp you expect but simply match another hourly one.


The other thing is about an improved handling of snapshot names.
Given Solaris time-slider, and probably other tools, creates names
such as
	pool/data at zfs-auto-snap_smb-hourly-2018-02-07-15h14
	pool/data at zfs-auto-snap_smb-daily-2018-03-07-16h14
we would need the regex-fromat feature plus a rather unpleasant
pattern for the delimiter and the time format like
	shadow: snapprefix          = zfs-auto-snap_smb-
	shadow: delimiter           = ly-
	shadow: format              = ly-%Y-%m-%d-%Hh%M

So while this works as the time specifications all end by "ly"
it becomes a pain if the delimiter pattern shows further to
the left in the string.
For example in
	pool/data at zfs-auto-snap_secretly-hourly-2018-02-07-15h14
	pool/data at zfs-auto-snap_secretly-daily-2018-03-07-16h14
delimiter would split the name at "secret ly-" and the time format,
not regex capable, cannot distinguish between daily and hourly anymore.

That said my approach keeps the old style valid but extends it a bit.
In case you set the delimiter explicitly to be empty string
	shadow: delimiter =
The patched code ignores the delimiter, matches the regex and assumes
that the time format string starts right after the match. The patch
applied allows for this config
    shadow: snapprefix          = zfs-auto-snap_smb-[a-z]*-
    shadow: delimiter           =
    shadow: format              = %Y-%m-%d-%Hh%M


I hope my findings are right and you find the attached diff useful

Thomas



-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch_samba-4.7.5_shadow_copy2.diff
Type: text/x-patch
Size: 2813 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20180309/d95af302/patch_samba-4.7.5_shadow_copy2.bin>


More information about the samba-technical mailing list