2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2014 SUSE Linux Products GmbH. All Rights Reserved.
5 # FS QA Test No. btrfs/077
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
15 # rename o261-7-0 -> merlin/RC/OSD failed
17 # This issue was a regression in the 3.16 kernel and got fixed by the following
18 # linux kernel btrfs patch:
20 # Btrfs: send, don't delay dir move if there's a new parent inode
23 seqres=$RESULT_DIR/$seq
24 echo "QA output created by $seq"
27 status=1 # failure is the default!
28 trap "_cleanup; exit \$status" 0 1 2 3 15
32 rm -fr $send_files_dir
36 # get standard environment, filters and checks
40 # real QA test starts here
46 send_files_dir=$TEST_DIR/btrfs-test-$seq
49 rm -fr $send_files_dir
52 _scratch_mkfs >>$seqres.full 2>&1
55 mkdir -p $SCRATCH_MNT/merlin/RC/OSD/Source
56 mkdir -p $SCRATCH_MNT/fdm/RCz/OSDz/Sourcez
57 mkdir -p $SCRATCH_MNT/Z/Z2
59 # Filesystem looks like:
62 # |---- merlin/ (ino 257)
63 # | |---- RC/ (ino 258)
64 # | |----- OSD/ (ino 259)
65 # | |---- Source/ (ino 260)
67 # |---- fdm/ (ino 261)
68 # | |---- RCz/ (ino 262)
69 # | |----- OSDz/ (ino 263)
70 # | |---- Sourcez/ (ino 264)
75 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap1
77 mkdir $SCRATCH_MNT/OSD
78 mv $SCRATCH_MNT/merlin/RC/OSD $SCRATCH_MNT/OSD/OSD-Plane_788
79 mv $SCRATCH_MNT/OSD $SCRATCH_MNT/merlin/RC
81 mkdir $SCRATCH_MNT/OSDz
82 mv $SCRATCH_MNT/Z/Z2 $SCRATCH_MNT/OSDz/xz2
83 mv $SCRATCH_MNT/Z $SCRATCH_MNT/OSDz/xz2/xz
84 mv $SCRATCH_MNT/fdm/RCz/OSDz $SCRATCH_MNT/OSDz/xz2/xz/OSD-Plane_788z
85 mv $SCRATCH_MNT/OSDz $SCRATCH_MNT/fdm/RCz
87 # Filesystem now looks like:
91 # |---- merlin/ (ino 257)
92 # | |---- RC/ (ino 258)
93 # | |----- OSD/ (ino 267) (new)
94 # | |---- OSD-Plane_788/ (ino 259)
95 # | |---- Source/ (ino 260)
97 # |---- fdm/ (ino 261)
98 # |---- RCz/ (ino 262)
99 # |----- OSDz/ (ino 268) (new)
100 # |--- xz2/ (ino 266)
101 # |---- xz/ (ino 265)
102 # |---- OSD-Plane_788z/ (ino 263)
103 # |---- Sourcez/ (ino 264)
106 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap2
108 run_check $FSSUM_PROG -A -f -w $send_files_dir/1.fssum $SCRATCH_MNT/mysnap1
109 run_check $FSSUM_PROG -A -f -w $send_files_dir/2.fssum \
110 -x $SCRATCH_MNT/mysnap2/mysnap1 $SCRATCH_MNT/mysnap2
112 _run_btrfs_util_prog send -f $send_files_dir/1.snap $SCRATCH_MNT/mysnap1
113 _run_btrfs_util_prog send -p $SCRATCH_MNT/mysnap1 -f $send_files_dir/2.snap \
119 _scratch_mkfs >>$seqres.full 2>&1
122 _run_btrfs_util_prog receive -f $send_files_dir/1.snap $SCRATCH_MNT
123 run_check $FSSUM_PROG -r $send_files_dir/1.fssum $SCRATCH_MNT/mysnap1
125 _run_btrfs_util_prog receive -f $send_files_dir/2.snap $SCRATCH_MNT
126 run_check $FSSUM_PROG -r $send_files_dir/2.fssum $SCRATCH_MNT/mysnap2
128 echo "Silence is golden"