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
34 _require_scratch_reflink
36 _require_xfs_io_command "fiemap"
37 _require_xfs_io_command "cowextsize"
39 # Takes the fsxattr.xflags line,
40 # i.e. fsxattr.xflags = 0x0 [--------------C-]
41 # and tests whether a flag character is set
45 grep -q "\[.*${flg}.*\]" && echo "$flg flag set" || echo "$flg flag unset"
50 echo "Format and mount"
51 _scratch_mkfs > $seqres.full 2>&1
52 _scratch_mount >> $seqres.full 2>&1
54 testdir=$SCRATCH_MNT/test-$seq
57 echo "Create the original files"
58 $XFS_IO_PROG -f -c "pwrite -S 0x61 0 0" $testdir/file1 >> $seqres.full
59 $XFS_IO_PROG -f -c "pwrite -S 0x61 0 1048576" $testdir/file2 >> $seqres.full
60 $XFS_IO_PROG -f -c "pwrite -S 0x61 0 0" $testdir/file3 >> $seqres.full
63 echo "Set extsz and cowextsz on zero byte file"
64 $XFS_IO_PROG -c "extsize 1048576" $testdir/file1 | _filter_scratch
65 $XFS_IO_PROG -c "cowextsize 1048576" $testdir/file1 | _filter_scratch
67 echo "Set extsz and cowextsz on 1Mbyte file"
68 $XFS_IO_PROG -c "extsize 1048576" $testdir/file2 | _filter_scratch
69 $XFS_IO_PROG -c "cowextsize 1048576" $testdir/file2 | _filter_scratch
72 echo "Check extsz and cowextsz settings on zero byte file"
73 $XFS_IO_PROG -c "extsize" $testdir/file1 | _filter_scratch
74 $XFS_IO_PROG -c "cowextsize" $testdir/file1 | _filter_scratch
76 echo "Check extsz and cowextsz settings on 1Mbyte file"
77 $XFS_IO_PROG -c "extsize" $testdir/file2 | _filter_scratch
78 $XFS_IO_PROG -c "cowextsize" $testdir/file2 | _filter_scratch
80 echo "Set cowextsize and check flag"
81 $XFS_IO_PROG -c "cowextsize 1048576" $testdir/file3 | _filter_scratch
84 $XFS_IO_PROG -c "stat" $testdir/file3 | grep 'fsxattr.xflags' | test_xflag "C"
85 $XFS_IO_PROG -c "cowextsize" $testdir/file3 | _filter_scratch
87 echo "Unset cowextsize and check flag"
88 $XFS_IO_PROG -c "cowextsize 0" $testdir/file3 | _filter_scratch
91 $XFS_IO_PROG -c "stat" $testdir/file3 | grep 'fsxattr.xflags' | test_xflag "C"
92 $XFS_IO_PROG -c "cowextsize" $testdir/file3 | _filter_scratch