2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2017 SUSE Linux Products GmbH. All Rights Reserved.
5 # FS QA Test No. btrfs/147
7 # Test that an incremental send/receive operation works correctly after moving
8 # some directory inode A, renaming a regular file inode B into the old name of
9 # inode A and finally creating a new hard link for inode B at directory inode A.
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
16 status=1 # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
22 rm -fr $send_files_dir
26 # get standard environment, filters and checks
30 # real QA test starts here
36 send_files_dir=$TEST_DIR/btrfs-test-$seq
39 rm -fr $send_files_dir
42 _scratch_mkfs >>$seqres.full 2>&1
45 mkdir $SCRATCH_MNT/dir1
46 mkdir $SCRATCH_MNT/dir1/dir2
47 mkdir $SCRATCH_MNT/dir1/dir2/dir3
48 mkdir $SCRATCH_MNT/dir5
49 touch $SCRATCH_MNT/dir1/dir2/dir3/file1
50 mkdir $SCRATCH_MNT/dir1/dir2/dir3/dir4
52 # Filesystem looks like:
56 # |--- dir1/ (ino 257)
57 # | |--- dir2/ (ino 258)
58 # | |--- dir3/ (ino 259)
59 # | |--- file1 (ino 261)
60 # | |--- dir4/ (ino 262)
62 # |--- dir5/ (ino 260)
64 $BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT \
65 $SCRATCH_MNT/mysnap1 > /dev/null
67 $BTRFS_UTIL_PROG send -f $send_files_dir/1.snap \
68 $SCRATCH_MNT/mysnap1 2>&1 1>/dev/null | _filter_scratch
70 mkdir $SCRATCH_MNT/dir1/dir6
71 mv $SCRATCH_MNT/dir5 $SCRATCH_MNT/dir1/dir2/dir3/dir4/dir55
72 ln $SCRATCH_MNT/dir1/dir2/dir3/file1 $SCRATCH_MNT/dir1/dir2/dir3/dir4/file11
73 mv $SCRATCH_MNT/dir1/dir2/dir3/dir4 $SCRATCH_MNT/dir1/dir6/dir44
74 mv $SCRATCH_MNT/dir1/dir2/dir3/file1 $SCRATCH_MNT/dir1/dir2/dir3/dir4
76 # Filesystem now looks like:
80 # |--- dir1/ (ino 257)
81 # |--- dir2/ (ino 258)
82 # | |--- dir3/ (ino 259)
83 # | |--- dir4 (ino 261)
85 # |--- dir6/ (ino 263)
86 # |--- dir44/ (ino 262)
87 # |--- file11 (ino 261)
88 # |--- dir55/ (ino 260)
90 $BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT \
91 $SCRATCH_MNT/mysnap2 > /dev/null
93 $BTRFS_UTIL_PROG send -p $SCRATCH_MNT/mysnap1 -f $send_files_dir/2.snap \
94 $SCRATCH_MNT/mysnap2 2>&1 1>/dev/null | _filter_scratch
96 $FSSUM_PROG -A -f -w $send_files_dir/1.fssum $SCRATCH_MNT/mysnap1
97 $FSSUM_PROG -A -f -w $send_files_dir/2.fssum \
98 -x $SCRATCH_MNT/mysnap2/mysnap1 $SCRATCH_MNT/mysnap2
100 # Now recreate the filesystem by receiving both send streams and verify we get
101 # the same content that the original filesystem had.
103 _scratch_mkfs >>$seqres.full 2>&1
106 $BTRFS_UTIL_PROG receive -f $send_files_dir/1.snap $SCRATCH_MNT > /dev/null
107 $BTRFS_UTIL_PROG receive -f $send_files_dir/2.snap $SCRATCH_MNT > /dev/null
108 $FSSUM_PROG -r $send_files_dir/1.fssum $SCRATCH_MNT/mysnap1
109 $FSSUM_PROG -r $send_files_dir/2.fssum $SCRATCH_MNT/mysnap2