2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018 Oracle, Inc. All Rights Reserved.
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
13 _begin_fstest auto quick repair
15 _register_cleanup "_cleanup" BUS
17 # Import common functions.
22 # real QA test starts here
24 _require_scratch_nocheck
25 _require_populate_commands
26 _require_xfs_db_command "fuzz"
28 echo "Format and populate"
29 _scratch_populate_cached nofill > $seqres.full 2>&1
32 grep rebuilding | sed -e 's/directory inode [0-9]*/directory inode XXX/g'
36 _scratch_xfs_repair > $tmp.repair 2>&1
37 cat $tmp.repair >> $seqres.full
38 cat $tmp.repair | filter_nbrepair
41 echo "Check leafn rebuilds"
45 echo "Fuzz nbtree[0].before to zero"
47 inum=$(stat -c '%i' $SCRATCH_MNT/S_IFDIR.FMT_NODE)
48 blk_sz=$(_get_block_size $SCRATCH_MNT)
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
54 echo "Check nbtree[0].before repair"