2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015, Oracle and/or its affiliates. All Rights Reserved.
7 # Ensuring that copy on write in buffered mode works when the CoW
8 # range originally covers multiple extents, some regular, some not.
10 # - Reflink the odd blocks of the first file into the second file.
11 # - CoW across the halfway mark, starting with the unwritten extent.
12 # - Check that the files are now different where we say they're different.
15 seqres=$RESULT_DIR/$seq
16 echo "QA output created by $seq"
20 status=1 # failure is the default!
21 trap "_cleanup; exit \$status" 0 1 2 3 15
26 rm -rf $tmp.* $testdir
29 # get standard environment, filters and checks
34 # real QA test starts here
36 _require_scratch_reflink
37 _require_xfs_io_command "falloc"
41 echo "Format and mount"
42 _scratch_mkfs > $seqres.full 2>&1
43 _scratch_mount >> $seqres.full 2>&1
45 testdir=$SCRATCH_MNT/test-$seq
48 echo "Create the original files"
51 filesize=$((blksz * nr))
52 _weave_reflink_regular $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
56 md5sum $testdir/file1 | _filter_scratch
57 md5sum $testdir/file3 | _filter_scratch
58 md5sum $testdir/file3.chk | _filter_scratch
60 echo "CoW across the transition"
61 cowoff=$((filesize / 4))
62 cowsz=$((filesize / 2))
63 $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $cowsz $cowoff $cowsz" $testdir/file3 >> $seqres.full
64 _pwrite_byte 0x63 $cowoff $cowsz $testdir/file3.chk >> $seqres.full
68 md5sum $testdir/file1 | _filter_scratch
69 md5sum $testdir/file3 | _filter_scratch
70 md5sum $testdir/file3.chk | _filter_scratch