2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016, Oracle and/or its affiliates. All Rights Reserved.
7 # Ensuring that copy on write in buffered mode to the source file when the
8 # CoW range covers regular unshared and regular shared blocks.
11 # - Reflink the odd blocks of the first file into the second file.
12 # - CoW the first file across the halfway mark, starting with the
14 # - Check that the files are now different where we say they're different.
17 seqres=$RESULT_DIR/$seq
18 echo "QA output created by $seq"
22 status=1 # failure is the default!
23 trap "_cleanup; exit \$status" 0 1 2 3 15
31 # get standard environment, filters and checks
36 # real QA test starts here
38 _require_scratch_reflink
39 _require_xfs_io_command "falloc"
40 _require_xfs_io_command "cowextsize"
44 echo "Format and mount"
45 _scratch_mkfs > $seqres.full 2>&1
46 _scratch_mount >> $seqres.full 2>&1
48 testdir=$SCRATCH_MNT/test-$seq
51 echo "Create the original files"
54 filesize=$((blksz * nr))
55 $XFS_IO_PROG -c "cowextsize $((blksz * 16))" $testdir >> $seqres.full
56 _sweave_reflink_regular $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
60 md5sum $testdir/file1 | _filter_scratch
61 md5sum $testdir/file3 | _filter_scratch
62 md5sum $testdir/file1.chk | _filter_scratch
64 echo "CoW across the transition"
65 cowoff=$((filesize / 4))
66 cowsz=$((filesize / 2))
67 $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $cowsz $cowoff $cowsz" $testdir/file1 >> $seqres.full
68 _pwrite_byte 0x63 $cowoff $cowsz $testdir/file1.chk >> $seqres.full
72 md5sum $testdir/file1 | _filter_scratch
73 md5sum $testdir/file3 | _filter_scratch
74 md5sum $testdir/file1.chk | _filter_scratch