summaryrefslogtreecommitdiff
path: root/tests/xfs/115
blob: f0647281284ee12b4cd6f8b7257f766feec722bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2017 Red Hat, Inc.  All Rights Reserved.
#
# FS QA Test 115
#
# Check if the filesystem will lockup when trying to allocate a new inode in
# an AG with no free inodes but with a corrupted agi->freecount showing free inodes.
#
# At the end of the test, the scratch device will purposely be in a corrupted
# state, so there is no need for checking that.
. ./common/preamble
_begin_fstest auto quick fuzzers

# Import common functions.
. ./common/filter

# real QA test starts here

# Modify as appropriate.
_supported_fs generic
_require_scratch_nocheck
# We corrupt XFS on purpose, and check if assert failures would crash system.
_require_no_xfs_bug_on_assert
_disable_dmesg_check

# Make sure we disable finobt if the filesystem supports it, otherwise, just
# initialize it with default options.
_scratch_mkfs | grep -q "finobt=1" && _scratch_mkfs -m "finobt=0" >/dev/null 2>&1

# Get the amount of free inodes from the AGI 0, so we can fill up the freecount
# structure.
freecount=`_scratch_xfs_db -c "agi 0" -c "p freecount" | cut -d' ' -f 3`

_scratch_mount

# At the end of filesystem's initialization, AG 0 will have $freecount free
# inodes in the agi->freecount, create $freecount extra dummy files to fill it.
for i in `seq 1 $freecount`; do
	touch $SCRATCH_MNT/dummy_file$i
done

_scratch_unmount

# agi->freecount is 0 here, corrupt it to show extra free inodes
_scratch_xfs_db -x -c "agi 0" -c "write freecount 10" >> $seqres.full 2>&1

_scratch_mount

# Lock up a buggy kernel
touch $SCRATCH_MNT/lockupfile >> $seqres.full 2>&1

# If we reach this point, the filesystem is fixed
echo "Silence is golden"
status=0
exit