]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
xfs: report fs corruption errors to the health tracking system
authorDarrick J. Wong <djwong@kernel.org>
Thu, 22 Feb 2024 20:31:02 +0000 (12:31 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Thu, 22 Feb 2024 20:31:02 +0000 (12:31 -0800)
Whenever we encounter corrupt fs metadata, we should report that to the
health monitoring system for later reporting.  A convenient program for
identifying places to insert xfs_*_mark_sick calls is as follows:

#!/bin/bash

# Detect missing calls to xfs_*_mark_sick

filter=cat
tty -s && filter=less

git grep -B3 EFSCORRUPTED fs/xfs/*.[ch] fs/xfs/libxfs/*.[ch] fs/xfs/scrub/*.[ch] | awk '
BEGIN {
ignore = 0;
lineno = 0;
delete lines;
}
{
if ($0 == "--") {
if (!ignore) {
for (i = 0; i < lineno; i++) {
print(lines[i]);
}
printf("--\n");
}
delete lines;
lineno = 0;
ignore = 0;
} else if ($0 ~ /mark_sick/) {
ignore = 1;
} else if ($0 ~ /if .fa/) {
ignore = 1;
} else if ($0 ~ /failaddr/) {
ignore = 1;
} else if ($0 ~ /_verifier_error/) {
ignore = 1;
} else if ($0 ~ /^ \* .*EFSCORRUPTED/) {
ignore = 1;
} else if ($0 ~ /== -EFSCORRUPTED/) {
ignore = 1;
} else if ($0 ~ /!= -EFSCORRUPTED/) {
ignore = 1;
} else {
lines[lineno++] = $0;
}
}
' | $filter

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
fs/xfs/libxfs/xfs_ag.c

index 036f4ee43fd3c796fa4583427ab76d297614c365..d23800c45292e5dd797f2c27cb4c261dc67ba206 100644 (file)
@@ -217,6 +217,7 @@ xfs_initialize_perag_data(
         */
        if (fdblocks > sbp->sb_dblocks || ifree > ialloc) {
                xfs_alert(mp, "AGF corruption. Please run xfs_repair.");
+               xfs_fs_mark_sick(mp, XFS_SICK_FS_COUNTERS);
                error = -EFSCORRUPTED;
                goto out;
        }