2 # FS QA Test No. btrfs/084
4 # Test for incremental send where the difference between the parent and send
5 # snapshots is that for a subtree with the same path in both snapshots (p1/p2),
6 # the root directories were swapped.
8 # This issue was fixed by the following linux kernel btrfs patch:
10 # Btrfs: incremental send, clear name from cache after orphanization
12 #-----------------------------------------------------------------------
13 # Copyright (C) 2015 SUSE Linux Products GmbH. All Rights Reserved.
14 # Author: Filipe Manana <fdmanana@suse.com>
16 # This program is free software; you can redistribute it and/or
17 # modify it under the terms of the GNU General Public License as
18 # published by the Free Software Foundation.
20 # This program is distributed in the hope that it would be useful,
21 # but WITHOUT ANY WARRANTY; without even the implied warranty of
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 # GNU General Public License for more details.
25 # You should have received a copy of the GNU General Public License
26 # along with this program; if not, write the Free Software Foundation,
27 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 #-----------------------------------------------------------------------
32 seqres=$RESULT_DIR/$seq
33 echo "QA output created by $seq"
36 status=1 # failure is the default!
37 trap "_cleanup; exit \$status" 0 1 2 3 15
41 rm -fr $send_files_dir
45 # get standard environment, filters and checks
49 # real QA test starts here
55 send_files_dir=$TEST_DIR/btrfs-test-$seq
58 rm -fr $send_files_dir
61 _scratch_mkfs >>$seqres.full 2>&1
64 mkdir -p $SCRATCH_MNT/data/n1/n2/p1/p2
65 mkdir $SCRATCH_MNT/data/n4
66 mkdir -p $SCRATCH_MNT/data/p1/p2
68 # Filesystem looks like:
71 # |---- data (ino 257)
73 # | |---- n2/ (ino 259)
74 # | |---- p1/ (ino 260)
75 # | |---- p2/ (ino 261)
81 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap1
83 # Now move directories around such that for the subtrees with the path "p1/p2"
84 # we end up swapping the parents, that is, inode 263 becomes the parent of
85 # inode 261 and inode 260 becomes the parent of inode 264. This makes the send
86 # stream orphanize the inodes 263 and 264, and we want to verify the respective
87 # rename operations don't fail, that they don't use incorrect paths.
88 mv $SCRATCH_MNT/data/p1/p2 $SCRATCH_MNT/data
89 mv $SCRATCH_MNT/data/n1/n2/p1/p2 $SCRATCH_MNT/data/p1
90 mv $SCRATCH_MNT/data/p2 $SCRATCH_MNT/data/n1/n2/p1
91 mv $SCRATCH_MNT/data/n1/n2 $SCRATCH_MNT/data/p1
92 mv $SCRATCH_MNT/data/p1 $SCRATCH_MNT/data/n4
93 mv $SCRATCH_MNT/data/n4/p1/n2/p1 $SCRATCH_MNT/data
95 # Filesystem now looks like:
98 # |---- data (ino 257)
100 # |---- n4/ (ino 262)
101 # | |---- p1/ (ino 263)
102 # | |---- n2/ (ino 259)
103 # | |---- p2/ (ino 261)
105 # |---- p1/ (ino 260)
106 # |---- p2/ (ino 264)
108 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap2
110 run_check $FSSUM_PROG -A -f -w $send_files_dir/1.fssum $SCRATCH_MNT/mysnap1
111 run_check $FSSUM_PROG -A -f -w $send_files_dir/2.fssum \
112 -x $SCRATCH_MNT/mysnap2/mysnap1 $SCRATCH_MNT/mysnap2
114 _run_btrfs_util_prog send -f $send_files_dir/1.snap $SCRATCH_MNT/mysnap1
115 _run_btrfs_util_prog send -p $SCRATCH_MNT/mysnap1 -f $send_files_dir/2.snap \
118 # Now recreate the filesystem by receiving both send streams and verify we get
119 # the same content that the original filesystem had.
121 _scratch_mkfs >>$seqres.full 2>&1
124 _run_btrfs_util_prog receive -f $send_files_dir/1.snap $SCRATCH_MNT
125 run_check $FSSUM_PROG -r $send_files_dir/1.fssum $SCRATCH_MNT/mysnap1
126 _run_btrfs_util_prog receive -f $send_files_dir/2.snap $SCRATCH_MNT
127 run_check $FSSUM_PROG -r $send_files_dir/2.fssum $SCRATCH_MNT/mysnap2
129 echo "Silence is golden"