2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2014 Filipe Manana. All Rights Reserved.
5 # FS QA Test No. btrfs/044
7 # Regression test for a btrfs incremental send issue where under certain
8 # scenarios invalid paths for utimes, chown and chmod operations were sent
9 # to the send stream, causing btrfs receive to fail.
11 # If a directory had a move/rename operation delayed, and none of its parent
12 # directories, except for the immediate one, had delayed move/rename operations,
13 # after processing the directory's references, the incremental send code would
14 # issue invalid paths for utimes, chown and chmod operations.
16 # This issue is fixed by the following linux kernel btrfs patch:
18 # Btrfs: fix send issuing outdated paths for utimes, chown and chmod
21 seqres=$RESULT_DIR/$seq
22 echo "QA output created by $seq"
25 status=1 # failure is the default!
26 trap "_cleanup; exit \$status" 0 1 2 3 15
33 # get standard environment, filters and checks
37 # real QA test starts here
45 _scratch_mkfs >/dev/null 2>&1
49 mkdir -p $SCRATCH_MNT/a/b/c/d/e
50 mkdir $SCRATCH_MNT/a/b/c/f
51 echo 'ola ' > $SCRATCH_MNT/a/b/c/d/e/file.txt
52 chmod 0777 $SCRATCH_MNT/a/b/c/d/e
54 # Filesystem looks like:
62 # | |-- file.txt (ino 262)
66 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap1
68 echo 'mundo' >> $SCRATCH_MNT/a/b/c/d/e/file.txt
69 mv $SCRATCH_MNT/a/b/c/d/e/file.txt $SCRATCH_MNT/a/b/c/d/e/file2.txt
70 mv $SCRATCH_MNT/a/b/c/f $SCRATCH_MNT/a/b/f2
71 mv $SCRATCH_MNT/a/b/c/d/e $SCRATCH_MNT/a/b/f2/e2
72 mv $SCRATCH_MNT/a/b/c $SCRATCH_MNT/a/b/c2
73 mv $SCRATCH_MNT/a/b/c2/d $SCRATCH_MNT/a/b/c2/d2
74 chmod 0700 $SCRATCH_MNT/a/b/f2/e2
76 # Filesystem now looks like:
86 # |-- file2.txt (ino 263)
88 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap2
90 run_check $FSSUM_PROG -A -f -w $tmp/1.fssum $SCRATCH_MNT/mysnap1
91 run_check $FSSUM_PROG -A -f -w $tmp/2.fssum -x $SCRATCH_MNT/mysnap2/mysnap1 \
94 _run_btrfs_util_prog send -f $tmp/1.snap $SCRATCH_MNT/mysnap1
95 _run_btrfs_util_prog send -p $SCRATCH_MNT/mysnap1 -f $tmp/2.snap \
101 _scratch_mkfs >/dev/null 2>&1
104 _run_btrfs_util_prog receive -f $tmp/1.snap $SCRATCH_MNT
105 run_check $FSSUM_PROG -r $tmp/1.fssum $SCRATCH_MNT/mysnap1
107 _run_btrfs_util_prog receive -f $tmp/2.snap $SCRATCH_MNT
108 run_check $FSSUM_PROG -r $tmp/2.fssum $SCRATCH_MNT/mysnap2