2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016, Oracle and/or its affiliates. All Rights Reserved.
7 # - Create two reflinked files a byte longer than a block.
8 # - Rewrite the whole file.
11 _begin_fstest auto quick clone
13 # Import common functions.
17 # real QA test starts here
18 _require_scratch_reflink
21 echo "Format and mount"
22 _scratch_mkfs > $seqres.full 2>&1
23 _scratch_mount >> $seqres.full 2>&1
25 testdir=$SCRATCH_MNT/test-$seq
30 filesize=$((blksz * nr))
32 bufsize=$((blksz * bufnr))
34 real_blksz=$(_get_block_size "$testdir")
35 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
37 echo "Create the original files"
38 $XFS_IO_PROG -f -c "pwrite -S 0x61 -b $bufsize 0 $((filesize + 1))" $testdir/file1 >> $seqres.full
39 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
40 $XFS_IO_PROG -f -c "pwrite -S 0x61 -b $bufsize 0 $((filesize + 1))" $testdir/file2.chk >> $seqres.full
44 md5sum $testdir/file1 | _filter_scratch
45 md5sum $testdir/file2 | _filter_scratch
46 md5sum $testdir/file2.chk | _filter_scratch
48 echo "CoW and unmount"
49 $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $real_blksz 0 $((filesize + 1))" -c "fdatasync" $testdir/file2 >> $seqres.full
50 $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $real_blksz 0 $((filesize + 1))" -c "fdatasync" $testdir/file2.chk >> $seqres.full
54 md5sum $testdir/file1 | _filter_scratch
55 md5sum $testdir/file2 | _filter_scratch
56 md5sum $testdir/file2.chk | _filter_scratch