rockstor / rockstor-core

Linux/BTRFS based Network Attached Storage(NAS)
http://rockstor.com/docs/contribute_section.html
GNU General Public License v3.0
557 stars 138 forks source link

[Samba] Enable the btrfs vfs module #2136

Open FroggyFlox opened 4 years ago

FroggyFlox commented 4 years ago

During my research for #1910 , I came across a potential improvement of our global SMB implementation:

As of Samba 4.1.0, Samba carries a Btrfs VFS module that enables the support of Btrfs enhanced server-side copy offload: https://wiki.samba.org/index.php/Server-Side_Copy#Btrfs_Enhanced_Server-Side_Copy_Offload

The Samba wiki reads:

Along with server-side copy support, a Btrfs specific Samba VFS Module was newly added with 4.1.0. This module improves the performance and efficiency of server-side copy operations on Btrfs backed shares, by using the Btrfs clone-range IOCTL. As of Samba 4.7.0, the VFS Module also offers support for FSCTL_DUPLICATE_EXTENTS_TO_FILE.

Sequence

  1. Client issues FSCTL_SRV_COPYCHUNK or FSCTL_DUPLICATE_EXTENTS_TO_FILE requests to server
  2. Server issues BTRFS_IOC_CLONE_RANGE filesystem ioctl

Result

  • File data does not traverse network or disk
    • Filesystem meta-data update only
  • No duplication of file data
    • Source and destination files share the same on disk data extents

It simply requires to add the vfs module on a per share basis:

   [share]
   vfs objects = btrfs

This could thus simply be added to the defaults in: https://github.com/rockstor/rockstor-core/blob/dcdb7ca352f1b9c16323fbfc57d180b64cc019b7/src/rockstor/system/samba.py#L50-L64

As all three Rockstor variants currently have samba versions > 4.7.0, it should be possible across the board. @phillxnet , what do you think?

phillxnet commented 4 years ago

@FroggyFlox Re:

@phillxnet , what do you think?

I think that's a great idea, Nice find. Lets do it.

FroggyFlox commented 4 years ago

Lets do it.

Sounds good. I'm not sure (yet) how to test any performance improvement with it, but on paper I don't seem to see how it could be worse, at the very least. I'll probably include this when working on #1910 .

FroggyFlox commented 4 years ago

Of note, there's also a snapper module of and when we get to implement it. https://www.samba.org/samba/docs/current/man-html/vfs_snapper.8.html

Linking to #1491 for later consideration and evaluation.

phillxnet commented 4 years ago

@FroggyFlox Re:

I'll probably include this when working on #1910 .

It is of course your call, but it might make for a nice little concise pr to highlight this potentially significant 'feature' addition within the changelog. But we could also do that by bending our changelog convention.

I'm not sure (yet) how to test any performance improvement with it,

No me neither, though I'd imagine copying a large file, using a sufficiently new enough SMB client, from one subvol to another within the same pool should be much master and involve much less disk activity, it should be near enough instantaneous from the:

  • Filesystem meta-data update only

bit. But it may not work across mount points, even though the metadata of subvols so mounted share metadata via there pool. Quite a nice tick that. I believe NFS has a similar trick but I'm not sure if it's yet btrfs 'happy'.

phillxnet commented 4 years ago

@FroggyFlox Re:

Of note, there's also a snapper module of and when we get to implement it. https://www.samba.org/samba/docs/current/man-html/vfs_snapper.8.html

Linking to #1491 for later consideration and evaluation.

Yes snapper integration would be nice, and @sfranzen in the issue you linked, did a tone of work in that direction. Maybe once we are fully moved over we can pick that up again.

FroggyFlox commented 4 years ago

It is of course your call, but it might make for a nice little concise pr to highlight this potentially significant 'feature' addition within the changelog. But we could also do that by bending our changelog convention.

Good point. As it's not a pressing matter, I'll keep it separate so that we make sure it doesn't mess with the other vfs modules we'll have to add for #1910. That again looks like a good candidate for Testing channel, incidentally.

Thanks for your very informative input!

phillxnet commented 1 year ago

@FroggyFlox Given the recent interest in Samba performance on the forum of late: https://forum.rockstor.com/t/samba-write-speeds-are-ultra-slow/8869/24 Maybe this issue should be added to our next Milestone once we have our 5.0.0-0 testing branch release out (next few days hopefully). WARNING -- RENEWED TESTING PHASE 5.0.0-0 -- (DEVELOPERS ONLY) #2610

FroggyFlox commented 1 year ago

Good idea.