diff mbox series

[2/2] btrfs-progs: misc-tests: new test case check the handling of full file clone

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

Commit Message

Qu Wenruo Sept. 27, 2024, 5:53 a.m. UTC
The new test case will utilize the following send stream:

Stream 1:

subvol          ./ro_subv1                      uuid=769f87d1-98b2-824f-bf18-9d98178ad2e2 transid=7
chown           ./ro_subv1/                     gid=0 uid=0
chmod           ./ro_subv1/                     mode=755
mkfile          ./ro_subv1/o257-7-0
rename          ./ro_subv1/o257-7-0             dest=./ro_subv1/source
write           ./ro_subv1/source               offset=0 len=4000
chown           ./ro_subv1/source               gid=0 uid=0
chmod           ./ro_subv1/source               mode=600
utimes          ./ro_subv1/source               atime=2024-09-27T13:26:25+0800 mtime=2024-09-27T13:26:25+0800 ctime=2024-09-27T13:26:25+0800
mkfile          ./ro_subv1/o258-7-0
rename          ./ro_subv1/o258-7-0             dest=./ro_subv1/dest
clone           ./ro_subv1/dest                 offset=0 len=4000 from=./ro_subv1/source clone_offset=0
chown           ./ro_subv1/dest                 gid=0 uid=0
chmod           ./ro_subv1/dest                 mode=600
utimes          ./ro_subv1/dest                 atime=2024-09-27T13:26:25+0800 mtime=2024-09-27T13:26:25+0800 ctime=2024-09-27T13:26:25+0800
utimes          ./ro_subv1/                     atime=2024-09-27T13:26:25+0800 mtime=2024-09-27T13:26:25+0800 ctime=2024-09-27T13:26:25+0800

Stream 2:

snapshot        ./ro_snap1                      uuid=e78c9b7c-1bea-fc48-aaf3-6a4d98eba473 transid=9 parent_uuid=769f87d1-98b2-824f-bf18-9d98178ad2e2 parent_transid=7
write           ./ro_snap1/source               offset=0 len=3900
truncate        ./ro_snap1/source               size=3900
utimes          ./ro_snap1/source               atime=2024-09-27T13:26:25+0800 mtime=2024-09-27T13:26:25+0800 ctime=2024-09-27T13:26:25+0800
clone           ./ro_snap1/dest                 offset=0 len=3900 from=./ro_snap1/source clone_offset=0
truncate        ./ro_snap1/dest                 size=3900
utimes          ./ro_snap1/dest                 atime=2024-09-27T13:26:25+0800 mtime=2024-09-27T13:26:25+0800 ctime=2024-09-27T13:26:25+0800

