2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015, Oracle and/or its affiliates. All Rights Reserved.
7 # Ensure that reflinking a file N times and DIO CoWing the copies leaves the
9 # - Create a file and record its hash
10 # - Create some reflink copies
11 # - Rewrite all the reflink copies w/ directio
12 # - Compare the contents of the original file
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
41 testdir=$TEST_DIR/test-$seq
45 echo "Create the original file blocks"
48 filesize=$((blksz * nr))
49 _pwrite_byte 0x61 0 $((blksz * 256)) $testdir/file1 >> $seqres.full
52 md5sum $testdir/file1 | _filter_test_dir
53 csum=$(_md5_checksum $testdir/file1)
55 echo "Create the reflink copies"
56 seq 2 $nr | while read i; do
57 _cp_reflink $testdir/file1 $testdir/file$i
61 echo "Rewrite the copies"
62 seq 2 $nr | while read i; do
63 _pwrite_byte 0x62 0 $((blksz * 256)) $testdir/file$i -d >> $seqres.full
67 echo "Examine original file"
68 md5sum $testdir/file1 | _filter_test_dir
69 md5sum $testdir/file2 | _filter_test_dir
71 mod_csum=$(_md5_checksum $testdir/file2)
72 new_csum=$(_md5_checksum $testdir/file1)
73 test ${csum} != ${mod_csum} || echo "checksums do not match"
74 test ${csum} = ${new_csum} || echo "checksums do not match"