xfs/007: fix regressions on V4 filesystems
[xfstests-dev.git] / tests / xfs / 210
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
4 #
5 # FS QA Test No. 210
6 #
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
11 # otherwise.
12 #
13 . ./common/preamble
14 _begin_fstest auto quick clone
15
16 # Import common functions.
17 . ./common/filter
18 . ./common/reflink
19
20 # real QA test starts here
21 _supported_fs xfs
22 _require_scratch_reflink
23 _require_cp_reflink
24 _require_xfs_io_command "fiemap"
25 _require_xfs_io_command "cowextsize"
26
27 echo "Format and mount"
28 _scratch_mkfs > $seqres.full 2>&1
29 _scratch_mount >> $seqres.full 2>&1
30
31 testdir=$SCRATCH_MNT/test-$seq
32 mkdir $testdir
33
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
41
42 echo "Reflink to an empty file"
43 _reflink_range $testdir/file1 0 $testdir/file2 0 0 >> $seqres.full
44
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
48
49 echo "Reflink to a small file"
50 _reflink_range $testdir/file1 0 $testdir/file4 0 0 >> $seqres.full
51
52 echo "Reflink to a nonzero offset"
53 _reflink_range $testdir/file1 0 $testdir/file5 65536 0 >> $seqres.full
54
55 echo "Reflink from a nonzero offset"
56 _reflink_range $testdir/file1 65536 $testdir/file6 0 0 >> $seqres.full
57
58 echo "Reflink to a larger file"
59 _reflink_range $testdir/file1 0 $testdir/file7 0 0 >> $seqres.full
60
61 echo "Reflink less than the whole source file"
62 _reflink_range $testdir/file1 0 $testdir/file8 0 65536 >> $seqres.full
63
64 echo "cp reflink to a larger file"
65 _cp_reflink $testdir/file1 $testdir/file9 >> $seqres.full
66
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
70
71 echo "Check cowextsz"
72 for i in `seq 1 10`; do
73         $XFS_IO_PROG -c "cowextsize" $testdir/file$i | _filter_scratch
74 done
75
76 # success, all done
77 status=0
78 exit