Files
apfstests/tests/xfs/506
T
Darrick J. Wong f7a8c5c4ad xfs/506: fix regression on freshly quotachecked filesystem
The first thing this test checks is that the health command reports that
nothing has been checked.  This isn't true if we regenerated the quota
counts when we mounted the filesystem (and hence they're marked healthy
and checked), so cycle the mount to get rid of that state.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2021-04-18 20:53:53 +08:00

83 lines
1.8 KiB
Bash
Executable File

#! /bin/bash
# SPDX-License-Identifier: GPL-2.0+
# Copyright (c) 2019, Oracle and/or its affiliates. All Rights Reserved.
#
# FS QA Test No. 506
#
# Basic tests of the xfs_spaceman health command.
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/fuzzy
. ./common/filter
# real QA test starts here
_supported_fs xfs
_require_scratch_nocheck
_require_scrub
_require_xfs_spaceman_command "health"
rm -f $seqres.full
_scratch_mkfs > $seqres.full 2>&1
_scratch_mount
_scratch_cycle_mount # make sure we haven't run quotacheck on this mount
# Haven't checked anything, it should tell us to run scrub
$XFS_SPACEMAN_PROG -c "health" $SCRATCH_MNT
# Run scrub to collect health info.
_scratch_scrub -n >> $seqres.full
query() {
$XFS_SPACEMAN_PROG -c "$@" $SCRATCH_MNT | tee -a $seqres.full
}
query_health() {
query "$@" | grep -q ": ok$"
}
query_sick() {
query "$@" | grep -q ": unhealthy$"
}
# Let's see if we get at least one healthy rating for each health reporting
# group.
query_health "health -f" || \
echo "Didn't see a single healthy fs metadata?"
query_health "health -a 0" || \
echo "Didn't see a single healthy ag metadata?"
query_health "health $SCRATCH_MNT" || \
echo "Didn't see a single healthy file metadata?"
# Unmount, corrupt filesystem
_scratch_unmount
_scratch_xfs_db -x -c 'sb 1' -c 'fuzz -d magicnum random' >> $seqres.full
# Now let's see what the AG report says
_scratch_mount
_scratch_scrub -n >> $seqres.full 2>&1
query_sick "health -a 1" || \
echo "Didn't see the expected unhealthy metadata?"
# success, all done
status=0
exit