2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2015 SUSE Linux Products GmbH. All Rights Reserved.
5 # FS QA Test No. btrfs/084
7 # Test for incremental send where the difference between the parent and send
8 # snapshots is that for a subtree with the same path in both snapshots (p1/p2),
9 # the root directories were swapped.
11 # This issue was fixed by the following linux kernel btrfs patch:
13 # Btrfs: incremental send, clear name from cache after orphanization
16 _begin_fstest auto quick send
18 # Override the default cleanup function.
21 rm -fr $send_files_dir
25 # Import common functions.
28 # real QA test starts here
33 send_files_dir=$TEST_DIR/btrfs-test-$seq
35 rm -fr $send_files_dir
38 _scratch_mkfs >>$seqres.full 2>&1
41 mkdir -p $SCRATCH_MNT/data/n1/n2/p1/p2
42 mkdir $SCRATCH_MNT/data/n4
43 mkdir -p $SCRATCH_MNT/data/p1/p2
45 # Filesystem looks like:
48 # |---- data (ino 257)
50 # | |---- n2/ (ino 259)
51 # | |---- p1/ (ino 260)
52 # | |---- p2/ (ino 261)
58 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap1
60 # Now move directories around such that for the subtrees with the path "p1/p2"
61 # we end up swapping the parents, that is, inode 263 becomes the parent of
62 # inode 261 and inode 260 becomes the parent of inode 264. This makes the send
63 # stream orphanize the inodes 263 and 264, and we want to verify the respective
64 # rename operations don't fail, that they don't use incorrect paths.
65 mv $SCRATCH_MNT/data/p1/p2 $SCRATCH_MNT/data
66 mv $SCRATCH_MNT/data/n1/n2/p1/p2 $SCRATCH_MNT/data/p1
67 mv $SCRATCH_MNT/data/p2 $SCRATCH_MNT/data/n1/n2/p1
68 mv $SCRATCH_MNT/data/n1/n2 $SCRATCH_MNT/data/p1
69 mv $SCRATCH_MNT/data/p1 $SCRATCH_MNT/data/n4
70 mv $SCRATCH_MNT/data/n4/p1/n2/p1 $SCRATCH_MNT/data
72 # Filesystem now looks like:
75 # |---- data (ino 257)
78 # | |---- p1/ (ino 263)
79 # | |---- n2/ (ino 259)
80 # | |---- p2/ (ino 261)
85 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap2
87 run_check $FSSUM_PROG -A -f -w $send_files_dir/1.fssum $SCRATCH_MNT/mysnap1
88 run_check $FSSUM_PROG -A -f -w $send_files_dir/2.fssum \
89 -x $SCRATCH_MNT/mysnap2/mysnap1 $SCRATCH_MNT/mysnap2
91 _run_btrfs_util_prog send -f $send_files_dir/1.snap $SCRATCH_MNT/mysnap1
92 _run_btrfs_util_prog send -p $SCRATCH_MNT/mysnap1 -f $send_files_dir/2.snap \
95 # Now recreate the filesystem by receiving both send streams and verify we get
96 # the same content that the original filesystem had.
98 _scratch_mkfs >>$seqres.full 2>&1
101 _run_btrfs_util_prog receive -f $send_files_dir/1.snap $SCRATCH_MNT
102 run_check $FSSUM_PROG -r $send_files_dir/1.fssum $SCRATCH_MNT/mysnap1
103 _run_btrfs_util_prog receive -f $send_files_dir/2.snap $SCRATCH_MNT
104 run_check $FSSUM_PROG -r $send_files_dir/2.fssum $SCRATCH_MNT/mysnap2
106 echo "Silence is golden"