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
44 _scratch_mkfs >/dev/null 2>&1
47 mkdir -p $SCRATCH_MNT/a/b/c
48 echo 'hello world' > $SCRATCH_MNT/a/b/c/hel.txt
49 echo 'ola mundo' > $SCRATCH_MNT/a/b/c/foo.txt
50 ln $SCRATCH_MNT/a/b/c/foo.txt $SCRATCH_MNT/a/b/c/bar.txt
51 ln $SCRATCH_MNT/a/b/c/foo.txt $SCRATCH_MNT/a/b/baz.txt
53 # Filesystem looks like:
59 # | |-- hel.txt (ino 260)
60 # | |-- foo.txt (ino 261)
61 # | |-- bar.txt (ino 261)
63 # |-- baz.txt (ino 261)
65 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap1
67 rm -f $SCRATCH_MNT/a/b/c/foo.txt
68 rm -f $SCRATCH_MNT/a/b/c/bar.txt
69 rm -f $SCRATCH_MNT/a/b/c/hel.txt
70 rmdir $SCRATCH_MNT/a/b/c
72 # Filesystem now looks like:
77 # |-- baz.txt (ino 261)
79 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap2
81 run_check $FSSUM_PROG -A -f -w $tmp/1.fssum $SCRATCH_MNT/mysnap1
82 run_check $FSSUM_PROG -A -f -w $tmp/2.fssum -x $SCRATCH_MNT/mysnap2/mysnap1 \
85 _run_btrfs_util_prog send -f $tmp/1.snap $SCRATCH_MNT/mysnap1
86 _run_btrfs_util_prog send -p $SCRATCH_MNT/mysnap1 -f $tmp/2.snap \
90 _check_btrfs_filesystem $SCRATCH_DEV
92 _scratch_mkfs >/dev/null 2>&1
95 _run_btrfs_util_prog receive -f $tmp/1.snap $SCRATCH_MNT
96 run_check $FSSUM_PROG -r $tmp/1.fssum $SCRATCH_MNT/mysnap1 2>> $seqres.full
98 _run_btrfs_util_prog receive -f $tmp/2.snap $SCRATCH_MNT
99 run_check $FSSUM_PROG -r $tmp/2.fssum $SCRATCH_MNT/mysnap2 2>> $seqres.full
102 _check_btrfs_filesystem $SCRATCH_DEV