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.
10 # - Reflink the odd blocks of the first file into a third file.
11 # - Reflink the even blocks of the second file into the third file.
12 # - CoW across the halfway mark.
13 # - Check that the files are now different where we say they're different.
16 seqres=$RESULT_DIR/$seq
17 echo "QA output created by $seq"
21 status=1 # failure is the default!
22 trap "_cleanup; exit \$status" 0 1 2 3 15
27 rm -rf $tmp.* $testdir
30 # get standard environment, filters and checks
35 # real QA test starts here
36 _require_scratch_reflink
40 echo "Format and mount"
41 _scratch_mkfs > $seqres.full 2>&1
42 _scratch_mount >> $seqres.full 2>&1
44 testdir=$SCRATCH_MNT/test-$seq
47 echo "Create the original files"
50 filesize=$((blksz * nr))
51 _pwrite_byte 0x61 0 $filesize $testdir/file1 >> $seqres.full
52 _pwrite_byte 0x62 0 $filesize $testdir/file2 >> $seqres.full
53 seq 0 2 $((nr-1)) | while read f; do
54 _reflink_range $testdir/file1 $((blksz * f)) $testdir/file3 $((blksz * f)) $blksz >> $seqres.full
55 _pwrite_byte 0x61 $((blksz * f)) $blksz $testdir/file3.chk >> $seqres.full
57 seq 1 2 $((nr-1)) | while read f; do
58 _reflink_range $testdir/file2 $((blksz * f)) $testdir/file3 $((blksz * f)) $blksz >> $seqres.full
59 _pwrite_byte 0x62 $((blksz * f)) $blksz $testdir/file3.chk >> $seqres.full
64 md5sum $testdir/file1 | _filter_scratch
65 md5sum $testdir/file2 | _filter_scratch
66 md5sum $testdir/file3 | _filter_scratch
67 md5sum $testdir/file3.chk | _filter_scratch
69 echo "CoW across the transition"
70 cowoff=$((filesize / 4))
71 cowsz=$((filesize / 2))
72 _pwrite_byte 0x63 $cowoff $cowsz $testdir/file3 >> $seqres.full
73 _pwrite_byte 0x63 $cowoff $cowsz $testdir/file3.chk >> $seqres.full
77 md5sum $testdir/file1 | _filter_scratch
78 md5sum $testdir/file2 | _filter_scratch
79 md5sum $testdir/file3 | _filter_scratch
80 md5sum $testdir/file3.chk | _filter_scratch