2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2016 SUSE Linux Products GmbH. All Rights Reserved.
5 # FS QA Test No. btrfs/117
7 # Test that an incremental send operation which issues clone operations works
8 # for files that have a full path containing more than one parent directory
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
16 status=1 # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
25 # get standard environment, filters and checks
30 # real QA test starts here
37 _scratch_mkfs >>$seqres.full 2>&1
40 mkdir -p $SCRATCH_MNT/a/b/c
41 $XFS_IO_PROG -f -c "pwrite -S 0xfd 0 128K" $SCRATCH_MNT/a/b/c/x | _filter_xfs_io
43 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/snap1
45 # Create a bunch of small and empty files, this is just to make sure our
46 # subvolume's btree gets more than 1 leaf, a condition necessary to trigger a
47 # past bug (1000 files is enough even for a leaf/node size of 64K, the largest
49 for ((i = 1; i <= 1000; i++)); do
50 echo -n > $SCRATCH_MNT/a/b/c/z_$i
53 # Create a clone of file x's extent and write some data to the middle of this
54 # new file, this is to guarantee the incremental send operation below issues
56 cp --reflink=always $SCRATCH_MNT/a/b/c/x $SCRATCH_MNT/a/b/c/y
57 $XFS_IO_PROG -c "pwrite -S 0xab 32K 16K" $SCRATCH_MNT/a/b/c/y | _filter_xfs_io
59 # Will be used as an extra source root for clone operations for the incremental
60 # send operation below.
61 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/clones_snap
63 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/snap2
65 _run_btrfs_util_prog send -f $tmp/1.snap $SCRATCH_MNT/snap1
66 _run_btrfs_util_prog send -f $tmp/clones.snap $SCRATCH_MNT/clones_snap
67 _run_btrfs_util_prog send -p $SCRATCH_MNT/snap1 \
68 -c $SCRATCH_MNT/clones_snap -f $tmp/2.snap $SCRATCH_MNT/snap2
70 echo "File digests in the original filesystem:"
71 md5sum $SCRATCH_MNT/snap1/a/b/c/x | _filter_scratch
72 md5sum $SCRATCH_MNT/snap2/a/b/c/x | _filter_scratch
73 md5sum $SCRATCH_MNT/snap2/a/b/c/y | _filter_scratch
76 _scratch_mkfs >>$seqres.full 2>&1
79 _run_btrfs_util_prog receive -f $tmp/1.snap $SCRATCH_MNT
80 _run_btrfs_util_prog receive -f $tmp/clones.snap $SCRATCH_MNT
81 _run_btrfs_util_prog receive -f $tmp/2.snap $SCRATCH_MNT
83 echo "File digests in the new filesystem:"
84 # Should match the digests we had in the original filesystem.
85 md5sum $SCRATCH_MNT/snap1/a/b/c/x | _filter_scratch
86 md5sum $SCRATCH_MNT/snap2/a/b/c/x | _filter_scratch
87 md5sum $SCRATCH_MNT/snap2/a/b/c/y | _filter_scratch