[PATCH 3/5] xfs_scrub: update health status if we get a clean bill of health

Darrick J. Wong
2024-06-03T19:23:37Z

If we checked a filesystem and it turned out to be clean, upload that
information into the kernel.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
libfrog/scrub.c | 5 +++++
man/man2/ioctl_xfs_scrub_metadata.2 | 6 ++++++
scrub/scrub.c | 7 +------
3 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/libfrog/scrub.c b/libfrog/scrub.c
index b6b8ae042..1df2965fe 100644
--- a/libfrog/scrub.c
+++ b/libfrog/scrub.c
@@ -144,6 +144,11 @@ const struct xfrog_scrub_descr xfrog_scrubbers[XFS_SCRUB_TYPE_NR] = {
.descr = "inode link counts",
.group = XFROG_SCRUB_GROUP_ISCAN,
},
+ [XFS_SCRUB_TYPE_HEALTHY] = {
+ .name = "healthy",
+ .descr = "retained health records",
+ .group = XFROG_SCRUB_GROUP_NONE,
+ },
};

/* Invoke the scrub ioctl. Returns zero or negative error code. */
diff --git a/man/man2/ioctl_xfs_scrub_metadata.2 b/man/man2/ioctl_xfs_scrub_metadata.2
index 8e8bb72fb..9963f1913 100644
--- a/man/man2/ioctl_xfs_scrub_metadata.2
+++ b/man/man2/ioctl_xfs_scrub_metadata.2
@@ -168,6 +168,12 @@ count) for errors.
.TP
.B XFS_SCRUB_TYPE_NLINKS
Scan all inodes in the filesystem to verify each file's link count.
+
+.TP
+.B XFS_SCRUB_TYPE_HEALTHY
+Mark everything healthy after a clean scrub run.
+This clears out all the indirect health problem markers that might remain
+in the system.
.RE

.PD 1
diff --git a/scrub/scrub.c b/scrub/scrub.c
index a22633a81..436ccb0ca 100644
--- a/scrub/scrub.c
+++ b/scrub/scrub.c
@@ -39,20 +39,15 @@ format_scrub_descr(
case XFROG_SCRUB_GROUP_PERAG:
return snprintf(buf, buflen, _("AG %u %s"), meta->sm_agno,
_(sc->descr));
- break;
case XFROG_SCRUB_GROUP_INODE:
return scrub_render_ino_descr(ctx, buf, buflen,
meta->sm_ino, meta->sm_gen, "%s",
_(sc->descr));
- break;
case XFROG_SCRUB_GROUP_FS:
case XFROG_SCRUB_GROUP_SUMMARY:
case XFROG_SCRUB_GROUP_ISCAN:
- return snprintf(buf, buflen, _("%s"), _(sc->descr));
- break;
case XFROG_SCRUB_GROUP_NONE:
- assert(0);
- break;
+ return snprintf(buf, buflen, _("%s"), _(sc->descr));
}
return -1;
}