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 _begin_fstest auto quick clone
15 # Import common functions.
19 # real QA test starts here
21 _require_scratch_reflink
23 _require_xfs_io_command "fiemap"
24 _require_xfs_io_command "cowextsize"
26 # Takes the fsxattr.xflags line,
27 # i.e. fsxattr.xflags = 0x0 [--------------C-]
28 # and tests whether a flag character is set
32 grep -q "\[.*${flg}.*\]" && echo "$flg flag set" || echo "$flg flag unset"
35 echo "Format and mount"
36 _scratch_mkfs > $seqres.full 2>&1
37 _scratch_mount >> $seqres.full 2>&1
38 _xfs_force_bdev data $SCRATCH_MNT
40 testdir=$SCRATCH_MNT/test-$seq
43 echo "Create the original files"
44 $XFS_IO_PROG -f -c "pwrite -S 0x61 0 0" $testdir/file1 >> $seqres.full
45 $XFS_IO_PROG -f -c "pwrite -S 0x61 0 1048576" $testdir/file2 >> $seqres.full
46 $XFS_IO_PROG -f -c "pwrite -S 0x61 0 0" $testdir/file3 >> $seqres.full
49 echo "Set extsz and cowextsz on zero byte file"
50 $XFS_IO_PROG -c "extsize 1048576" $testdir/file1 | _filter_scratch
51 $XFS_IO_PROG -c "cowextsize 1048576" $testdir/file1 | _filter_scratch
53 echo "Set extsz and cowextsz on 1Mbyte file"
54 $XFS_IO_PROG -c "extsize 1048576" $testdir/file2 | _filter_scratch
55 $XFS_IO_PROG -c "cowextsize 1048576" $testdir/file2 | _filter_scratch
58 echo "Check extsz and cowextsz settings on zero byte file"
59 $XFS_IO_PROG -c "extsize" $testdir/file1 | _filter_scratch
60 $XFS_IO_PROG -c "cowextsize" $testdir/file1 | _filter_scratch
62 echo "Check extsz and cowextsz settings on 1Mbyte file"
63 $XFS_IO_PROG -c "extsize" $testdir/file2 | _filter_scratch
64 $XFS_IO_PROG -c "cowextsize" $testdir/file2 | _filter_scratch
66 echo "Set cowextsize and check flag"
67 $XFS_IO_PROG -c "cowextsize 1048576" $testdir/file3 | _filter_scratch
70 $XFS_IO_PROG -c "stat" $testdir/file3 | grep 'fsxattr.xflags' | test_xflag "C"
71 $XFS_IO_PROG -c "cowextsize" $testdir/file3 | _filter_scratch
73 echo "Unset cowextsize and check flag"
74 $XFS_IO_PROG -c "cowextsize 0" $testdir/file3 | _filter_scratch
77 $XFS_IO_PROG -c "stat" $testdir/file3 | grep 'fsxattr.xflags' | test_xflag "C"
78 $XFS_IO_PROG -c "cowextsize" $testdir/file3 | _filter_scratch