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
38 _scratch_mkfs >>$seqres.full 2>&1
41 mkdir -p $SCRATCH_MNT/a/b/c
42 $XFS_IO_PROG -f -c "pwrite -S 0xfd 0 128K" $SCRATCH_MNT/a/b/c/x | _filter_xfs_io
44 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/snap1
46 # Create a bunch of small and empty files, this is just to make sure our
47 # subvolume's btree gets more than 1 leaf, a condition necessary to trigger a
48 # past bug (1000 files is enough even for a leaf/node size of 64K, the largest
50 for ((i = 1; i <= 1000; i++)); do
51 echo -n > $SCRATCH_MNT/a/b/c/z_$i
54 # Create a clone of file x's extent and write some data to the middle of this
55 # new file, this is to guarantee the incremental send operation below issues
57 cp --reflink=always $SCRATCH_MNT/a/b/c/x $SCRATCH_MNT/a/b/c/y
58 $XFS_IO_PROG -c "pwrite -S 0xab 32K 16K" $SCRATCH_MNT/a/b/c/y | _filter_xfs_io
60 # Will be used as an extra source root for clone operations for the incremental
61 # send operation below.
62 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/clones_snap
64 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/snap2
66 _run_btrfs_util_prog send -f $tmp/1.snap $SCRATCH_MNT/snap1
67 _run_btrfs_util_prog send -f $tmp/clones.snap $SCRATCH_MNT/clones_snap
68 _run_btrfs_util_prog send -p $SCRATCH_MNT/snap1 \
69 -c $SCRATCH_MNT/clones_snap -f $tmp/2.snap $SCRATCH_MNT/snap2
71 echo "File digests in the original filesystem:"
72 md5sum $SCRATCH_MNT/snap1/a/b/c/x | _filter_scratch
73 md5sum $SCRATCH_MNT/snap2/a/b/c/x | _filter_scratch
74 md5sum $SCRATCH_MNT/snap2/a/b/c/y | _filter_scratch
77 _scratch_mkfs >>$seqres.full 2>&1
80 _run_btrfs_util_prog receive -f $tmp/1.snap $SCRATCH_MNT
81 _run_btrfs_util_prog receive -f $tmp/clones.snap $SCRATCH_MNT
82 _run_btrfs_util_prog receive -f $tmp/2.snap $SCRATCH_MNT
84 echo "File digests in the new filesystem:"
85 # Should match the digests we had in the original filesystem.
86 md5sum $SCRATCH_MNT/snap1/a/b/c/x | _filter_scratch
87 md5sum $SCRATCH_MNT/snap2/a/b/c/x | _filter_scratch
88 md5sum $SCRATCH_MNT/snap2/a/b/c/y | _filter_scratch