xfs: test fragmentation characteristics of copy-on-write
[xfstests-dev.git] / tests / xfs / 207
1 #! /bin/bash
2 # FS QA Test No. 207
3 #
4 # Test setting the extsz and cowextsz hints:
5 # - Ensure that we can set both on a zero-byte file.
6 # - Ensure that we can set only cowextsz on a many-byte file.
7 # - Ensure that whatever we set we get back later.
8 #
9 #-----------------------------------------------------------------------
10 # Copyright (c) 2016, 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.*
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 _supported_fs xfs
49 _require_scratch_reflink
50 _require_cp_reflink
51 _require_fiemap
52 _require_xfs_io_command "cowextsize"
53
54 rm -f $seqres.full
55
56 echo "Format and mount"
57 _scratch_mkfs > $seqres.full 2>&1
58 _scratch_mount >> $seqres.full 2>&1
59
60 testdir=$SCRATCH_MNT/test-$seq
61 mkdir $testdir
62
63 echo "Create the original files"
64 $XFS_IO_PROG -f -c "pwrite -S 0x61 0 0" $testdir/file1 >> $seqres.full
65 $XFS_IO_PROG -f -c "pwrite -S 0x61 0 1048576" $testdir/file2 >> $seqres.full
66 $XFS_IO_PROG -f -c "pwrite -S 0x61 0 0" $testdir/file3 >> $seqres.full
67 _scratch_remount
68
69 echo "Set extsz and cowextsz on zero byte file"
70 $XFS_IO_PROG -c "extsize 1048576" $testdir/file1 | _filter_scratch
71 $XFS_IO_PROG -c "cowextsize 1048576" $testdir/file1 | _filter_scratch
72
73 echo "Set extsz and cowextsz on 1Mbyte file"
74 $XFS_IO_PROG -c "extsize 1048576" $testdir/file2 | _filter_scratch
75 $XFS_IO_PROG -c "cowextsize 1048576" $testdir/file2 | _filter_scratch
76 _scratch_remount
77
78 echo "Check extsz and cowextsz settings on zero byte file"
79 $XFS_IO_PROG -c "extsize" $testdir/file1 | _filter_scratch
80 $XFS_IO_PROG -c "cowextsize" $testdir/file1 | _filter_scratch
81
82 echo "Check extsz and cowextsz settings on 1Mbyte file"
83 $XFS_IO_PROG -c "extsize" $testdir/file2 | _filter_scratch
84 $XFS_IO_PROG -c "cowextsize" $testdir/file2 | _filter_scratch
85
86 echo "Set cowextsize and check flag"
87 $XFS_IO_PROG -c "cowextsize 1048576" $testdir/file3 | _filter_scratch
88 _scratch_remount
89
90 $XFS_IO_PROG -c "stat" $testdir/file3 | grep 'fsxattr.xflags' | _filter_scratch
91 $XFS_IO_PROG -c "cowextsize" $testdir/file3 | _filter_scratch
92
93 echo "Unset cowextsize and check flag"
94 $XFS_IO_PROG -c "cowextsize 0" $testdir/file3 | _filter_scratch
95 _scratch_remount
96
97 $XFS_IO_PROG -c "stat" $testdir/file3 | grep 'fsxattr.xflags' | _filter_scratch
98 $XFS_IO_PROG -c "cowextsize" $testdir/file3 | _filter_scratch
99
100 status=0
101 exit