2 # FS QA Test No. btrfs/145
4 # Test that an incremental send works if we rename some directory inode A and
5 # then rename some file inode B to the name inode A had, for the case where the
6 # directory inode A is an ancestor of inode B in the parent snapshot.
8 #-----------------------------------------------------------------------
10 # Copyright (C) 2017 SUSE Linux Products GmbH. All Rights Reserved.
11 # Author: Filipe Manana <fdmanana@suse.com>
13 # This program is free software; you can redistribute it and/or
14 # modify it under the terms of the GNU General Public License as
15 # published by the Free Software Foundation.
17 # This program is distributed in the hope that it would be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write the Free Software Foundation,
24 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #-----------------------------------------------------------------------
29 seqres=$RESULT_DIR/$seq
30 echo "QA output created by $seq"
33 status=1 # failure is the default!
34 trap "_cleanup; exit \$status" 0 1 2 3 15
39 rm -fr $send_files_dir
43 # get standard environment, filters and checks
47 # real QA test starts here
54 send_files_dir=$TEST_DIR/btrfs-test-$seq
57 rm -fr $send_files_dir
60 _scratch_mkfs >>$seqres.full 2>&1
63 mkdir $SCRATCH_MNT/dir1
64 mkdir $SCRATCH_MNT/dir1/dir2
65 touch $SCRATCH_MNT/dir1/dir2/file1
66 touch $SCRATCH_MNT/dir1/dir2/file2
67 touch $SCRATCH_MNT/dir1/dir2/file3
68 mkdir $SCRATCH_MNT/dir1/dir3
69 mv $SCRATCH_MNT/dir1/dir2/file2 $SCRATCH_MNT/dir1/dir3/file22
70 mkdir $SCRATCH_MNT/dir1/dir3/dir4
72 # Filesystem looks like:
76 # |--- dir1/ (ino 257)
77 # |--- dir2/ (ino 258)
78 # | |--- file1 (ino 259)
79 # | |--- file3 (ino 261)
81 # |--- dir3/ (ino 262)
82 # |--- file22 (ino 260)
83 # |--- dir4/ (ino 263)
85 $BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT \
86 $SCRATCH_MNT/mysnap1 > /dev/null
88 $BTRFS_UTIL_PROG send -f $send_files_dir/1.snap \
89 $SCRATCH_MNT/mysnap1 2>&1 1>/dev/null | _filter_scratch
91 mv $SCRATCH_MNT/dir1/dir2/file3 $SCRATCH_MNT/dir1/dir3/dir4/file33
92 mv $SCRATCH_MNT/dir1/dir2/file1 $SCRATCH_MNT/dir1/dir3/dir4/file11
93 mv $SCRATCH_MNT/dir1/dir3 $SCRATCH_MNT/dir1/file3
94 mv $SCRATCH_MNT/dir1/file3/file22 $SCRATCH_MNT/dir1/dir3
96 # Filesystem now looks like:
100 # |--- dir1/ (ino 257)
101 # |--- dir2/ (ino 258)
102 # |--- dir3 (ino 260)
103 # |--- file3/ (ino 262)
104 # |--- dir4/ (ino 263)
105 # |--- file11 (ino 269)
106 # |--- file33 (ino 261)
108 $BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT \
109 $SCRATCH_MNT/mysnap2 > /dev/null
111 $BTRFS_UTIL_PROG send -p $SCRATCH_MNT/mysnap1 -f $send_files_dir/2.snap \
112 $SCRATCH_MNT/mysnap2 2>&1 1>/dev/null | _filter_scratch
114 $FSSUM_PROG -A -f -w $send_files_dir/1.fssum $SCRATCH_MNT/mysnap1
115 $FSSUM_PROG -A -f -w $send_files_dir/2.fssum \
116 -x $SCRATCH_MNT/mysnap2/mysnap1 $SCRATCH_MNT/mysnap2
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 $BTRFS_UTIL_PROG receive -f $send_files_dir/1.snap $SCRATCH_MNT > /dev/null
125 $BTRFS_UTIL_PROG receive -f $send_files_dir/2.snap $SCRATCH_MNT > /dev/null
126 $FSSUM_PROG -r $send_files_dir/1.fssum $SCRATCH_MNT/mysnap1
127 $FSSUM_PROG -r $send_files_dir/2.fssum $SCRATCH_MNT/mysnap2