generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / xfs / 199
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2008 Christoph Hellwig.
4 #
5 # FS QA Test No. 199
6 #
7 # Check that the features2 location fixups work correctly.  We check both
8 # a regular read-write mount of a filesystem and the case where the
9 # filesystem is first mounted read-only and then later remounted read-write,
10 # which is the usual case for the root filesystem.
11 #
12 . ./common/preamble
13 _begin_fstest mount auto quick
14
15 # Override the default cleanup function.
16 _cleanup()
17 {
18         cd /
19         _scratch_unmount >/dev/null 2>&1
20 }
21
22 # Import common functions.
23 . ./common/filter
24
25 # real QA test starts here
26 _supported_fs xfs
27
28 _require_scratch
29
30 # clear any mkfs options so that we can directly specify the options we need to
31 # be able to test the features bitmask behaviour correctly.
32 MKFS_OPTIONS=
33 _scratch_mkfs_xfs -m crc=0 -l lazy-count=1 >/dev/null 2>&1
34
35 # Grab the initial configuration. This checks mkfs sets the fields properly, and
36 # gives us the values the resultant tests should be the same as for testing at
37 # the end of the test. We don't hard code feature values, because that makes the
38 # test break every time we change mkfs feature defaults.
39 f2=`_scratch_xfs_get_sb_field features2`
40 bf2=`_scratch_xfs_get_sb_field bad_features2`
41
42 #
43 # Now clear the normal flags
44 #
45 echo "Clearing features2:"
46 _scratch_xfs_db -x  -c 'sb' -c 'write features2 0'
47
48 _scratch_mount
49 _scratch_unmount
50 rwf2=`_scratch_xfs_get_sb_field features2`
51
52 #
53 # Clear the normal flags again for the second rount.
54 #
55 echo "Clearing features2:"
56 _scratch_xfs_db -x  -c 'sb' -c 'write features2 0'
57
58 #
59 # And print the flags after a mount ro and remount rw
60 #
61 _scratch_mount -o ro
62 _scratch_mount -o remount,rw
63 _scratch_unmount
64 rof2=`_scratch_xfs_get_sb_field features2`
65
66 [ "$f2" != "$bf2" ] && echo "mkfs: features2 $f2 != bad_features2 $bf2"
67 [ "$f2" != "$rwf2" ] && echo "mount rw: old features2 $f2 != new features2 $rwf2"
68 [ "$f2" != "$rof2" ] && echo "ro->rw: old features2 $f2 != new features2 $rof2"
69
70 # success, all done
71 echo "*** done"
72 status=0