Circular snapshots, visibility, samba, shadow copy and FUN ;)

Hi,

I’ve somehow discovered a reason for slow down on creating a lot of snapshots on share that would be visible via samba.

SO, to be able to see snapshots in samba as a shadow copy, snapshots created need to be set to “visible”.

To make it more graphica, lets say you’ve got a pool called “main_pool” and a share called "share"
Those will sit in:
/mnt2/main_pool
/mnt2/share

Fair enough - right ? Now, if rockstor script creates a scheduled snapshot (called for sake “share_5min”) which is set to be visible, it will create snapshot located here:
/mnt2/main_pool/.snapshots/share/share_5min_201609191525

but it will also create a symlink:
/mnt2/share/.share_5min_201609191525

so when a samba comes in and tries to find a shadow copy - here is a symlink, go away and look for veto files there.
So far so good :slight_smile:
Now, lets say scheduler creates another snapshot, it will locate it here:
/mnt2/main_pool/.snapshots/share/share_5min_201609191530
and create another symlink:
/mnt2/share/.share_5min_201609191530

BUT !!! Bare in mind that your share has now TWO (2) symlinks on it!!! and your second snapshot has a symlink pointing to previous snapshot !!!

So, samba comes in and looks for veto files:
lets follow symlink:
/mnt2/share/.share_5min_201609191530
-> that points you to snapshot ->
/mnt2/main_pool/.snapshots/share/share_5min_201609191530
-> hey that one has a symlink ->
/mnt2/share/.share_5min_201609191525
-> that points you to snapshot ->
/mnt2/main_pool/.snapshots/share/share_5min_201609191530

That causes samba to hash through a log(n) snapshots (where n = total amount of snaphost of share you have) every time it wants to find a shadow copy.

To fix that:
switch off your “visible” options on snapshots
delete all the snapshots that are visible
delete all silly symlinks you have on your share
disable “shadow copy” on samba share
Go to services configuration and add those lines to samba main config:
wide links = yes
unix extensions = no
Go to configuration of you share and add manually those options:
vfs objects = shadow_copy2
shadow:sort = desc
shadow:basedir = /mnt2/share
shadow:format = share_5min_%Y%m%d%H%M
shadow:snapdir = /mnt2/main_pool/.snapshots/share

And that’s it, you’re golden :smiley:
I sure hope that this will help somebody and point rockstor developers away from this crazy circular creation scheme (FYI btrfs get’s hell confused while creating “visible” snapshots and very often you can see kworker thread sitting there at 100%)

3 Likes

FYI,

for who ever even might be interested. After 4 days and a bit I’ve managed to accumulate 1300 snapshots, (done every 5 minutes) over 250GB of corporate data (multitude of little documents actively edited, added and removed) and SAMBA worked absolutely 100% OK, no high CPU usage, no delays on startup.

Now my next test is to have a whole pool compressed with LZO and attempt an extreme snapshot count and see how samba will behave.

1 Like

Your post saved my day a few months ago.
I switched off “visible” option and things went smoothly from there.
Thanks for that.

Though, I’m coming back at this and can’t find my snapshots anymore(!).
If I have /mnt2/myShare/ shouldn’t they be in /mnt2/myShare/.snapshot/?

I’ve run ls -a in /mnt2/ and /mnt2/myShare/ but my .snapshot/ folders are nowhere to be found…

Any cue, hint or help would be much appreciated.

I found the answer here.

For the record, snapshots are stored at the pool level:
/mnt2/<pool name>/.snapshots/<share name>/<snapshot name>

2 Likes