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
45 send_files_dir=$TEST_DIR/btrfs-test-$seq
48 rm -fr $send_files_dir
51 _scratch_mkfs >>$seqres.full 2>&1
54 mkdir -p $SCRATCH_MNT/merlin/RC/OSD/Source
55 mkdir -p $SCRATCH_MNT/fdm/RCz/OSDz/Sourcez
56 mkdir -p $SCRATCH_MNT/Z/Z2
58 # Filesystem looks like:
61 # |---- merlin/ (ino 257)
62 # | |---- RC/ (ino 258)
63 # | |----- OSD/ (ino 259)
64 # | |---- Source/ (ino 260)
66 # |---- fdm/ (ino 261)
67 # | |---- RCz/ (ino 262)
68 # | |----- OSDz/ (ino 263)
69 # | |---- Sourcez/ (ino 264)
74 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap1
76 mkdir $SCRATCH_MNT/OSD
77 mv $SCRATCH_MNT/merlin/RC/OSD $SCRATCH_MNT/OSD/OSD-Plane_788
78 mv $SCRATCH_MNT/OSD $SCRATCH_MNT/merlin/RC
80 mkdir $SCRATCH_MNT/OSDz
81 mv $SCRATCH_MNT/Z/Z2 $SCRATCH_MNT/OSDz/xz2
82 mv $SCRATCH_MNT/Z $SCRATCH_MNT/OSDz/xz2/xz
83 mv $SCRATCH_MNT/fdm/RCz/OSDz $SCRATCH_MNT/OSDz/xz2/xz/OSD-Plane_788z
84 mv $SCRATCH_MNT/OSDz $SCRATCH_MNT/fdm/RCz
86 # Filesystem now looks like:
90 # |---- merlin/ (ino 257)
91 # | |---- RC/ (ino 258)
92 # | |----- OSD/ (ino 267) (new)
93 # | |---- OSD-Plane_788/ (ino 259)
94 # | |---- Source/ (ino 260)
96 # |---- fdm/ (ino 261)
97 # |---- RCz/ (ino 262)
98 # |----- OSDz/ (ino 268) (new)
100 # |---- xz/ (ino 265)
101 # |---- OSD-Plane_788z/ (ino 263)
102 # |---- Sourcez/ (ino 264)
105 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap2
107 run_check $FSSUM_PROG -A -f -w $send_files_dir/1.fssum $SCRATCH_MNT/mysnap1
108 run_check $FSSUM_PROG -A -f -w $send_files_dir/2.fssum \
109 -x $SCRATCH_MNT/mysnap2/mysnap1 $SCRATCH_MNT/mysnap2
111 _run_btrfs_util_prog send -f $send_files_dir/1.snap $SCRATCH_MNT/mysnap1
112 _run_btrfs_util_prog send -p $SCRATCH_MNT/mysnap1 -f $send_files_dir/2.snap \
118 _scratch_mkfs >>$seqres.full 2>&1
121 _run_btrfs_util_prog receive -f $send_files_dir/1.snap $SCRATCH_MNT
122 run_check $FSSUM_PROG -r $send_files_dir/1.fssum $SCRATCH_MNT/mysnap1
124 _run_btrfs_util_prog receive -f $send_files_dir/2.snap $SCRATCH_MNT
125 run_check $FSSUM_PROG -r $send_files_dir/2.fssum $SCRATCH_MNT/mysnap2
127 echo "Silence is golden"