fstests: move test group info to test files
[xfstests-dev.git] / tests / btrfs / 077
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2014 SUSE Linux Products GmbH. All Rights Reserved.
4 #
5 # FS QA Test No. btrfs/077
6 #
7 # Regression test for a btrfs incremental send issue.
8 # If between two snapshots we rename an existing directory named X to Y and
9 # make it a child (direct or not) of a new inode named X, we were delaying
10 # the move/rename of the former directory unnecessarily, which would result
11 # in attempting to rename the new directory from its orphan name to name X
12 # prematurely. This made btrfs receive fail with an error message like the
13 # following:
14 #
15 #   rename o261-7-0 -> merlin/RC/OSD failed
16 #
17 # This issue was a regression in the 3.16 kernel and got fixed by the following
18 # linux kernel btrfs patch:
19 #
20 #   Btrfs: send, don't delay dir move if there's a new parent inode
21 #
22 . ./common/preamble
23 _begin_fstest auto quick send snapshot
24
25 tmp=`mktemp -d`
26
27 # Override the default cleanup function.
28 _cleanup()
29 {
30     rm -fr $send_files_dir
31     rm -fr $tmp
32 }
33
34 # Import common functions.
35 . ./common/filter
36
37 # real QA test starts here
38 _supported_fs btrfs
39 _require_scratch
40 _require_fssum
41
42 send_files_dir=$TEST_DIR/btrfs-test-$seq
43
44 rm -fr $send_files_dir
45 mkdir $send_files_dir
46
47 _scratch_mkfs >>$seqres.full 2>&1
48 _scratch_mount
49
50 mkdir -p $SCRATCH_MNT/merlin/RC/OSD/Source
51 mkdir -p $SCRATCH_MNT/fdm/RCz/OSDz/Sourcez
52 mkdir -p $SCRATCH_MNT/Z/Z2
53
54 # Filesystem looks like:
55 #
56 # .                                                 (ino 256)
57 # |---- merlin/                                     (ino 257)
58 # |        |---- RC/                                (ino 258)
59 # |              |----- OSD/                        (ino 259)
60 # |                      |---- Source/              (ino 260)
61 # |
62 # |---- fdm/                                        (ino 261)
63 # |       |---- RCz/                                (ino 262)
64 # |             |----- OSDz/                        (ino 263)
65 # |                     |---- Sourcez/              (ino 264)
66 # |
67 # |---- Z/                                          (ino 265)
68 #       |---- Z2/                                   (ino 266)
69 #
70 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap1
71
72 mkdir $SCRATCH_MNT/OSD
73 mv $SCRATCH_MNT/merlin/RC/OSD $SCRATCH_MNT/OSD/OSD-Plane_788
74 mv $SCRATCH_MNT/OSD $SCRATCH_MNT/merlin/RC
75
76 mkdir $SCRATCH_MNT/OSDz
77 mv $SCRATCH_MNT/Z/Z2 $SCRATCH_MNT/OSDz/xz2
78 mv $SCRATCH_MNT/Z $SCRATCH_MNT/OSDz/xz2/xz
79 mv $SCRATCH_MNT/fdm/RCz/OSDz $SCRATCH_MNT/OSDz/xz2/xz/OSD-Plane_788z
80 mv $SCRATCH_MNT/OSDz $SCRATCH_MNT/fdm/RCz
81
82 # Filesystem now looks like:
83 #
84 #
85 # .                                                                  (ino 256)
86 # |---- merlin/                                                      (ino 257)
87 # |       |---- RC/                                                  (ino 258)
88 # |             |----- OSD/                                     (ino 267) (new)
89 # |                     |---- OSD-Plane_788/                         (ino 259)
90 # |                                    |---- Source/                 (ino 260)
91 # |
92 # |---- fdm/                                                         (ino 261)
93 #         |---- RCz/                                                 (ino 262)
94 #                |----- OSDz/                                   (ino 268) (new)
95 #                        |--- xz2/                                   (ino 266)
96 #                              |---- xz/                             (ino 265)
97 #                                    |---- OSD-Plane_788z/           (ino 263)
98 #                                                    |---- Sourcez/  (ino 264)
99 #
100
101 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap2
102
103 run_check $FSSUM_PROG -A -f -w $send_files_dir/1.fssum $SCRATCH_MNT/mysnap1
104 run_check $FSSUM_PROG -A -f -w $send_files_dir/2.fssum \
105         -x $SCRATCH_MNT/mysnap2/mysnap1 $SCRATCH_MNT/mysnap2
106
107 _run_btrfs_util_prog send -f $send_files_dir/1.snap $SCRATCH_MNT/mysnap1
108 _run_btrfs_util_prog send -p $SCRATCH_MNT/mysnap1 -f $send_files_dir/2.snap \
109         $SCRATCH_MNT/mysnap2
110
111 _check_scratch_fs
112
113 _scratch_unmount
114 _scratch_mkfs >>$seqres.full 2>&1
115 _scratch_mount
116
117 _run_btrfs_util_prog receive -f $send_files_dir/1.snap $SCRATCH_MNT
118 run_check $FSSUM_PROG -r $send_files_dir/1.fssum $SCRATCH_MNT/mysnap1
119
120 _run_btrfs_util_prog receive -f $send_files_dir/2.snap $SCRATCH_MNT
121 run_check $FSSUM_PROG -r $send_files_dir/2.fssum $SCRATCH_MNT/mysnap2
122
123 echo "Silence is golden"
124
125 status=0
126 exit