generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / xfs / 495
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018 Oracle, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 495
6 #
7 # Test for two related regressions -- first, check that repair doesn't
8 # repeatedly rebuild directories with a single leafn block; and check that
9 # repair also doesn't crash when it hits a corrupt da btree with a zero before
10 # pointer.
11 #
12 . ./common/preamble
13 _begin_fstest auto quick repair
14
15 _register_cleanup "_cleanup" BUS
16
17 # Import common functions.
18 . ./common/filter
19 . ./common/populate
20 . ./common/fuzzy
21
22 # real QA test starts here
23 _supported_fs xfs
24 _require_scratch_nocheck
25 _require_populate_commands
26 _require_xfs_db_command "fuzz"
27
28 echo "Format and populate"
29 _scratch_populate_cached nofill > $seqres.full 2>&1
30
31 filter_nbrepair() {
32         grep rebuilding | sed -e 's/directory inode [0-9]*/directory inode XXX/g'
33 }
34
35 run_repair() {
36         _scratch_xfs_repair > $tmp.repair 2>&1
37         cat $tmp.repair >> $seqres.full
38         cat $tmp.repair | filter_nbrepair
39 }
40
41 echo "Check leafn rebuilds"
42 run_repair
43 run_repair
44
45 echo "Fuzz nbtree[0].before to zero"
46 _scratch_mount
47 inum=$(stat -c '%i' $SCRATCH_MNT/S_IFDIR.FMT_NODE)
48 blk_sz=$(_get_block_size $SCRATCH_MNT)
49 _scratch_unmount
50 leaf_offset=$(( (2 ** 35) / blk_sz ))
51 _scratch_xfs_fuzz_metadata_field "nbtree[0].before" "zeroes" "inode ${inum}" \
52                                  "dblock ${leaf_offset}" >> $seqres.full
53
54 echo "Check nbtree[0].before repair"
55 run_repair
56 run_repair
57
58 # success, all done
59 echo Done
60 status=0
61 exit