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 seqres=$RESULT_DIR/$seq
15 echo "QA output created by $seq"
19 status=1 # failure is the default!
20 trap "_cleanup; exit \$status" 0 1 2 3 15
28 # get standard environment, filters and checks
33 # real QA test starts here
35 _require_scratch_reflink
37 _require_xfs_io_command "fiemap"
38 _require_xfs_io_command "cowextsize"
42 echo "Format and mount"
43 _scratch_mkfs > $seqres.full 2>&1
44 _scratch_mount >> $seqres.full 2>&1
46 testdir=$SCRATCH_MNT/test-$seq
49 echo "Create initial file"
50 $XFS_IO_PROG -f -c "pwrite -S 0x61 0 131072" $testdir/file1 >> $seqres.full
51 $XFS_IO_PROG -c "cowextsize 1048576" $testdir/file1 >> $seqres.full
52 $XFS_IO_PROG -f -c "pwrite -S 0x61 0 1" $testdir/file4 >> $seqres.full
53 $XFS_IO_PROG -f -c "pwrite -S 0x61 0 262144" $testdir/file7 >> $seqres.full
54 $XFS_IO_PROG -f -c "pwrite -S 0x61 0 262144" $testdir/file9 >> $seqres.full
55 $XFS_IO_PROG -f -c "pwrite -S 0x61 0 262144" $testdir/file10 >> $seqres.full
57 echo "Reflink to an empty file"
58 _reflink_range $testdir/file1 0 $testdir/file2 0 0 >> $seqres.full
60 echo "Reflink to an empty file that already has cowextsz"
61 $XFS_IO_PROG -f -c "cowextsize 524288" $testdir/file3 >> $seqres.full
62 _reflink_range $testdir/file1 0 $testdir/file3 0 0 >> $seqres.full
64 echo "Reflink to a small file"
65 _reflink_range $testdir/file1 0 $testdir/file4 0 0 >> $seqres.full
67 echo "Reflink to a nonzero offset"
68 _reflink_range $testdir/file1 0 $testdir/file5 65536 0 >> $seqres.full
70 echo "Reflink from a nonzero offset"
71 _reflink_range $testdir/file1 65536 $testdir/file6 0 0 >> $seqres.full
73 echo "Reflink to a larger file"
74 _reflink_range $testdir/file1 0 $testdir/file7 0 0 >> $seqres.full
76 echo "Reflink less than the whole source file"
77 _reflink_range $testdir/file1 0 $testdir/file8 0 65536 >> $seqres.full
79 echo "cp reflink to a larger file"
80 _cp_reflink $testdir/file1 $testdir/file9 >> $seqres.full
82 echo "cp reflink to a larger file with cowextsize"
83 $XFS_IO_PROG -f -c "cowextsize 524288" $testdir/file10 >> $seqres.full
84 _cp_reflink $testdir/file1 $testdir/file10 >> $seqres.full
87 for i in `seq 1 10`; do
88 $XFS_IO_PROG -c "cowextsize" $testdir/file$i | _filter_scratch