common/fuzzy: try to clear blocking flags first in _scratch_fuzz_modify
[xfstests-dev.git] / tests / btrfs / 084
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2015 SUSE Linux Products GmbH. All Rights Reserved.
4 #
5 # FS QA Test No. btrfs/084
6 #
7 # Test for incremental send where the difference between the parent and send
8 # snapshots is that for a subtree with the same path in both snapshots (p1/p2),
9 # the root directories were swapped.
10 #
11 # This issue was fixed by the following linux kernel btrfs patch:
12 #
13 #   Btrfs: incremental send, clear name from cache after orphanization
14 #
15 seq=`basename $0`
16 seqres=$RESULT_DIR/$seq
17 echo "QA output created by $seq"
18
19 tmp=/tmp/$$
20 status=1        # failure is the default!
21 trap "_cleanup; exit \$status" 0 1 2 3 15
22
23 _cleanup()
24 {
25         rm -fr $send_files_dir
26         rm -f $tmp.*
27 }
28
29 # get standard environment, filters and checks
30 . ./common/rc
31 . ./common/filter
32
33 # real QA test starts here
34 _supported_fs btrfs
35 _supported_os Linux
36 _require_scratch
37 _require_fssum
38
39 send_files_dir=$TEST_DIR/btrfs-test-$seq
40
41 rm -f $seqres.full
42 rm -fr $send_files_dir
43 mkdir $send_files_dir
44
45 _scratch_mkfs >>$seqres.full 2>&1
46 _scratch_mount
47
48 mkdir -p $SCRATCH_MNT/data/n1/n2/p1/p2
49 mkdir $SCRATCH_MNT/data/n4
50 mkdir -p $SCRATCH_MNT/data/p1/p2
51
52 # Filesystem looks like:
53 #
54 # .                                       (ino 256)
55 # |---- data                              (ino 257)
56 #         |---- n1/                       (ino 258)
57 #         |     |---- n2/                 (ino 259)
58 #         |           |---- p1/           (ino 260)
59 #         |                 |---- p2/     (ino 261)
60 #         |
61 #         |---- n4/                       (ino 262)
62 #         |---- p1/                       (ino 263)
63 #               |---- p2/                 (ino 264)
64 #
65 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap1
66
67 # Now move directories around such that for the subtrees with the path "p1/p2"
68 # we end up swapping the parents, that is, inode 263 becomes the parent of
69 # inode 261 and inode 260 becomes the parent of inode 264. This makes the send
70 # stream orphanize the inodes 263 and 264, and we want to verify the respective
71 # rename operations don't fail, that they don't use incorrect paths.
72 mv $SCRATCH_MNT/data/p1/p2 $SCRATCH_MNT/data
73 mv $SCRATCH_MNT/data/n1/n2/p1/p2 $SCRATCH_MNT/data/p1
74 mv $SCRATCH_MNT/data/p2 $SCRATCH_MNT/data/n1/n2/p1
75 mv $SCRATCH_MNT/data/n1/n2 $SCRATCH_MNT/data/p1
76 mv $SCRATCH_MNT/data/p1 $SCRATCH_MNT/data/n4
77 mv $SCRATCH_MNT/data/n4/p1/n2/p1 $SCRATCH_MNT/data
78
79 # Filesystem now looks like:
80 #
81 # .                                       (ino 256)
82 # |---- data                              (ino 257)
83 #         |---- n1/                       (ino 258)
84 #         |---- n4/                       (ino 262)
85 #         |     |---- p1/                 (ino 263)
86 #         |           |---- n2/           (ino 259)
87 #         |           |---- p2/           (ino 261)
88 #         |
89 #         |---- p1/                       (ino 260)
90 #               |---- p2/                 (ino 264)
91 #
92 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap2
93
94 run_check $FSSUM_PROG -A -f -w $send_files_dir/1.fssum $SCRATCH_MNT/mysnap1
95 run_check $FSSUM_PROG -A -f -w $send_files_dir/2.fssum \
96         -x $SCRATCH_MNT/mysnap2/mysnap1 $SCRATCH_MNT/mysnap2
97
98 _run_btrfs_util_prog send -f $send_files_dir/1.snap $SCRATCH_MNT/mysnap1
99 _run_btrfs_util_prog send -p $SCRATCH_MNT/mysnap1 -f $send_files_dir/2.snap \
100         $SCRATCH_MNT/mysnap2
101
102 # Now recreate the filesystem by receiving both send streams and verify we get
103 # the same content that the original filesystem had.
104 _scratch_unmount
105 _scratch_mkfs >>$seqres.full 2>&1
106 _scratch_mount
107
108 _run_btrfs_util_prog receive -f $send_files_dir/1.snap $SCRATCH_MNT
109 run_check $FSSUM_PROG -r $send_files_dir/1.fssum $SCRATCH_MNT/mysnap1
110 _run_btrfs_util_prog receive -f $send_files_dir/2.snap $SCRATCH_MNT
111 run_check $FSSUM_PROG -r $send_files_dir/2.fssum $SCRATCH_MNT/mysnap2
112
113 echo "Silence is golden"
114 status=0
115 exit