fsx/fsstress: round blocksize properly
[xfstests-dev.git] / tests / xfs / 270
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016 Red Hat, Inc.  All Rights Reserved.
4 #
5 # FS QA Test 270
6 #
7 # Today ro-compat features can't be mounted rw, but a bug allows
8 # an ro->rw remount transition. This bug has been fixed on linux
9 # kernel (d0a58e8 xfs: disallow rw remount on fs with unknown
10 # ro-compat features), and this case is the regression testcase.
11 #
12 seq=`basename $0`
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
15
16 here=`pwd`
17 tmp=/tmp/$$
18 status=1        # failure is the default!
19 trap "_cleanup; exit \$status" 0 1 2 3 15
20
21 _cleanup()
22 {
23         cd /
24         rm -f $tmp.*
25 }
26
27 # get standard environment, filters and checks
28 . ./common/rc
29 . ./common/filter
30
31 # remove previous $seqres.full before test
32 rm -f $seqres.full
33
34 # real QA test starts here
35 _supported_fs xfs
36 # skip fs check because superblock contains unknown ro-compat features
37 _require_scratch_nocheck
38 # Only V5 XFS disallow rw mount/remount with unknown ro-compat features
39 _require_scratch_xfs_crc
40
41 _scratch_mkfs_xfs >>$seqres.full 2>&1
42
43 # set the highest bit of features_ro_compat, use it as an unknown
44 # feature bit. If one day this bit become known feature, please
45 # change this case.
46 _scratch_xfs_set_metadata_field "features_ro_compat" "$((2**31))" "sb 0" | \
47         grep 'features_ro_compat'
48
49 # rw mount with unknown ro-compat feature should fail
50 echo "rw mount test"
51 _try_scratch_mount 2>>$seqres.full
52 if [ $? -eq 0 ]; then
53         _fail "rw mount test failed"
54 fi
55
56 # But ro mount should succeed
57 echo "ro mount test"
58 _try_scratch_mount -o ro
59 if [ $? -ne 0 ]; then
60         _fail "ro mount test failed"
61 else
62         # no hang/panic is fine
63         $FSSTRESS_PROG -d $SCRATCH_MNT -p 4 -n 400 >>$seqres.full 2>&1
64 fi
65
66 # remount as rw, kernel should reject it
67 echo "rw remount test"
68 _scratch_remount rw 2>>$seqres.full
69 if [ $? -eq 0 ]; then
70         dmesg | tail -n 15 >> $seqres.full
71         _fail "rw remount test failed"
72 fi
73
74 _scratch_unmount
75
76 # success, all done
77 status=0
78 exit