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 _begin_fstest auto quick clone
17 # Override the default cleanup function.
21 rm -rf $tmp.* $testdir
24 # Import common functions.
28 # real QA test starts here
33 testdir=$TEST_DIR/test-$seq
37 echo "Create the original file blocks"
40 filesize=$((blksz * nr))
41 _pwrite_byte 0x61 0 $((blksz * 256)) $testdir/file1 >> $seqres.full
44 md5sum $testdir/file1 | _filter_test_dir
45 csum=$(_md5_checksum $testdir/file1)
47 echo "Create the reflink copies"
48 seq 2 $nr | while read i; do
49 _cp_reflink $testdir/file1 $testdir/file$i
53 echo "Rewrite the copies"
54 seq 2 $nr | while read i; do
55 _pwrite_byte 0x62 0 $((blksz * 256)) $testdir/file$i -d >> $seqres.full
59 echo "Examine original file"
60 md5sum $testdir/file1 | _filter_test_dir
61 md5sum $testdir/file2 | _filter_test_dir
63 mod_csum=$(_md5_checksum $testdir/file2)
64 new_csum=$(_md5_checksum $testdir/file1)
65 test ${csum} != ${mod_csum} || echo "checksums do not match"
66 test ${csum} = ${new_csum} || echo "checksums do not match"