]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: report fs corruption errors to the health tracking system
authorDarrick J. Wong <djwong@kernel.org>
Mon, 22 Apr 2024 17:00:54 +0000 (10:00 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Mon, 3 Jun 2024 18:37:36 +0000 (11:37 -0700)
Source kernel commit: 50645ce8822d23ae3e002d3bee775fa8c315f957

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>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
libxfs/util.c
libxfs/xfs_ag.c

index 8cea0c1500b417c25c682166eb426dd1a4f5fdb1..26339171ff82e84230c4055ca3c40cfcc7ff9a32 100644 (file)
@@ -728,3 +728,4 @@ xfs_fs_mark_healthy(
 }
 
 void xfs_ag_geom_health(struct xfs_perag *pag, struct xfs_ag_geometry *ageo) { }
+void xfs_fs_mark_sick(struct xfs_mount *mp, unsigned int mask) { }
index 86024ddfd74a506f2b523227488cdd6f8a48a936..e001ac11ca85cf90fa94370f56b0956f64a8c7c7 100644 (file)
@@ -215,6 +215,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;
        }