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 _begin_fstest auto quick send snapshot
27 # Override the default cleanup function.
30 rm -fr $send_files_dir
34 # Import common functions.
37 # real QA test starts here
42 send_files_dir=$TEST_DIR/btrfs-test-$seq
44 rm -fr $send_files_dir
47 _scratch_mkfs >>$seqres.full 2>&1
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
54 # Filesystem looks like:
57 # |---- merlin/ (ino 257)
58 # | |---- RC/ (ino 258)
59 # | |----- OSD/ (ino 259)
60 # | |---- Source/ (ino 260)
62 # |---- fdm/ (ino 261)
63 # | |---- RCz/ (ino 262)
64 # | |----- OSDz/ (ino 263)
65 # | |---- Sourcez/ (ino 264)
70 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap1
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
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
82 # Filesystem now looks like:
86 # |---- merlin/ (ino 257)
87 # | |---- RC/ (ino 258)
88 # | |----- OSD/ (ino 267) (new)
89 # | |---- OSD-Plane_788/ (ino 259)
90 # | |---- Source/ (ino 260)
92 # |---- fdm/ (ino 261)
93 # |---- RCz/ (ino 262)
94 # |----- OSDz/ (ino 268) (new)
97 # |---- OSD-Plane_788z/ (ino 263)
98 # |---- Sourcez/ (ino 264)
101 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap2
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
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 \
114 _scratch_mkfs >>$seqres.full 2>&1
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
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
123 echo "Silence is golden"