generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / xfs / 493
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018 Oracle.  All Rights Reserved.
4 #
5 # FS QA Test No. 493
6 #
7 # Test detection & fixing of bad summary block counts at mount time.
8 # Corrupt the AGFs to test mount failure when mount-fixing fails.
9 #
10 . ./common/preamble
11 _begin_fstest auto quick fuzzers
12
13 # Import common functions.
14 . ./common/filter
15
16 # real QA test starts here
17
18 # Modify as appropriate.
19 _supported_fs xfs
20 _require_scratch_nocheck
21
22 echo "Format and mount"
23 _scratch_mkfs > $seqres.full 2>&1
24 _scratch_mount >> $seqres.full 2>&1
25 echo "test file" > $SCRATCH_MNT/testfile
26
27 echo "Fuzz fdblocks and btreeblks"
28 _scratch_unmount
29 dblocks=$(_scratch_xfs_get_metadata_field dblocks 'sb 0')
30 _scratch_xfs_set_metadata_field fdblocks $((dblocks * 2)) 'sb 0' > $seqres.full 2>&1
31
32 aglen=$(_scratch_xfs_get_metadata_field length 'agf 0')
33 _scratch_xfs_set_metadata_field btreeblks $aglen 'agf 0' > $seqres.full 2>&1
34
35 echo "Detection and Correction"
36 if _try_scratch_mount >> $seqres.full 2>&1; then
37         echo "mount should have failed"
38         avail=$(stat -c '%a' -f $SCRATCH_MNT)
39         total=$(stat -c '%b' -f $SCRATCH_MNT)
40         echo "avail: $avail" >> $seqres.full
41         echo "total: $total" >> $seqres.full
42         test "$avail" -gt "$total" && echo "free space bad: $avail > $total"
43         _scratch_unmount
44 fi
45 _scratch_xfs_repair -n >> $seqres.full 2>&1 && echo "repair didn't find fuzz?"
46
47 # success, all done
48 status=0
49 exit