2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015, Oracle and/or its affiliates. All Rights Reserved.
7 # Reflink two large files and DIO CoW them in big chunks.
9 # This test is dependent on the system page size, so we cannot use md5 in
10 # the golden output; we can only compare to a check file.
13 _begin_fstest auto clone
15 # Override the default cleanup function.
19 rm -rf $tmp.* $testdir
22 # Import common functions.
26 # real QA test starts here
27 _require_scratch_reflink
31 echo "Format and mount"
32 _scratch_mkfs > $seqres.full 2>&1
33 _scratch_mount >> $seqres.full 2>&1
35 testdir=$SCRATCH_MNT/test-$seq
40 filesize=$((blksz * nr))
42 bufsize=$((blksz * bufnr))
44 free_blocks=$(stat -f -c '%a' $testdir)
45 real_blksz=$(_get_block_size $testdir)
46 space_needed=$(((filesize * 3) * 5 / 4))
47 space_avail=$((free_blocks * real_blksz))
48 test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
50 echo "Create the original files"
51 $XFS_IO_PROG -f -c "pwrite -S 0x61 -b $bufsize 0 $filesize" $testdir/file1 >> $seqres.full
52 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
53 $XFS_IO_PROG -f -c "pwrite -S 0x61 -b $bufsize 0 $filesize" $testdir/file2.chk >> $seqres.full
57 md5sum $testdir/file1 | _filter_scratch
58 md5sum $testdir/file2 | _filter_scratch
59 md5sum $testdir/file2.chk | _filter_scratch
61 echo "CoW and unmount"
62 $XFS_IO_PROG -d -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $testdir/file2 >> $seqres.full
63 $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $testdir/file2.chk >> $seqres.full
67 md5sum $testdir/file1 | _filter_scratch
68 md5sum $testdir/file2 | _filter_scratch
69 md5sum $testdir/file2.chk | _filter_scratch