xfs/530: skip test if user MKFS_OPTIONS screw up formatting
[xfstests-dev.git] / tests / xfs / 207
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
4 #
5 # FS QA Test No. 207
6 #
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.
11 #
12 . ./common/preamble
13 _begin_fstest auto quick clone
14
15 # Import common functions.
16 . ./common/filter
17 . ./common/reflink
18
19 # real QA test starts here
20 _supported_fs xfs
21 _require_scratch_reflink
22 _require_cp_reflink
23 _require_xfs_io_command "fiemap"
24 _require_xfs_io_command "cowextsize"
25
26 # Takes the fsxattr.xflags line,
27 # i.e. fsxattr.xflags = 0x0 [--------------C-]
28 # and tests whether a flag character is set
29 test_xflag()
30 {
31     local flg=$1
32     grep -q "\[.*${flg}.*\]" && echo "$flg flag set" || echo "$flg flag unset"
33 }
34
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
39
40 testdir=$SCRATCH_MNT/test-$seq
41 mkdir $testdir
42
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
47 _scratch_cycle_mount
48
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
52
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
56 _scratch_cycle_mount
57
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
61
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
65
66 echo "Set cowextsize and check flag"
67 $XFS_IO_PROG -c "cowextsize 1048576" $testdir/file3 | _filter_scratch
68 _scratch_cycle_mount
69
70 $XFS_IO_PROG -c "stat" $testdir/file3 | grep 'fsxattr.xflags' | test_xflag "C"
71 $XFS_IO_PROG -c "cowextsize" $testdir/file3 | _filter_scratch
72
73 echo "Unset cowextsize and check flag"
74 $XFS_IO_PROG -c "cowextsize 0" $testdir/file3 | _filter_scratch
75 _scratch_cycle_mount
76
77 $XFS_IO_PROG -c "stat" $testdir/file3 | grep 'fsxattr.xflags' | test_xflag "C"
78 $XFS_IO_PROG -c "cowextsize" $testdir/file3 | _filter_scratch
79
80 status=0
81 exit