The stream is generated using v6.11 kernel, as upstream commit
46a6e10a1ab1 ("btrfs: send: allow cloning non-aligned extent if it ends
at i_size") allows full file clone to further reduce the stream size.

Verify that "btrfs receive" command has the proper workaround to handle
such full file clone correctly.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 .../ro_snap1.stream.zst                       | Bin 0 -> 293 bytes
 .../ro_subv1.stream.zst                       | Bin 0 -> 413 bytes
 .../066-receive-full-file-clone/test.sh       |  24 ++++++++++++++++++
 3 files changed, 24 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
diff mbox series

Patch

diff --git a/tests/misc-tests/066-receive-full-file-clone/ro_snap1.stream.zst b/tests/misc-tests/066-receive-full-file-clone/ro_snap1.stream.zst
new file mode 100644
index 0000000000000000000000000000000000000000..e190b6ca7f050ae16ed11a6b278658fdea5c9adb
GIT binary patch
literal 293
zcmdPcs{c3TEB{^&1{2<-lA^R?-Qtp>)Wlo{Mg|53A0TF8@Z107AU^{KLs5Qwab9A9
zAtQqT!}FfmHPWyCc&z%I<vZi`l42&HJST$)P^N5t`^6cXn*8@m%$*_Lb?K2PP==i$
zjGuvlpTV_b)mnZAHiqK-(xT*4A)t&fgAM<GF`zYq47Z-7Okn{E+3;Hd`63Jx^d!G>
zGw?7lI(<vq7xY+w%T8>q5N8-rPJkiab{?|?KLZOxN@{V5h^Uyjh-*u5sKt8Y^aYtb
zo`U<<xC)Ch1mv8YE5(q*F+-B!fZ&6S3=57fj&<5n{N4hxZ{vj9WPJn^?nvw?$u!7&
luh{Nz-PpJJK>IC@9;31yigTFPGv;#`@UaQ7R&Bgf1OO`|ST_Iw

literal 0
HcmV?d00001

diff --git a/tests/misc-tests/066-receive-full-file-clone/ro_subv1.stream.zst b/tests/misc-tests/066-receive-full-file-clone/ro_subv1.stream.zst
new file mode 100644
index 0000000000000000000000000000000000000000..f70aeebb7cf5161d0fe3db25496ed29d7e12430b
GIT binary patch
literal 413
zcmdPcs{c2oU$B;k;fO#|Nl{v{ZgELbYGN(}BLf424iGak?0Y}=5kCV5Ls5QwacNSS
zAtQqTL)rZHi!(Mg`R|vQJ43wd(jz9IJUfF7P`xk%leumWKaj-+5)%M2gcu@2OHEmU
z+_#JpKt3}=PTp<id?QnHU2|OnW}rBu7*Lp#VF$n976G8X;{4L0<kVe2L--jU-1uw9
zFC@&cfd8ygns{>;o7n1Ov5On5fEq*?9+uT#<7VJtV08MHwlC<h02gO*tMN7qCK26Z
zc|H~_3@NF_C1F670t{dNZ~H9)v}pl@h^Uyj!f9o>RU#b+y}w&Hi9A=x<na_V`PE^n
zCo;2EK$IaM=j2=qg#%0zHH9Ygg)k?~VLH~Z+O6<c#9@gx)^mZUEjff<?wbDjg36^*
zL;gdX+>I62Nw&%AE-Fmkc;syI)(Z(Njvq`8$w)j}^0w@aaM=`2gBkD6UE5N#Bd{{m
zLHgd(?cZ4{6N>xaFIDk)`_$&`*ZC*p-p(s${q$V-*Ay0JxnfmCi8PV8k2@{_07?#w
AHUIzs

literal 0
HcmV?d00001

diff --git a/tests/misc-tests/066-receive-full-file-clone/test.sh b/tests/misc-tests/066-receive-full-file-clone/test.sh
new file mode 100755
index 000000000000..63fa922a5600
--- /dev/null
+++ b/tests/misc-tests/066-receive-full-file-clone/test.sh
@@ -0,0 +1,24 @@ 
+#!/bin/bash
+# Verify "btrfs-receive" can handle a full file clone (clone length is not
+# aligned but matches inode size) into a larger destination file.
+#
+# Such clone stream can be generated since kernel commit 46a6e10a1ab1
+# ("btrfs: send: allow cloning non-aligned extent if it ends at i_size").
+
+source "$TEST_TOP/common" || exit
+source "$TEST_TOP/common.convert" || exit
+
+tmp=$(_mktemp "receive-full-file-clone")
+
+setup_root_helper
+prepare_test_dev
+check_global_prereq zstd
+
+run_check_mkfs_test_dev
+run_check_mount_test_dev
+run_check zstd -d -f ./ro_subv1.stream.zst -o "$tmp"
+run_check "$TOP/btrfs" receive -f "$tmp" "$TEST_MNT"
+run_check zstd -d -f ./ro_snap1.stream.zst -o "$tmp"
+run_check "$TOP/btrfs" receive -f "$tmp" "$TEST_MNT"
+run_check_umount_test_dev
+rm -f -- "$tmp"