Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Btrfs clone ioctl #640

Open
wants to merge 4 commits into
base: next
Choose a base branch
from

Conversation

szekelyszilv
Copy link

Btrfs clone ioctl can be used for O(1) copying within a file system
utilizing copy-on-write.

Passing --enable-btrfs-clone to ./configure enables this feature.

The feature is dependent on the "btrfs/ioctl.h" header which is part of
btrfs-progs.

vfs_file_task_do_copy is modified to always try to call the ioctl,
and fall back to the regular copying method if it fails.

Btrfs clone ioctl can be used for O(1) copying within a file system
utilizing copy-on-write.

Passing --enable-btrfs-clone to ./configure enables this feature.

The feature is dependent on the "btrfs/ioctl.h" header which is part of
btrfs-progs.

vfs_file_task_do_copy is modified to always try to call the ioctl,
and fall back to the regular copying method if it fails.
@szekelyszilv
Copy link
Author

I found this useful e.g. for quickly and cheaply creating backup copies where a more robust approach was not required.

@IgnorantGuru IgnorantGuru added this to the near milestone Apr 28, 2016
@IgnorantGuru
Copy link
Owner

IgnorantGuru commented Apr 30, 2016

Reference in coreutils cp

Looks reasonable. Need to document any build dependencies this would add. Also configure should probably default to using it if the dependencies are present, like it does with startup-notification, since this seems standardized in coreutils. If the deps aren't available, or if you add --disable-btrfs-clone (if such an option is even worth it), then it can skip it. If you require --enable-btrfs-clone explicitly, it will rarely get used.

Change definition from USE_ to HAVE_
Code cleanup, reduce #ifdefs
Add clone_file function that tries to clone using available methods in
turn. Return success if one of the succeeds or failure if none of them
do or are available.
@szekelyszilv
Copy link
Author

Changed it to be used by default and added it to the output of the configure script.
I also added to the README, dependencies are just btrfs-tools or btrfs-progs.
Also added the kernel and filesystem requirements, but those should fail gracefully.

In VFS file task the clone_file function can be used to add other clone methods
and have less conditional code.

@nioncode
Copy link

Any chance of having this merged soon?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants