reflink: ensure that we can handle reflinking a lot of extents
[xfstests-dev.git] / tests / generic / 243
1 #! /bin/bash
2 # FS QA Test No. 243
3 #
4 # Reflink two large files and DIO CoW them in big chunks.
5 #
6 # This test is dependent on the system page size, so we cannot use md5 in
7 # the golden output; we can only compare to a check file.
8 #
9 #-----------------------------------------------------------------------
10 # Copyright (c) 2015, Oracle and/or its affiliates.  All Rights Reserved.
11 #
12 # This program is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License as
14 # published by the Free Software Foundation.
15 #
16 # This program is distributed in the hope that it would be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 # GNU General Public License for more details.
20 #
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write the Free Software Foundation,
23 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
24 #-----------------------------------------------------------------------
25
26 seq=`basename $0`
27 seqres=$RESULT_DIR/$seq
28 echo "QA output created by $seq"
29
30 here=`pwd`
31 tmp=/tmp/$$
32 status=1    # failure is the default!
33 trap "_cleanup; exit \$status" 0 1 2 3 15
34
35 _cleanup()
36 {
37     cd /
38     rm -rf $tmp.* $testdir
39 }
40
41 # get standard environment, filters and checks
42 . ./common/rc
43 . ./common/filter
44 . ./common/reflink
45
46 # real QA test starts here
47 _supported_os Linux
48 _require_scratch_reflink
49 _require_cp_reflink
50 _require_odirect
51
52 rm -f $seqres.full
53
54
55 echo "Format and mount"
56 _scratch_mkfs > $seqres.full 2>&1
57 _scratch_mount >> $seqres.full 2>&1
58
59 testdir=$SCRATCH_MNT/test-$seq
60 mkdir $testdir
61
62 blksz=65536
63 nr=6400
64 filesize=$((blksz * nr))
65 bufnr=1280
66 bufsize=$((blksz * bufnr))
67
68 free_blocks=$(stat -f -c '%a' $testdir)
69 real_blksz=$(stat -f -c '%S' $testdir)
70 space_needed=$(((filesize * 3) * 5 / 4))
71 space_avail=$((free_blocks * real_blksz))
72 test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
73
74 echo "Create the original files"
75 $XFS_IO_PROG -f -c "pwrite -S 0x61 -b $bufsize 0 $filesize" $testdir/file1 >> $seqres.full
76 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
77 $XFS_IO_PROG -f -c "pwrite -S 0x61 -b $bufsize 0 $filesize" $testdir/file2.chk >> $seqres.full
78 _scratch_remount
79
80 echo "Compare files"
81 md5sum $testdir/file1 | _filter_scratch
82 md5sum $testdir/file2 | _filter_scratch
83 md5sum $testdir/file2.chk | _filter_scratch
84
85 echo "CoW and unmount"
86 $XFS_IO_PROG -d -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $testdir/file2 >> $seqres.full
87 $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $testdir/file2.chk >> $seqres.full
88 _scratch_remount
89
90 echo "Compare files"
91 md5sum $testdir/file1 | _filter_scratch
92 md5sum $testdir/file2 | _filter_scratch
93 md5sum $testdir/file2.chk | _filter_scratch
94
95 # success, all done
96 status=0
97 exit