2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2014 Filipe Manana. All Rights Reserved.
5 # FS QA Test No. btrfs/039
7 # Regression test for a btrfs incremental send issue related to renaming of
8 # directories. If at the time of the initial send we have a directory that is
9 # a child of a directory with a higher inode number, and then later after the
10 # initial full send we rename both the child and parent directories, but
11 # without moving any of them, a subsequent incremental send would produce a
12 # rename instruction for the child directory that pointed to an invalid path.
13 # This made the btrfs receive operation fail.
15 # This issue is fixed by the following linux kernel btrfs patch:
17 # Btrfs: incremental send, fix invalid path after dir rename
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
48 mkdir $SCRATCH_MNT/a/b/c
49 mv $SCRATCH_MNT/d $SCRATCH_MNT/a/b/c
51 mkdir -p $SCRATCH_MNT/a/b/f/g
52 mv $SCRATCH_MNT/e $SCRATCH_MNT/a/b/f/g
54 # Filesystem looks like:
66 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap1
68 mv $SCRATCH_MNT/a/b/c $SCRATCH_MNT/a/b/x
69 mv $SCRATCH_MNT/a/b/x/d $SCRATCH_MNT/a/b/x/y
70 mv $SCRATCH_MNT/a/b/f $SCRATCH_MNT/a/b/w
71 mv $SCRATCH_MNT/a/b/w/g/e $SCRATCH_MNT/a/b/w/g/z
73 # Filesystem now looks like:
85 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap2
87 run_check $FSSUM_PROG -A -f -w $tmp/1.fssum $SCRATCH_MNT/mysnap1
88 run_check $FSSUM_PROG -A -f -w $tmp/2.fssum -x $SCRATCH_MNT/mysnap2/mysnap1 \
91 _run_btrfs_util_prog send -f $tmp/1.snap $SCRATCH_MNT/mysnap1
92 _run_btrfs_util_prog send -p $SCRATCH_MNT/mysnap1 -f $tmp/2.snap \
96 _check_btrfs_filesystem $SCRATCH_DEV
98 _scratch_mkfs >/dev/null 2>&1
101 _run_btrfs_util_prog receive -f $tmp/1.snap $SCRATCH_MNT
102 run_check $FSSUM_PROG -r $tmp/1.fssum $SCRATCH_MNT/mysnap1 2>> $seqres.full
104 _run_btrfs_util_prog receive -f $tmp/2.snap $SCRATCH_MNT
105 run_check $FSSUM_PROG -r $tmp/2.fssum $SCRATCH_MNT/mysnap2 2>> $seqres.full
108 _check_btrfs_filesystem $SCRATCH_DEV