2 # FS QA Test No. btrfs/077
4 # Regression test for a btrfs incremental send issue.
5 # If between two snapshots we rename an existing directory named X to Y and
6 # make it a child (direct or not) of a new inode named X, we were delaying
7 # the move/rename of the former directory unnecessarily, which would result
8 # in attempting to rename the new directory from its orphan name to name X
9 # prematurely. This made btrfs receive fail with an error message like the
12 # rename o261-7-0 -> merlin/RC/OSD failed
14 # This issue was a regression in the 3.16 kernel and got fixed by the following
15 # linux kernel btrfs patch:
17 # Btrfs: send, don't delay dir move if there's a new parent inode
19 #-----------------------------------------------------------------------
20 # Copyright (C) 2014 SUSE Linux Products GmbH. All Rights Reserved.
21 # Author: Filipe Manana <fdmanana@suse.com>
23 # This program is free software; you can redistribute it and/or
24 # modify it under the terms of the GNU General Public License as
25 # published by the Free Software Foundation.
27 # This program is distributed in the hope that it would be useful,
28 # but WITHOUT ANY WARRANTY; without even the implied warranty of
29 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 # GNU General Public License for more details.
32 # You should have received a copy of the GNU General Public License
33 # along with this program; if not, write the Free Software Foundation,
34 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
35 #-----------------------------------------------------------------------
39 seqres=$RESULT_DIR/$seq
40 echo "QA output created by $seq"
43 status=1 # failure is the default!
44 trap "_cleanup; exit \$status" 0 1 2 3 15
48 rm -fr $send_files_dir
52 # get standard environment, filters and checks
56 # real QA test starts here
62 send_files_dir=$TEST_DIR/btrfs-test-$seq
65 rm -fr $send_files_dir
68 _scratch_mkfs >>$seqres.full 2>&1
71 mkdir -p $SCRATCH_MNT/merlin/RC/OSD/Source
72 mkdir -p $SCRATCH_MNT/fdm/RCz/OSDz/Sourcez
73 mkdir -p $SCRATCH_MNT/Z/Z2
75 # Filesystem looks like:
78 # |---- merlin/ (ino 257)
79 # | |---- RC/ (ino 258)
80 # | |----- OSD/ (ino 259)
81 # | |---- Source/ (ino 260)
83 # |---- fdm/ (ino 261)
84 # | |---- RCz/ (ino 262)
85 # | |----- OSDz/ (ino 263)
86 # | |---- Sourcez/ (ino 264)
91 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap1
93 mkdir $SCRATCH_MNT/OSD
94 mv $SCRATCH_MNT/merlin/RC/OSD $SCRATCH_MNT/OSD/OSD-Plane_788
95 mv $SCRATCH_MNT/OSD $SCRATCH_MNT/merlin/RC
97 mkdir $SCRATCH_MNT/OSDz
98 mv $SCRATCH_MNT/Z/Z2 $SCRATCH_MNT/OSDz/xz2
99 mv $SCRATCH_MNT/Z $SCRATCH_MNT/OSDz/xz2/xz
100 mv $SCRATCH_MNT/fdm/RCz/OSDz $SCRATCH_MNT/OSDz/xz2/xz/OSD-Plane_788z
101 mv $SCRATCH_MNT/OSDz $SCRATCH_MNT/fdm/RCz
103 # Filesystem now looks like:
107 # |---- merlin/ (ino 257)
108 # | |---- RC/ (ino 258)
109 # | |----- OSD/ (ino 267) (new)
110 # | |---- OSD-Plane_788/ (ino 259)
111 # | |---- Source/ (ino 260)
113 # |---- fdm/ (ino 261)
114 # |---- RCz/ (ino 262)
115 # |----- OSDz/ (ino 268) (new)
116 # |--- xz2/ (ino 266)
117 # |---- xz/ (ino 265)
118 # |---- OSD-Plane_788z/ (ino 263)
119 # |---- Sourcez/ (ino 264)
122 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap2
124 run_check $FSSUM_PROG -A -f -w $send_files_dir/1.fssum $SCRATCH_MNT/mysnap1
125 run_check $FSSUM_PROG -A -f -w $send_files_dir/2.fssum \
126 -x $SCRATCH_MNT/mysnap2/mysnap1 $SCRATCH_MNT/mysnap2
128 _run_btrfs_util_prog send -f $send_files_dir/1.snap $SCRATCH_MNT/mysnap1
129 _run_btrfs_util_prog send -p $SCRATCH_MNT/mysnap1 -f $send_files_dir/2.snap \
135 _scratch_mkfs >>$seqres.full 2>&1
138 _run_btrfs_util_prog receive -f $send_files_dir/1.snap $SCRATCH_MNT
139 run_check $FSSUM_PROG -r $send_files_dir/1.fssum $SCRATCH_MNT/mysnap1
141 _run_btrfs_util_prog receive -f $send_files_dir/2.snap $SCRATCH_MNT
142 run_check $FSSUM_PROG -r $send_files_dir/2.fssum $SCRATCH_MNT/mysnap2
144 echo "Silence is golden"