2 # FS QA Test No. btrfs/040
4 # Regression test for btrfs incremental send issue where an rmdir
5 # instruction was sent multiple times for the same target directory.
6 # The number of times depended on the number of hardlinks against
7 # the same inode inside the target directory. That inode must have
8 # had the highest number of all the inodes that were children of the
9 # directory. This made the btrfs receive command fail immediately once
10 # it received the second rmdir instruction.
12 # This issue is fixed by the following linux kernel btrfs patch:
14 # Btrfs: send, don't send rmdir for same target multiple times
16 #-----------------------------------------------------------------------
17 # Copyright (c) 2014 Filipe Manana. All Rights Reserved.
19 # This program is free software; you can redistribute it and/or
20 # modify it under the terms of the GNU General Public License as
21 # published by the Free Software Foundation.
23 # This program is distributed in the hope that it would be useful,
24 # but WITHOUT ANY WARRANTY; without even the implied warranty of
25 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 # GNU General Public License for more details.
28 # You should have received a copy of the GNU General Public License
29 # along with this program; if not, write the Free Software Foundation,
30 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
31 #-----------------------------------------------------------------------
35 seqres=$RESULT_DIR/$seq
36 echo "QA output created by $seq"
39 status=1 # failure is the default!
40 trap "_cleanup; exit \$status" 0 1 2 3 15
47 # get standard environment, filters and checks
51 # real QA test starts here
59 _scratch_mkfs >/dev/null 2>&1
62 mkdir -p $SCRATCH_MNT/a/b/c
63 echo 'hello world' > $SCRATCH_MNT/a/b/c/hel.txt
64 echo 'ola mundo' > $SCRATCH_MNT/a/b/c/foo.txt
65 ln $SCRATCH_MNT/a/b/c/foo.txt $SCRATCH_MNT/a/b/c/bar.txt
66 ln $SCRATCH_MNT/a/b/c/foo.txt $SCRATCH_MNT/a/b/baz.txt
68 # Filesystem looks like:
74 # | |-- hel.txt (ino 260)
75 # | |-- foo.txt (ino 261)
76 # | |-- bar.txt (ino 261)
78 # |-- baz.txt (ino 261)
80 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap1
82 rm -f $SCRATCH_MNT/a/b/c/foo.txt
83 rm -f $SCRATCH_MNT/a/b/c/bar.txt
84 rm -f $SCRATCH_MNT/a/b/c/hel.txt
85 rmdir $SCRATCH_MNT/a/b/c
87 # Filesystem now looks like:
92 # |-- baz.txt (ino 261)
94 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap2
96 run_check $FSSUM_PROG -A -f -w $tmp/1.fssum $SCRATCH_MNT/mysnap1
97 run_check $FSSUM_PROG -A -f -w $tmp/2.fssum -x $SCRATCH_MNT/mysnap2/mysnap1 \
100 _run_btrfs_util_prog send -f $tmp/1.snap $SCRATCH_MNT/mysnap1
101 _run_btrfs_util_prog send -p $SCRATCH_MNT/mysnap1 -f $tmp/2.snap \
105 _check_btrfs_filesystem $SCRATCH_DEV
107 _scratch_mkfs >/dev/null 2>&1
110 _run_btrfs_util_prog receive -f $tmp/1.snap $SCRATCH_MNT
111 run_check $FSSUM_PROG -r $tmp/1.fssum $SCRATCH_MNT/mysnap1 2>> $seqres.full
113 _run_btrfs_util_prog receive -f $tmp/2.snap $SCRATCH_MNT
114 run_check $FSSUM_PROG -r $tmp/2.fssum $SCRATCH_MNT/mysnap2 2>> $seqres.full
117 _check_btrfs_filesystem $SCRATCH_DEV