linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 0/2] btrfs-progs: receive: workaround full file clone quirk
Date: Fri, 27 Sep 2024 15:23:23 +0930	[thread overview]
Message-ID: <cover.1727416314.git.wqu@suse.com> (raw)

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


             reply	other threads:[~2024-09-27  5:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-27  5:53 Qu Wenruo [this message]
2024-09-27  5:53 ` [PATCH 1/2] btrfs-progs: receive: workaround unaligned full file clone Qu Wenruo
2024-09-27  8:14   ` Filipe Manana
2024-09-27  5:53 ` [PATCH 2/2] btrfs-progs: misc-tests: new test case check the handling of " Qu Wenruo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cover.1727416314.git.wqu@suse.com \
    --to=wqu@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).