2 # FS QA Test No. btrfs/044
4 # Regression test for a btrfs incremental send issue where under certain
5 # scenarios invalid paths for utimes, chown and chmod operations were sent
6 # to the send stream, causing btrfs receive to fail.
8 # If a directory had a move/rename operation delayed, and none of its parent
9 # directories, except for the immediate one, had delayed move/rename operations,
10 # after processing the directory's references, the incremental send code would
11 # issue invalid paths for utimes, chown and chmod operations.
13 # This issue is fixed by the following linux kernel btrfs patch:
15 # Btrfs: fix send issuing outdated paths for utimes, chown and chmod
17 #-----------------------------------------------------------------------
18 # Copyright (c) 2014 Filipe Manana. All Rights Reserved.
20 # This program is free software; you can redistribute it and/or
21 # modify it under the terms of the GNU General Public License as
22 # published by the Free Software Foundation.
24 # This program is distributed in the hope that it would be useful,
25 # but WITHOUT ANY WARRANTY; without even the implied warranty of
26 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 # GNU General Public License for more details.
29 # You should have received a copy of the GNU General Public License
30 # along with this program; if not, write the Free Software Foundation,
31 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
32 #-----------------------------------------------------------------------
36 seqres=$RESULT_DIR/$seq
37 echo "QA output created by $seq"
40 status=1 # failure is the default!
41 trap "_cleanup; exit \$status" 0 1 2 3 15
48 # get standard environment, filters and checks
52 # real QA test starts here
60 _scratch_mkfs >/dev/null 2>&1
64 mkdir -p $SCRATCH_MNT/a/b/c/d/e
65 mkdir $SCRATCH_MNT/a/b/c/f
66 echo 'ola ' > $SCRATCH_MNT/a/b/c/d/e/file.txt
67 chmod 0777 $SCRATCH_MNT/a/b/c/d/e
69 # Filesystem looks like:
77 # | |-- file.txt (ino 262)
81 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap1
83 echo 'mundo' >> $SCRATCH_MNT/a/b/c/d/e/file.txt
84 mv $SCRATCH_MNT/a/b/c/d/e/file.txt $SCRATCH_MNT/a/b/c/d/e/file2.txt
85 mv $SCRATCH_MNT/a/b/c/f $SCRATCH_MNT/a/b/f2
86 mv $SCRATCH_MNT/a/b/c/d/e $SCRATCH_MNT/a/b/f2/e2
87 mv $SCRATCH_MNT/a/b/c $SCRATCH_MNT/a/b/c2
88 mv $SCRATCH_MNT/a/b/c2/d $SCRATCH_MNT/a/b/c2/d2
89 chmod 0700 $SCRATCH_MNT/a/b/f2/e2
91 # Filesystem now looks like:
101 # |-- file2.txt (ino 263)
103 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap2
105 run_check $FSSUM_PROG -A -f -w $tmp/1.fssum $SCRATCH_MNT/mysnap1
106 run_check $FSSUM_PROG -A -f -w $tmp/2.fssum -x $SCRATCH_MNT/mysnap2/mysnap1 \
109 _run_btrfs_util_prog send -f $tmp/1.snap $SCRATCH_MNT/mysnap1
110 _run_btrfs_util_prog send -p $SCRATCH_MNT/mysnap1 -f $tmp/2.snap \
116 _scratch_mkfs >/dev/null 2>&1
119 _run_btrfs_util_prog receive -f $tmp/1.snap $SCRATCH_MNT
120 run_check $FSSUM_PROG -r $tmp/1.fssum $SCRATCH_MNT/mysnap1
122 _run_btrfs_util_prog receive -f $tmp/2.snap $SCRATCH_MNT
123 run_check $FSSUM_PROG -r $tmp/2.fssum $SCRATCH_MNT/mysnap2