xfs: new test on xfs with corrupted sb_inopblock
PATCH v2 1/1 xfs: new test on xfs with corrupted sb_inopblock
There's a known bug fix 392c6de98af1 ("xfs: sanitize sb_inopblock in xfs_mount_validate_sb"). So try to corrupt the sb_inopblock of xfs, to cover this bug.
---
V2 does below changes:
1) Add _fixed_by_kernel_commit ...
2) Repair and check the xfs at the test end
Thanks,
Zorro
tests/xfs/555 | 32 ++++++++++++++++++++++++++++++++ tests/xfs/555.out | 6 ++++++ 2 files changed, 38 insertions(+) create mode 100755 tests/xfs/555 create mode 100644 tests/xfs/555.out
tests/xfs/555 new file +32 -0
@@ -0,0 +1,32 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2022 Red Hat, Inc. All Rights Reserved. +# +# FS QA Test 555 +# +# Corrupt xfs sb_inopblock, make sure no crash. This's a test coverage of +# 392c6de98af1 ("xfs: sanitize sb_inopblock in xfs_mount_validate_sb") +# +. ./common/preamble +_begin_fstest auto quick + +# real QA test starts here +_supported_fs xfs +_fixed_by_kernel_commit 392c6de98af1 \ + "xfs: sanitize sb_inopblock in xfs_mount_validate_sb" +_require_scratch + +_scratch_mkfs >>$seqres.full +echo "corrupt inopblock of sb 0" +_scratch_xfs_set_metadata_field "inopblock" "500" "sb 0" >> $seqres.full +echo "try to mount ..." +_try_scratch_mount 2>> $seqres.full && _fail "mount should not succeed!" +echo "no crash or hang" +echo "repair corrupted sb 0" +_scratch_xfs_repair >> $seqres.full 2>&1 +echo "check fs" +_scratch_xfs_repair -n >> $seqres.full 2>&1 || echo "fs isn't fixed!" + +# success, all done +status=0 +exit
tests/xfs/555.out new file +6 -0
@@ -0,0 +1,6 @@ +QA output created by 555 +corrupt inopblock of sb 0 +try to mount ... +no crash or hang +repair corrupted sb 0 +check fs
Signature · 1 line
2.31.1
Quoted 33 lines · Zorro Lang
There's a known bug fix
392c6de98af1("xfs: sanitizesb_inopblockinxfs_mount_validate_sb"). So try to corrupt thesb_inopblockof xfs, to cover this bug.Signed-off-by Zorro Lang <[email protected]>---
V2 does below changes:
1) Add_fixed_by_kernel_commit...
2) Repair and check the xfs at the test endThanks,
Zorrotests/xfs/555 | 32 ++++++++++++++++++++++++++++++++ tests/xfs/555.out | 6 ++++++ 2 files changed, 38 insertions(+) create mode 100755 tests/xfs/555 create mode 100644 tests/xfs/555.outtests/xfs/555 new file +7
-0@@ -0,0 +1,32 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2022 Red Hat, Inc. All Rights Reserved. +# +# FS QA Test 555 +# +# Corrupt xfs sb_inopblock, make sure no crash. This's a test coverage of
tests/xfs/555 line 17
Quoted 10 lines
tests/xfs/555 new file +10
-0+# 392c6de98af1 ("xfs: sanitize sb_inopblock in xfs_mount_validate_sb") +# +. ./common/preamble +_begin_fstest auto quick + +# real QA test starts here +_supported_fs xfs +_fixed_by_kernel_commit 392c6de98af1 \ + "xfs: sanitize sb_inopblock in xfs_mount_validate_sb" +_require_scratch
This /might/ want a _require_xfs_db_command "write" too, but that might not be necessary since iirc 'write' has been in db for a long time now.
Either way, this test looks ok to me so
--D
Quoted 30 lines
tests/xfs/555 new file +15
-0+ +_scratch_mkfs >>$seqres.full +echo "corrupt inopblock of sb 0" +_scratch_xfs_set_metadata_field "inopblock" "500" "sb 0" >> $seqres.full +echo "try to mount ..." +_try_scratch_mount 2>> $seqres.full && _fail "mount should not succeed!" +echo "no crash or hang" +echo "repair corrupted sb 0" +_scratch_xfs_repair >> $seqres.full 2>&1 +echo "check fs" +_scratch_xfs_repair -n >> $seqres.full 2>&1 || echo "fs isn't fixed!" + +# success, all done +status=0 +exittests/xfs/555.out new file +6
-0@@ -0,0 +1,6 @@ +QA output created by 555 +corrupt inopblock of sb 0 +try to mount ... +no crash or hang +repair corrupted sb 0 +check fsSignature · 1 line
2.31.1