2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2014 Filipe Manana. All Rights Reserved.
5 # FS QA Test No. btrfs/040
7 # Regression test for btrfs incremental send issue where an rmdir
8 # instruction was sent multiple times for the same target directory.
9 # The number of times depended on the number of hardlinks against
10 # the same inode inside the target directory. That inode must have
11 # had the highest number of all the inodes that were children of the
12 # directory. This made the btrfs receive command fail immediately once
13 # it received the second rmdir instruction.
15 # This issue is fixed by the following linux kernel btrfs patch:
17 # Btrfs: send, don't send rmdir for same target multiple times
20 seqres=$RESULT_DIR/$seq
21 echo "QA output created by $seq"
24 status=1 # failure is the default!
25 trap "_cleanup; exit \$status" 0 1 2 3 15
32 # get standard environment, filters and checks
36 # real QA test starts here
43 _scratch_mkfs >/dev/null 2>&1
46 mkdir -p $SCRATCH_MNT/a/b/c
47 echo 'hello world' > $SCRATCH_MNT/a/b/c/hel.txt
48 echo 'ola mundo' > $SCRATCH_MNT/a/b/c/foo.txt
49 ln $SCRATCH_MNT/a/b/c/foo.txt $SCRATCH_MNT/a/b/c/bar.txt
50 ln $SCRATCH_MNT/a/b/c/foo.txt $SCRATCH_MNT/a/b/baz.txt
52 # Filesystem looks like:
58 # | |-- hel.txt (ino 260)
59 # | |-- foo.txt (ino 261)
60 # | |-- bar.txt (ino 261)
62 # |-- baz.txt (ino 261)
64 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap1
66 rm -f $SCRATCH_MNT/a/b/c/foo.txt
67 rm -f $SCRATCH_MNT/a/b/c/bar.txt
68 rm -f $SCRATCH_MNT/a/b/c/hel.txt
69 rmdir $SCRATCH_MNT/a/b/c
71 # Filesystem now looks like:
76 # |-- baz.txt (ino 261)
78 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap2
80 run_check $FSSUM_PROG -A -f -w $tmp/1.fssum $SCRATCH_MNT/mysnap1
81 run_check $FSSUM_PROG -A -f -w $tmp/2.fssum -x $SCRATCH_MNT/mysnap2/mysnap1 \
84 _run_btrfs_util_prog send -f $tmp/1.snap $SCRATCH_MNT/mysnap1
85 _run_btrfs_util_prog send -p $SCRATCH_MNT/mysnap1 -f $tmp/2.snap \
89 _check_btrfs_filesystem $SCRATCH_DEV
91 _scratch_mkfs >/dev/null 2>&1
94 _run_btrfs_util_prog receive -f $tmp/1.snap $SCRATCH_MNT
95 run_check $FSSUM_PROG -r $tmp/1.fssum $SCRATCH_MNT/mysnap1 2>> $seqres.full
97 _run_btrfs_util_prog receive -f $tmp/2.snap $SCRATCH_MNT
98 run_check $FSSUM_PROG -r $tmp/2.fssum $SCRATCH_MNT/mysnap2 2>> $seqres.full
101 _check_btrfs_filesystem $SCRATCH_DEV