This case is a regression test for xfsprogs commit f4afdcb0a ("xfs_db: clean up the salvage read callsites in set_cur()"). I found this because xfs/270 on older xfsprogs can hit this bug. The code is pasted from xfs/270 but remove mount rw/ro test. Signed-off-by: Yang Xu <xuyang2018.jy@xxxxxxxxxxx> --- tests/xfs/082 | 67 +++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/082.out | 2 ++ 2 files changed, 69 insertions(+) create mode 100755 tests/xfs/082 create mode 100644 tests/xfs/082.out diff --git a/tests/xfs/082 b/tests/xfs/082 new file mode 100755 index 00000000..7a5ece8f --- /dev/null +++ b/tests/xfs/082 @@ -0,0 +1,67 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2022 FUJITSU LIMITED. All rights reserved. +# +# FS QA Test 082 +# +# Today xfs_db set_cur whether clean up the LIBXFS_READBUF_SALVAGE +# call sites so that we use the return value directly instead of +# scraping it out later. +# +# It is a regression test for xfsprogs +# f4afdcb0a ("xfs_db: clean up the salvage read callsites in set_cur()"). +# + +. ./common/preamble +_begin_fstest auto quick mount + +# Import common functions. +. ./common/filter + +# real QA test starts here +_supported_fs xfs +# skip fs check because superblock contains unknown ro-compat features +_require_scratch_nocheck +# Only V5 XFS disallow rw mount/remount with unknown ro-compat features +_require_scratch_xfs_crc + +_scratch_mkfs_xfs >>$seqres.full 2>&1 + +# set the highest bit of features_ro_compat, use it as an unknown +# feature bit. If one day this bit become known feature, please +# change this case. + +ro_compat=$(_scratch_xfs_get_metadata_field "features_ro_compat" "sb 0") +echo $ro_compat | grep -q -E '^0x[[:xdigit:]]$' +if [[ $? != 0 ]]; then + echo "features_ro_compat has an invalid value." +fi + +ro_compat=$(echo $ro_compat | \ + awk '/^0x[[:xdigit:]]+/ { + printf("0x%x\n", or(strtonum($1), 0x80000000)) + }') + +# write the new ro compat field to the superblock +_scratch_xfs_set_metadata_field "features_ro_compat" "$ro_compat" "sb 0" \ + > $seqres.full 2>&1 + +# read the newly set ro compat filed for verification +new_ro_compat=$(_scratch_xfs_get_metadata_field "features_ro_compat" "sb 0" \ + >$seqres.full 2>&1) + +# verify the new ro_compat field is empty +# Without xfsprog patch, xfs_db set_cur function doesn't return directly when +# meeting error by using LIBXFS_READBUF_SALVAGE flag. So cache_purge will complain +# about this. +if [ -z $new_ro_compat ]; then + grep -q "cache_purge: shake on cache" $seqres.full && \ + echo "Hit xfsprogs set_cur bug" + echo "Unable to get new ro compat filed" +fi + +echo "Silence is golden." + +# success, all done +status=0 +exit diff --git a/tests/xfs/082.out b/tests/xfs/082.out new file mode 100644 index 00000000..6ed56cb1 --- /dev/null +++ b/tests/xfs/082.out @@ -0,0 +1,2 @@ +QA output created by 082 +Silence is golden. -- 2.27.0