From a62490a118449c37a19cfd5370cfbc2e6a792bca Mon Sep 17 00:00:00 2001 From: "Darrick J. Wong" Date: Thu, 4 Oct 2018 17:19:20 -0700 Subject: [PATCH] xfs: test mount time summary counter check and fix Tests to ensure that the xfs mount code can detect obviously bad fs summary counters at mount time and fix them. Signed-off-by: Darrick J. Wong Reviewed-by: Eryu Guan Signed-off-by: Eryu Guan --- tests/xfs/491 | 58 +++++++++++++++++++++++++++++++++++++++++ tests/xfs/491.out | 4 +++ tests/xfs/492 | 58 +++++++++++++++++++++++++++++++++++++++++ tests/xfs/492.out | 4 +++ tests/xfs/493 | 66 +++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/493.out | 4 +++ tests/xfs/group | 3 +++ 7 files changed, 197 insertions(+) create mode 100755 tests/xfs/491 create mode 100644 tests/xfs/491.out create mode 100755 tests/xfs/492 create mode 100644 tests/xfs/492.out create mode 100755 tests/xfs/493 create mode 100644 tests/xfs/493.out diff --git a/tests/xfs/491 b/tests/xfs/491 new file mode 100755 index 00000000..420c6f93 --- /dev/null +++ b/tests/xfs/491 @@ -0,0 +1,58 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2018 Oracle. All Rights Reserved. +# +# FS QA Test No. 491 +# +# Test detection & fixing of bad summary block counts at mount time. +# +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap '_cleanup; exit $status' 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here + +# Modify as appropriate. +_supported_fs xfs +_supported_os Linux +_require_scratch + +echo "Format and mount" +_scratch_mkfs > $seqres.full 2>&1 +_scratch_mount >> $seqres.full 2>&1 +echo "test file" > $SCRATCH_MNT/testfile + +echo "Fuzz fdblocks" +_scratch_unmount +dblocks=$(_scratch_xfs_get_metadata_field dblocks 'sb 0') +_scratch_xfs_set_metadata_field fdblocks $((dblocks * 2)) 'sb 0' > $seqres.full 2>&1 + +echo "Detection and Correction" +_scratch_mount >> $seqres.full 2>&1 +avail=$(stat -c '%a' -f $SCRATCH_MNT) +total=$(stat -c '%b' -f $SCRATCH_MNT) +echo "avail: $avail" >> $seqres.full +echo "total: $total" >> $seqres.full +test "$avail" -gt "$total" && echo "free space bad: $avail > $total" + +# success, all done +status=0 +exit diff --git a/tests/xfs/491.out b/tests/xfs/491.out new file mode 100644 index 00000000..f2d98a54 --- /dev/null +++ b/tests/xfs/491.out @@ -0,0 +1,4 @@ +QA output created by 491 +Format and mount +Fuzz fdblocks +Detection and Correction diff --git a/tests/xfs/492 b/tests/xfs/492 new file mode 100755 index 00000000..a83d7b7b --- /dev/null +++ b/tests/xfs/492 @@ -0,0 +1,58 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2018 Oracle. All Rights Reserved. +# +# FS QA Test No. 492 +# +# Test detection & fixing of bad summary inode counts at mount time. +# +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap '_cleanup; exit $status' 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here + +# Modify as appropriate. +_supported_fs xfs +_supported_os Linux +_require_scratch + +echo "Format and mount" +_scratch_mkfs > $seqres.full 2>&1 +_scratch_mount >> $seqres.full 2>&1 +echo "test file" > $SCRATCH_MNT/testfile + +echo "Fuzz ifree" +_scratch_unmount +icount=$(_scratch_xfs_get_metadata_field icount 'sb 0') +_scratch_xfs_set_metadata_field ifree $((icount * 2)) 'sb 0' > $seqres.full 2>&1 + +echo "Detection and Correction" +_scratch_mount >> $seqres.full 2>&1 +avail=$(stat -c '%d' -f $SCRATCH_MNT) +total=$(stat -c '%c' -f $SCRATCH_MNT) +echo "avail: $avail" >> $seqres.full +echo "total: $total" >> $seqres.full +test "$avail" -gt "$total" && echo "free inodes bad: $avail > $total" + +# success, all done +status=0 +exit diff --git a/tests/xfs/492.out b/tests/xfs/492.out new file mode 100644 index 00000000..18d787c8 --- /dev/null +++ b/tests/xfs/492.out @@ -0,0 +1,4 @@ +QA output created by 492 +Format and mount +Fuzz ifree +Detection and Correction diff --git a/tests/xfs/493 b/tests/xfs/493 new file mode 100755 index 00000000..9a1aad94 --- /dev/null +++ b/tests/xfs/493 @@ -0,0 +1,66 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2018 Oracle. All Rights Reserved. +# +# FS QA Test No. 493 +# +# Test detection & fixing of bad summary block counts at mount time. +# Corrupt the AGFs to test mount failure when mount-fixing fails. +# +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap '_cleanup; exit $status' 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here + +# Modify as appropriate. +_supported_fs xfs +_supported_os Linux +_require_scratch_nocheck + +echo "Format and mount" +_scratch_mkfs > $seqres.full 2>&1 +_scratch_mount >> $seqres.full 2>&1 +echo "test file" > $SCRATCH_MNT/testfile + +echo "Fuzz fdblocks and btreeblks" +_scratch_unmount +dblocks=$(_scratch_xfs_get_metadata_field dblocks 'sb 0') +_scratch_xfs_set_metadata_field fdblocks $((dblocks * 2)) 'sb 0' > $seqres.full 2>&1 + +aglen=$(_scratch_xfs_get_metadata_field length 'agf 0') +_scratch_xfs_set_metadata_field btreeblks $aglen 'agf 0' > $seqres.full 2>&1 + +echo "Detection and Correction" +if _try_scratch_mount >> $seqres.full 2>&1; then + echo "mount should have failed" + avail=$(stat -c '%a' -f $SCRATCH_MNT) + total=$(stat -c '%b' -f $SCRATCH_MNT) + echo "avail: $avail" >> $seqres.full + echo "total: $total" >> $seqres.full + test "$avail" -gt "$total" && echo "free space bad: $avail > $total" + _scratch_unmount +fi +_scratch_xfs_repair -n >> $seqres.full 2>&1 && echo "repair didn't find fuzz?" + +# success, all done +status=0 +exit diff --git a/tests/xfs/493.out b/tests/xfs/493.out new file mode 100644 index 00000000..ea29cff1 --- /dev/null +++ b/tests/xfs/493.out @@ -0,0 +1,4 @@ +QA output created by 493 +Format and mount +Fuzz fdblocks and btreeblks +Detection and Correction diff --git a/tests/xfs/group b/tests/xfs/group index 821bf2ac..2cec0585 100644 --- a/tests/xfs/group +++ b/tests/xfs/group @@ -488,3 +488,6 @@ 488 dangerous_fuzzers dangerous_norepair 489 dangerous_fuzzers dangerous_norepair 490 auto quick +491 auto quick fuzz +492 auto quick fuzz +493 auto quick fuzz -- 2.30.2