mbox series

[0/2] btrfs-progs: receive: workaround full file clone quirk

Message ID cover.1727416314.git.wqu@suse.com (mailing list archive)
Headers show
Series btrfs-progs: receive: workaround full file clone quirk | expand

Message

Qu Wenruo Sept. 27, 2024, 5:53 a.m. UTC
Since kernel commit 46a6e10a1ab1 ("btrfs: send: allow cloning
non-aligned extent if it ends at i_size"), we can have clone commands to
clone a full file.

However such full file clone can have an unaligned length, and such
clone is only allowed if the destination file is no larger than the
clone range.

But we can create a case where such clone called on a destination file
which has a larger size.
This can lead to kernel reject such clone, and fail the receive.

This patchset will handle such quirk by truncate the file size to 0 if
we detect this is a full file clone.

Also add a new test case to verify the behaivor.

Qu Wenruo (2):
  btrfs-progs: receive: workaround unaligned full file clone
  btrfs-progs: misc-tests: new test case check the handling of full file
    clone

 cmds/receive.c                                |  47 ++++++++++++++++++
 .../ro_snap1.stream.zst                       | Bin 0 -> 293 bytes
 .../ro_subv1.stream.zst                       | Bin 0 -> 413 bytes
 .../066-receive-full-file-clone/test.sh       |  24 +++++++++
 4 files changed, 71 insertions(+)
 create mode 100644 tests/misc-tests/066-receive-full-file-clone/ro_snap1.stream.zst
 create mode 100644 tests/misc-tests/066-receive-full-file-clone/ro_subv1.stream.zst
 create mode 100755 tests/misc-tests/066-receive-full-file-clone/test.sh

--
2.46.1