2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016, Oracle and/or its affiliates. All Rights Reserved.
7 # During reflink, XFS should carry the cowextsz setting to the destination file
8 # if the destination file size is less than the size of the source file, the
9 # length is the size of the source file, both offsets are zero, and the
10 # destination does not already have a cowextsz setting. It should not do so
14 _begin_fstest auto quick clone
16 # Import common functions.
20 # real QA test starts here
22 _require_scratch_reflink
24 _require_xfs_io_command "fiemap"
25 _require_xfs_io_command "cowextsize"
27 echo "Format and mount"
28 _scratch_mkfs > $seqres.full 2>&1
29 _scratch_mount >> $seqres.full 2>&1
31 testdir=$SCRATCH_MNT/test-$seq
34 echo "Create initial file"
35 $XFS_IO_PROG -f -c "pwrite -S 0x61 0 131072" $testdir/file1 >> $seqres.full
36 $XFS_IO_PROG -c "cowextsize 1048576" $testdir/file1 >> $seqres.full
37 $XFS_IO_PROG -f -c "pwrite -S 0x61 0 1" $testdir/file4 >> $seqres.full
38 $XFS_IO_PROG -f -c "pwrite -S 0x61 0 262144" $testdir/file7 >> $seqres.full
39 $XFS_IO_PROG -f -c "pwrite -S 0x61 0 262144" $testdir/file9 >> $seqres.full
40 $XFS_IO_PROG -f -c "pwrite -S 0x61 0 262144" $testdir/file10 >> $seqres.full
42 echo "Reflink to an empty file"
43 _reflink_range $testdir/file1 0 $testdir/file2 0 0 >> $seqres.full
45 echo "Reflink to an empty file that already has cowextsz"
46 $XFS_IO_PROG -f -c "cowextsize 524288" $testdir/file3 >> $seqres.full
47 _reflink_range $testdir/file1 0 $testdir/file3 0 0 >> $seqres.full
49 echo "Reflink to a small file"
50 _reflink_range $testdir/file1 0 $testdir/file4 0 0 >> $seqres.full
52 echo "Reflink to a nonzero offset"
53 _reflink_range $testdir/file1 0 $testdir/file5 65536 0 >> $seqres.full
55 echo "Reflink from a nonzero offset"
56 _reflink_range $testdir/file1 65536 $testdir/file6 0 0 >> $seqres.full
58 echo "Reflink to a larger file"
59 _reflink_range $testdir/file1 0 $testdir/file7 0 0 >> $seqres.full
61 echo "Reflink less than the whole source file"
62 _reflink_range $testdir/file1 0 $testdir/file8 0 65536 >> $seqres.full
64 echo "cp reflink to a larger file"
65 _cp_reflink $testdir/file1 $testdir/file9 >> $seqres.full
67 echo "cp reflink to a larger file with cowextsize"
68 $XFS_IO_PROG -f -c "cowextsize 524288" $testdir/file10 >> $seqres.full
69 _cp_reflink $testdir/file1 $testdir/file10 >> $seqres.full
72 for i in `seq 1 10`; do
73 $XFS_IO_PROG -c "cowextsize" $testdir/file$i | _filter_scratch