2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016, Oracle and/or its affiliates. All Rights Reserved.
7 # Test setting the extsz and cowextsz hints:
8 # - Ensure that we can set both on a zero-byte file.
9 # - Ensure that we can set only cowextsz on a many-byte file.
10 # - Ensure that whatever we set we get back later.
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
18 status=1 # failure is the default!
19 trap "_cleanup; exit \$status" 0 1 2 3 15
27 # get standard environment, filters and checks
32 # real QA test starts here
35 _require_scratch_reflink
37 _require_xfs_io_command "fiemap"
38 _require_xfs_io_command "cowextsize"
40 # Takes the fsxattr.xflags line,
41 # i.e. fsxattr.xflags = 0x0 [--------------C-]
42 # and tests whether a flag character is set
46 grep -q "\[.*${flg}.*\]" && echo "$flg flag set" || echo "$flg flag unset"
51 echo "Format and mount"
52 _scratch_mkfs > $seqres.full 2>&1
53 _scratch_mount >> $seqres.full 2>&1
55 testdir=$SCRATCH_MNT/test-$seq
58 echo "Create the original files"
59 $XFS_IO_PROG -f -c "pwrite -S 0x61 0 0" $testdir/file1 >> $seqres.full
60 $XFS_IO_PROG -f -c "pwrite -S 0x61 0 1048576" $testdir/file2 >> $seqres.full
61 $XFS_IO_PROG -f -c "pwrite -S 0x61 0 0" $testdir/file3 >> $seqres.full
64 echo "Set extsz and cowextsz on zero byte file"
65 $XFS_IO_PROG -c "extsize 1048576" $testdir/file1 | _filter_scratch
66 $XFS_IO_PROG -c "cowextsize 1048576" $testdir/file1 | _filter_scratch
68 echo "Set extsz and cowextsz on 1Mbyte file"
69 $XFS_IO_PROG -c "extsize 1048576" $testdir/file2 | _filter_scratch
70 $XFS_IO_PROG -c "cowextsize 1048576" $testdir/file2 | _filter_scratch
73 echo "Check extsz and cowextsz settings on zero byte file"
74 $XFS_IO_PROG -c "extsize" $testdir/file1 | _filter_scratch
75 $XFS_IO_PROG -c "cowextsize" $testdir/file1 | _filter_scratch
77 echo "Check extsz and cowextsz settings on 1Mbyte file"
78 $XFS_IO_PROG -c "extsize" $testdir/file2 | _filter_scratch
79 $XFS_IO_PROG -c "cowextsize" $testdir/file2 | _filter_scratch
81 echo "Set cowextsize and check flag"
82 $XFS_IO_PROG -c "cowextsize 1048576" $testdir/file3 | _filter_scratch
85 $XFS_IO_PROG -c "stat" $testdir/file3 | grep 'fsxattr.xflags' | test_xflag "C"
86 $XFS_IO_PROG -c "cowextsize" $testdir/file3 | _filter_scratch
88 echo "Unset cowextsize and check flag"
89 $XFS_IO_PROG -c "cowextsize 0" $testdir/file3 | _filter_scratch
92 $XFS_IO_PROG -c "stat" $testdir/file3 | grep 'fsxattr.xflags' | test_xflag "C"
93 $XFS_IO_PROG -c "cowextsize" $testdir/file3 | _filter_scratch