fsx/fsstress: round blocksize properly
[xfstests-dev.git] / tests / btrfs / 145
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2017 SUSE Linux Products GmbH. All Rights Reserved.
4 #
5 # FS QA Test No. btrfs/145
6 #
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.
10 #
11 seq=`basename $0`
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
14
15 tmp=/tmp/$$
16 status=1        # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
18
19 _cleanup()
20 {
21         cd /
22         rm -fr $send_files_dir
23         rm -f $tmp.*
24 }
25
26 # get standard environment, filters and checks
27 . ./common/rc
28 . ./common/filter
29
30 # real QA test starts here
31 _supported_fs btrfs
32 _require_test
33 _require_scratch
34 _require_fssum
35
36 send_files_dir=$TEST_DIR/btrfs-test-$seq
37
38 rm -f $seqres.full
39 rm -fr $send_files_dir
40 mkdir $send_files_dir
41
42 _scratch_mkfs >>$seqres.full 2>&1
43 _scratch_mount
44
45 mkdir $SCRATCH_MNT/dir1
46 mkdir $SCRATCH_MNT/dir1/dir2
47 touch $SCRATCH_MNT/dir1/dir2/file1
48 touch $SCRATCH_MNT/dir1/dir2/file2
49 touch $SCRATCH_MNT/dir1/dir2/file3
50 mkdir $SCRATCH_MNT/dir1/dir3
51 mv $SCRATCH_MNT/dir1/dir2/file2 $SCRATCH_MNT/dir1/dir3/file22
52 mkdir $SCRATCH_MNT/dir1/dir3/dir4
53
54 # Filesystem looks like:
55 #
56 # .                                                      (ino 256)
57 # |
58 # |--- dir1/                                             (ino 257)
59 #       |--- dir2/                                       (ino 258)
60 #       |     |--- file1                                 (ino 259)
61 #       |     |--- file3                                 (ino 261)
62 #       |
63 #       |--- dir3/                                       (ino 262)
64 #             |--- file22                                (ino 260)
65 #             |--- dir4/                                 (ino 263)
66 #
67 $BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT \
68         $SCRATCH_MNT/mysnap1 > /dev/null
69
70 $BTRFS_UTIL_PROG send -f $send_files_dir/1.snap \
71         $SCRATCH_MNT/mysnap1 2>&1 1>/dev/null | _filter_scratch
72
73 mv $SCRATCH_MNT/dir1/dir2/file3 $SCRATCH_MNT/dir1/dir3/dir4/file33
74 mv $SCRATCH_MNT/dir1/dir2/file1 $SCRATCH_MNT/dir1/dir3/dir4/file11
75 mv $SCRATCH_MNT/dir1/dir3 $SCRATCH_MNT/dir1/file3
76 mv $SCRATCH_MNT/dir1/file3/file22 $SCRATCH_MNT/dir1/dir3
77
78 # Filesystem now looks like:
79 #
80 # .                                                      (ino 256)
81 # |
82 # |--- dir1/                                             (ino 257)
83 #       |--- dir2/                                       (ino 258)
84 #       |--- dir3                                        (ino 260)
85 #       |--- file3/                                      (ino 262)
86 #             |--- dir4/                                 (ino 263)
87 #                   |--- file11                          (ino 269)
88 #                   |--- file33                          (ino 261)
89 #
90 $BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT \
91                  $SCRATCH_MNT/mysnap2 > /dev/null
92
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
95
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
99
100 # Now recreate the filesystem by receiving both send streams and verify we get
101 # the same content that the original filesystem had.
102 _scratch_unmount
103 _scratch_mkfs >>$seqres.full 2>&1
104 _scratch_mount
105
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
110
111 status=0
112 exit