2 # FS QA Test No. btrfs/117
4 # Test that an incremental send operation which issues clone operations works
5 # for files that have a full path containing more than one parent directory
8 #-----------------------------------------------------------------------
10 # Copyright (C) 2016 SUSE Linux Products GmbH. All Rights Reserved.
11 # Author: Filipe Manana <fdmanana@suse.com>
13 # This program is free software; you can redistribute it and/or
14 # modify it under the terms of the GNU General Public License as
15 # published by the Free Software Foundation.
17 # This program is distributed in the hope that it would be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write the Free Software Foundation,
24 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #-----------------------------------------------------------------------
29 seqres=$RESULT_DIR/$seq
30 echo "QA output created by $seq"
33 status=1 # failure is the default!
34 trap "_cleanup; exit \$status" 0 1 2 3 15
42 # get standard environment, filters and checks
47 # real QA test starts here
56 _scratch_mkfs >>$seqres.full 2>&1
59 mkdir -p $SCRATCH_MNT/a/b/c
60 $XFS_IO_PROG -f -c "pwrite -S 0xfd 0 128K" $SCRATCH_MNT/a/b/c/x | _filter_xfs_io
62 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/snap1
64 # Create a bunch of small and empty files, this is just to make sure our
65 # subvolume's btree gets more than 1 leaf, a condition necessary to trigger a
66 # past bug (1000 files is enough even for a leaf/node size of 64K, the largest
68 for ((i = 1; i <= 1000; i++)); do
69 echo -n > $SCRATCH_MNT/a/b/c/z_$i
72 # Create a clone of file x's extent and write some data to the middle of this
73 # new file, this is to guarantee the incremental send operation below issues
75 cp --reflink=always $SCRATCH_MNT/a/b/c/x $SCRATCH_MNT/a/b/c/y
76 $XFS_IO_PROG -c "pwrite -S 0xab 32K 16K" $SCRATCH_MNT/a/b/c/y | _filter_xfs_io
78 # Will be used as an extra source root for clone operations for the incremental
79 # send operation below.
80 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/clones_snap
82 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/snap2
84 _run_btrfs_util_prog send $SCRATCH_MNT/snap1 -f $tmp/1.snap
85 _run_btrfs_util_prog send $SCRATCH_MNT/clones_snap -f $tmp/clones.snap
86 _run_btrfs_util_prog send -p $SCRATCH_MNT/snap1 \
87 -c $SCRATCH_MNT/clones_snap $SCRATCH_MNT/snap2 -f $tmp/2.snap
89 echo "File digests in the original filesystem:"
90 md5sum $SCRATCH_MNT/snap1/a/b/c/x | _filter_scratch
91 md5sum $SCRATCH_MNT/snap2/a/b/c/x | _filter_scratch
92 md5sum $SCRATCH_MNT/snap2/a/b/c/y | _filter_scratch
95 _scratch_mkfs >>$seqres.full 2>&1
98 _run_btrfs_util_prog receive $SCRATCH_MNT -f $tmp/1.snap
99 _run_btrfs_util_prog receive $SCRATCH_MNT -f $tmp/clones.snap
100 _run_btrfs_util_prog receive $SCRATCH_MNT -f $tmp/2.snap
102 echo "File digests in the new filesystem:"
103 # Should match the digests we had in the original filesystem.
104 md5sum $SCRATCH_MNT/snap1/a/b/c/x | _filter_scratch
105 md5sum $SCRATCH_MNT/snap2/a/b/c/x | _filter_scratch
106 md5sum $SCRATCH_MNT/snap2/a/b/c/y | _filter_scratch