2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018 Oracle. All Rights Reserved.
7 # Test detection & fixing of bad summary block counts at mount time.
8 # Corrupt the AGFs to test mount failure when mount-fixing fails.
11 _begin_fstest auto quick fuzz
13 # Import common functions.
16 # real QA test starts here
18 # Modify as appropriate.
20 _require_scratch_nocheck
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
27 echo "Fuzz fdblocks and btreeblks"
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
32 aglen=$(_scratch_xfs_get_metadata_field length 'agf 0')
33 _scratch_xfs_set_metadata_field btreeblks $aglen 'agf 0' > $seqres.full 2>&1
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"
45 _scratch_xfs_repair -n >> $seqres.full 2>&1 && echo "repair didn't find fuzz?"