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 seqres=$RESULT_DIR/$seq
17 echo "QA output created by $seq"
20 status=1 # failure is the default!
21 trap "_cleanup; exit \$status" 0 1 2 3 15
25 rm -fr $send_files_dir
29 # get standard environment, filters and checks
33 # real QA test starts here
38 send_files_dir=$TEST_DIR/btrfs-test-$seq
41 rm -fr $send_files_dir
44 _scratch_mkfs >>$seqres.full 2>&1
47 mkdir -p $SCRATCH_MNT/data/n1/n2/p1/p2
48 mkdir $SCRATCH_MNT/data/n4
49 mkdir -p $SCRATCH_MNT/data/p1/p2
51 # Filesystem looks like:
54 # |---- data (ino 257)
56 # | |---- n2/ (ino 259)
57 # | |---- p1/ (ino 260)
58 # | |---- p2/ (ino 261)
64 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap1
66 # Now move directories around such that for the subtrees with the path "p1/p2"
67 # we end up swapping the parents, that is, inode 263 becomes the parent of
68 # inode 261 and inode 260 becomes the parent of inode 264. This makes the send
69 # stream orphanize the inodes 263 and 264, and we want to verify the respective
70 # rename operations don't fail, that they don't use incorrect paths.
71 mv $SCRATCH_MNT/data/p1/p2 $SCRATCH_MNT/data
72 mv $SCRATCH_MNT/data/n1/n2/p1/p2 $SCRATCH_MNT/data/p1
73 mv $SCRATCH_MNT/data/p2 $SCRATCH_MNT/data/n1/n2/p1
74 mv $SCRATCH_MNT/data/n1/n2 $SCRATCH_MNT/data/p1
75 mv $SCRATCH_MNT/data/p1 $SCRATCH_MNT/data/n4
76 mv $SCRATCH_MNT/data/n4/p1/n2/p1 $SCRATCH_MNT/data
78 # Filesystem now looks like:
81 # |---- data (ino 257)
84 # | |---- p1/ (ino 263)
85 # | |---- n2/ (ino 259)
86 # | |---- p2/ (ino 261)
91 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap2
93 run_check $FSSUM_PROG -A -f -w $send_files_dir/1.fssum $SCRATCH_MNT/mysnap1
94 run_check $FSSUM_PROG -A -f -w $send_files_dir/2.fssum \
95 -x $SCRATCH_MNT/mysnap2/mysnap1 $SCRATCH_MNT/mysnap2
97 _run_btrfs_util_prog send -f $send_files_dir/1.snap $SCRATCH_MNT/mysnap1
98 _run_btrfs_util_prog send -p $SCRATCH_MNT/mysnap1 -f $send_files_dir/2.snap \
101 # Now recreate the filesystem by receiving both send streams and verify we get
102 # the same content that the original filesystem had.
104 _scratch_mkfs >>$seqres.full 2>&1
107 _run_btrfs_util_prog receive -f $send_files_dir/1.snap $SCRATCH_MNT
108 run_check $FSSUM_PROG -r $send_files_dir/1.fssum $SCRATCH_MNT/mysnap1
109 _run_btrfs_util_prog receive -f $send_files_dir/2.snap $SCRATCH_MNT
110 run_check $FSSUM_PROG -r $send_files_dir/2.fssum $SCRATCH_MNT/mysnap2
112 echo "Silence is golden"