xfs: force file creation to the data device for certain layout tests
[xfstests-dev.git] / tests / btrfs / 178
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/178
6 #
7 # Test an incremental send operation in a scenario where the relationship of
8 # ancestor-descendant between multiple directories is inversed, and where
9 # multiple directories that were previously ancestors of another directory now
10 # become descendents of multiple directories that used to be their ancestors in
11 # the parent snapshot. This used to trigger an infinite loop in the kernel code.
12 #
13 seq=`basename $0`
14 seqres=$RESULT_DIR/$seq
15 echo "QA output created by $seq"
16
17 tmp=/tmp/$$
18 status=1        # failure is the default!
19 trap "_cleanup; exit \$status" 0 1 2 3 15
20
21 _cleanup()
22 {
23         cd /
24         rm -fr $send_files_dir
25         rm -f $tmp.*
26 }
27
28 # get standard environment, filters and checks
29 . ./common/rc
30 . ./common/filter
31
32 # real QA test starts here
33 _supported_fs btrfs
34 _require_test
35 _require_scratch
36 _require_fssum
37
38 send_files_dir=$TEST_DIR/btrfs-test-$seq
39
40 rm -f $seqres.full
41 rm -fr $send_files_dir
42 mkdir $send_files_dir
43
44 _scratch_mkfs >>$seqres.full 2>&1
45 _scratch_mount
46
47 # The name of each directory corresponds to its inode number, to make it easier
48 # to debug since btrfs' send processes inodes in ascending order according to
49 # their number.
50 mkdir $SCRATCH_MNT/257
51 mkdir $SCRATCH_MNT/258
52 mv $SCRATCH_MNT/257 $SCRATCH_MNT/258/257
53 mkdir $SCRATCH_MNT/259
54 mkdir $SCRATCH_MNT/260
55 mkdir $SCRATCH_MNT/261
56 mkdir $SCRATCH_MNT/262
57 mkdir $SCRATCH_MNT/263
58 mkdir $SCRATCH_MNT/264
59 mv $SCRATCH_MNT/258 $SCRATCH_MNT/264/258
60 mkdir $SCRATCH_MNT/265
61 mkdir $SCRATCH_MNT/266
62 mv $SCRATCH_MNT/259 $SCRATCH_MNT/266/259
63 mv $SCRATCH_MNT/260 $SCRATCH_MNT/266/260
64 mv $SCRATCH_MNT/264 $SCRATCH_MNT/266/264
65 mv $SCRATCH_MNT/265 $SCRATCH_MNT/266/265
66 mkdir $SCRATCH_MNT/266/260/267
67 mkdir $SCRATCH_MNT/266/268
68 mkdir $SCRATCH_MNT/266/269
69 mv $SCRATCH_MNT/262 $SCRATCH_MNT/266/269/262
70 mkdir $SCRATCH_MNT/266/270
71 mkdir $SCRATCH_MNT/271
72 mv $SCRATCH_MNT/266 $SCRATCH_MNT/271/266
73 mkdir $SCRATCH_MNT/271/266/272
74 mv $SCRATCH_MNT/263 $SCRATCH_MNT/271/266/272/263
75 mkdir $SCRATCH_MNT/273
76 mkdir $SCRATCH_MNT/271/266/274
77 mv $SCRATCH_MNT/273 $SCRATCH_MNT/271/266/274/273
78 mkdir $SCRATCH_MNT/271/266/272/275
79 mv $SCRATCH_MNT/271 $SCRATCH_MNT/261/271
80
81 # Filesystem looks like:
82 #
83 # .
84 # |--- 261/
85 #       |--- 271/
86 #             |--- 266/
87 #                   |--- 259/
88 #                   |--- 260/
89 #                   |     |--- 267
90 #                   |
91 #                   |--- 264/
92 #                   |     |--- 258/
93 #                   |           |--- 257/
94 #                   |
95 #                   |--- 265/
96 #                   |--- 268/
97 #                   |--- 269/
98 #                   |     |--- 262/
99 #                   |
100 #                   |--- 270/
101 #                   |--- 272/
102 #                   |     |--- 263/
103 #                   |     |--- 275/
104 #                   |
105 #                   |--- 274/
106 #                         |--- 273/
107 #
108 $BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT \
109         $SCRATCH_MNT/mysnap1 > /dev/null
110
111 $BTRFS_UTIL_PROG send -f $send_files_dir/1.snap \
112         $SCRATCH_MNT/mysnap1 2>&1 1>/dev/null | _filter_scratch
113
114 mv $SCRATCH_MNT/261/271/266/272/275 $SCRATCH_MNT/275
115 mv $SCRATCH_MNT/261/271/266/274 $SCRATCH_MNT/275/274
116 mv $SCRATCH_MNT/261/271/266/269/262 $SCRATCH_MNT/275/274/273/262
117 mv $SCRATCH_MNT/261/271/266/269 $SCRATCH_MNT/275/274/273/262/269
118 mv $SCRATCH_MNT/261/271/266/264/258/257 $SCRATCH_MNT/261/271/266/272
119 mv $SCRATCH_MNT/261/271/266/264/258 $SCRATCH_MNT/275/274/273/262/269/258
120 mv $SCRATCH_MNT/261/271 $SCRATCH_MNT/275/274/273/262/269/258/271
121 mv $SCRATCH_MNT/275/274/273/262/269/258/271/266/268 \
122         $SCRATCH_MNT/275/274/273/262/269/258/271/268
123 mv $SCRATCH_MNT/275/274/273/262/269/258/271/266/260/267 \
124         $SCRATCH_MNT/275/274/273/262/269/258/271/268/267
125 mv $SCRATCH_MNT/275/274/273/262/269/258/271/266/270 \
126         $SCRATCH_MNT/275/274/273/262/269/258/271/268/267/270
127 mv $SCRATCH_MNT/275/274/273/262/269/258/271/266/265 \
128         $SCRATCH_MNT/275/274/273/262/269/258/271/266/259/265
129 mv $SCRATCH_MNT/275/274/273/262/269/258/271/266/259 \
130         $SCRATCH_MNT/275/274/273/262/269/258/271/268/267/270/259
131 mv $SCRATCH_MNT/275/274/273/262/269/258/271/266/272/263 \
132         $SCRATCH_MNT/275/274/273/262/269/258/271/266/264/263
133 mv $SCRATCH_MNT/275/274/273/262/269/258/271/266/272 \
134         $SCRATCH_MNT/275/274/273/262/269/258/271/268/267/270/272
135 mv $SCRATCH_MNT/275/274/273/262/269/258/271/266/260 \
136         $SCRATCH_MNT/275/274/273/262/269/258/271/268/267/270/272/257/260
137 mv $SCRATCH_MNT/275/274/273/262/269/258/271/266/264 \
138         $SCRATCH_MNT/275/274/273/262/269/258/271/268/267/270/272/257/264
139 mv $SCRATCH_MNT/261 \
140         $SCRATCH_MNT/275/274/273/262/269/258/271/268/267/270/272/257/264/263/261
141 mv $SCRATCH_MNT/275/274/273/262/269/258/271/266 \
142         $SCRATCH_MNT/275/274/273/262/269/258/271/268/267/270/272/257/264/263/261/266
143
144 # Filesystem now looks like:
145 #
146 # .
147 # |-- 275/
148 #      |-- 274/
149 #           |-- 273/
150 #                |-- 262/
151 #                     |-- 269/
152 #                          |-- 258/
153 #                               |-- 271/
154 #                                    |-- 268/
155 #                                         |-- 267/
156 #                                              |-- 270/
157 #                                                   |-- 259/
158 #                                                   |    |-- 265/
159 #                                                   |
160 #                                                   |-- 272/
161 #                                                        |-- 257/
162 #                                                             |-- 260/
163 #                                                             |-- 264/
164 #                                                                  |-- 263/
165 #                                                                       |-- 261/
166 #                                                                            |-- 266/
167 #
168 $BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT \
169                  $SCRATCH_MNT/mysnap2 > /dev/null
170 $BTRFS_UTIL_PROG send -p $SCRATCH_MNT/mysnap1 -f $send_files_dir/2.snap \
171                  $SCRATCH_MNT/mysnap2 2>&1 1>/dev/null | _filter_scratch
172
173 $FSSUM_PROG -A -f -w $send_files_dir/1.fssum $SCRATCH_MNT/mysnap1
174 $FSSUM_PROG -A -f -w $send_files_dir/2.fssum \
175         -x $SCRATCH_MNT/mysnap2/mysnap1 $SCRATCH_MNT/mysnap2
176
177 # Now recreate the filesystem by receiving both send streams and verify we get
178 # the same content that the original filesystem had.
179 _scratch_unmount
180 _scratch_mkfs >>$seqres.full 2>&1
181 _scratch_mount
182
183 $BTRFS_UTIL_PROG receive -f $send_files_dir/1.snap $SCRATCH_MNT > /dev/null
184 $BTRFS_UTIL_PROG receive -f $send_files_dir/2.snap $SCRATCH_MNT > /dev/null
185 $FSSUM_PROG -r $send_files_dir/1.fssum $SCRATCH_MNT/mysnap1
186 $FSSUM_PROG -r $send_files_dir/2.fssum $SCRATCH_MNT/mysnap2
187
188 status=0
189 exit