xfs/444: fix agfl reset warning detection for small log buffers
authorDarrick J. Wong <djwong@kernel.org>
Wed, 3 Jul 2024 21:36:05 +0000 (14:36 -0700)
committerZorro Lang <zlang@kernel.org>
Thu, 4 Jul 2024 14:17:42 +0000 (22:17 +0800)
Collectively, the ten subtests in xfs/444 can generate a lot of kernel
log data.  If the amount of log data is enough to overflow the kernel
log buffers, the AGFL reset warning generated by fix_start and fix_wrap
might have been overwritten by subsequent log data.  Fix this by
checking for the reset warning after each test and only complaining if
at the end if we have /never/ seen the warning.

Found by running on a kernel configured with CONFIG_LOG_BUF_SHIFT=14
(16K).  This happened to be a Raspberry Pi, but in principle this can
happen to anyone.  I'd never noticed this before because x86 helpfully
sets it to 17 (128K) by default.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
tests/xfs/444

index db7418c55deed315e18ce03a6d0bb47f7d65822f..cf78a9a1f09eb9c41e5b3d99d90493ef692add47 100755 (executable)
@@ -58,6 +58,10 @@ dump_ag0() {
        _scratch_xfs_db -c 'sb 0' -c 'p' -c 'agf 0' -c 'p' -c 'agfl 0' -c 'p'
 }
 
+# Did we get the kernel warning too?
+warn_str='WARNING: Reset corrupted AGFL'
+saw_agfl_reset_warning=0
+
 runtest() {
        cmd="$1"
 
@@ -208,6 +212,8 @@ ENDL
        echo "FS REMOUNT" >> $seqres.full
        dump_ag0 > $tmp.remount 2> /dev/null
        diff -u $tmp.repair $tmp.remount >> $seqres.full
+
+       _check_dmesg_for "${warn_str}" && ((saw_agfl_reset_warning++))
 }
 
 runtest fix_end
@@ -221,9 +227,11 @@ runtest bad_start
 runtest no_move
 runtest simple_move
 
-# Did we get the kernel warning too?
-warn_str='WARNING: Reset corrupted AGFL'
-_check_dmesg_for "${warn_str}" || echo "Missing dmesg string \"${warn_str}\"."
+# We must see the AGFL reset warning at least once.  Collectively, the subtests
+# can generate enough kernel log data to overflow the buffer, so we check for
+# the warning after each subtest and summarize the output here.
+((saw_agfl_reset_warning > 0)) || \
+       echo "Missing dmesg string \"${warn_str}\"."
 
 # Now run the regular dmesg check, filtering out the agfl warning
 filter_agfl_reset_printk() {