generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / xfs / 115
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Red Hat, Inc.  All Rights Reserved.
4 #
5 # FS QA Test 115
6 #
7 # Check if the filesystem will lockup when trying to allocate a new inode in
8 # an AG with no free inodes but with a corrupted agi->freecount showing free inodes.
9 #
10 # At the end of the test, the scratch device will purposely be in a corrupted
11 # state, so there is no need for checking that.
12 . ./common/preamble
13 _begin_fstest auto quick fuzzers
14
15 # Import common functions.
16 . ./common/filter
17
18 # real QA test starts here
19
20 # Modify as appropriate.
21 _supported_fs generic
22 _require_scratch_nocheck
23 # We corrupt XFS on purpose, and check if assert failures would crash system.
24 _require_no_xfs_bug_on_assert
25 _disable_dmesg_check
26
27 # Make sure we disable finobt if the filesystem supports it, otherwise, just
28 # initialize it with default options.
29 _scratch_mkfs | grep -q "finobt=1" && _scratch_mkfs -m "finobt=0" >/dev/null 2>&1
30
31 # Get the amount of free inodes from the AGI 0, so we can fill up the freecount
32 # structure.
33 freecount=`_scratch_xfs_db -c "agi 0" -c "p freecount" | cut -d' ' -f 3`
34
35 _scratch_mount
36
37 # At the end of filesystem's initialization, AG 0 will have $freecount free
38 # inodes in the agi->freecount, create $freecount extra dummy files to fill it.
39 for i in `seq 1 $freecount`; do
40         touch $SCRATCH_MNT/dummy_file$i
41 done
42
43 _scratch_unmount
44
45 # agi->freecount is 0 here, corrupt it to show extra free inodes
46 _scratch_xfs_db -x -c "agi 0" -c "write freecount 10" >> $seqres.full 2>&1
47
48 _scratch_mount
49
50 # Lock up a buggy kernel
51 touch $SCRATCH_MNT/lockupfile >> $seqres.full 2>&1
52
53 # If we reach this point, the filesystem is fixed
54 echo "Silence is golden"
55 status=0
56 exit