2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2017 SUSE Linux Products GmbH. All Rights Reserved.
5 # FS QA Test No. btrfs/145
7 # Test that an incremental send works if we rename some directory inode A and
8 # then rename some file inode B to the name inode A had, for the case where the
9 # directory inode A is an ancestor of inode B in the parent snapshot.
12 _begin_fstest auto quick send
14 # Override the default cleanup function.
18 rm -fr $send_files_dir
22 # Import common functions.
25 # real QA test starts here
31 send_files_dir=$TEST_DIR/btrfs-test-$seq
33 rm -fr $send_files_dir
36 _scratch_mkfs >>$seqres.full 2>&1
39 mkdir $SCRATCH_MNT/dir1
40 mkdir $SCRATCH_MNT/dir1/dir2
41 touch $SCRATCH_MNT/dir1/dir2/file1
42 touch $SCRATCH_MNT/dir1/dir2/file2
43 touch $SCRATCH_MNT/dir1/dir2/file3
44 mkdir $SCRATCH_MNT/dir1/dir3
45 mv $SCRATCH_MNT/dir1/dir2/file2 $SCRATCH_MNT/dir1/dir3/file22
46 mkdir $SCRATCH_MNT/dir1/dir3/dir4
48 # Filesystem looks like:
52 # |--- dir1/ (ino 257)
53 # |--- dir2/ (ino 258)
54 # | |--- file1 (ino 259)
55 # | |--- file3 (ino 261)
57 # |--- dir3/ (ino 262)
58 # |--- file22 (ino 260)
59 # |--- dir4/ (ino 263)
61 $BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT \
62 $SCRATCH_MNT/mysnap1 > /dev/null
64 $BTRFS_UTIL_PROG send -f $send_files_dir/1.snap \
65 $SCRATCH_MNT/mysnap1 2>&1 1>/dev/null | _filter_scratch
67 mv $SCRATCH_MNT/dir1/dir2/file3 $SCRATCH_MNT/dir1/dir3/dir4/file33
68 mv $SCRATCH_MNT/dir1/dir2/file1 $SCRATCH_MNT/dir1/dir3/dir4/file11
69 mv $SCRATCH_MNT/dir1/dir3 $SCRATCH_MNT/dir1/file3
70 mv $SCRATCH_MNT/dir1/file3/file22 $SCRATCH_MNT/dir1/dir3
72 # Filesystem now looks like:
76 # |--- dir1/ (ino 257)
77 # |--- dir2/ (ino 258)
79 # |--- file3/ (ino 262)
80 # |--- dir4/ (ino 263)
81 # |--- file11 (ino 269)
82 # |--- file33 (ino 261)
84 $BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT \
85 $SCRATCH_MNT/mysnap2 > /dev/null
87 $BTRFS_UTIL_PROG send -p $SCRATCH_MNT/mysnap1 -f $send_files_dir/2.snap \
88 $SCRATCH_MNT/mysnap2 2>&1 1>/dev/null | _filter_scratch
90 $FSSUM_PROG -A -f -w $send_files_dir/1.fssum $SCRATCH_MNT/mysnap1
91 $FSSUM_PROG -A -f -w $send_files_dir/2.fssum \
92 -x $SCRATCH_MNT/mysnap2/mysnap1 $SCRATCH_MNT/mysnap2
94 # Now recreate the filesystem by receiving both send streams and verify we get
95 # the same content that the original filesystem had.
97 _scratch_mkfs >>$seqres.full 2>&1
100 $BTRFS_UTIL_PROG receive -f $send_files_dir/1.snap $SCRATCH_MNT > /dev/null
101 $BTRFS_UTIL_PROG receive -f $send_files_dir/2.snap $SCRATCH_MNT > /dev/null
102 $FSSUM_PROG -r $send_files_dir/1.fssum $SCRATCH_MNT/mysnap1
103 $FSSUM_PROG -r $send_files_dir/2.fssum $SCRATCH_MNT/mysnap2