Commit 3f1bdf50 authored by Darrick J. Wong's avatar Darrick J. Wong
Browse files

xfs: scrub the realtime group superblock



Enable scrubbing of realtime group superblocks.

Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
parent 7333c948
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -191,6 +191,7 @@ xfs-y += $(addprefix scrub/, \
xfs-$(CONFIG_XFS_ONLINE_SCRUB_STATS) += scrub/stats.o

xfs-$(CONFIG_XFS_RT)		+= $(addprefix scrub/, \
				   rgsuper.o \
				   rtbitmap.o \
				   rtsummary.o \
				   )
+2 −1
Original line number Diff line number Diff line
@@ -736,9 +736,10 @@ struct xfs_scrub_metadata {
#define XFS_SCRUB_TYPE_HEALTHY	27	/* everything checked out ok */
#define XFS_SCRUB_TYPE_DIRTREE	28	/* directory tree structure */
#define XFS_SCRUB_TYPE_METAPATH	29	/* metadata directory tree paths */
#define XFS_SCRUB_TYPE_RGSUPER	30	/* realtime superblock */

/* Number of scrub subcommands. */
#define XFS_SCRUB_TYPE_NR	30
#define XFS_SCRUB_TYPE_NR	31

/*
 * This special type code only applies to the vectored scrub implementation.
+2 −0
Original line number Diff line number Diff line
@@ -79,9 +79,11 @@ int xchk_setup_metapath(struct xfs_scrub *sc);
#ifdef CONFIG_XFS_RT
int xchk_setup_rtbitmap(struct xfs_scrub *sc);
int xchk_setup_rtsummary(struct xfs_scrub *sc);
int xchk_setup_rgsuperblock(struct xfs_scrub *sc);
#else
# define xchk_setup_rtbitmap		xchk_setup_nothing
# define xchk_setup_rtsummary		xchk_setup_nothing
# define xchk_setup_rgsuperblock	xchk_setup_nothing
#endif
#ifdef CONFIG_XFS_QUOTA
int xchk_ino_dqattach(struct xfs_scrub *sc);
+1 −0
Original line number Diff line number Diff line
@@ -111,6 +111,7 @@ static const struct xchk_health_map type_to_health_flag[XFS_SCRUB_TYPE_NR] = {
	[XFS_SCRUB_TYPE_NLINKS]		= { XHG_FS,  XFS_SICK_FS_NLINKS },
	[XFS_SCRUB_TYPE_DIRTREE]	= { XHG_INO, XFS_SICK_INO_DIRTREE },
	[XFS_SCRUB_TYPE_METAPATH]	= { XHG_FS,  XFS_SICK_FS_METAPATH },
	[XFS_SCRUB_TYPE_RGSUPER]	= { XHG_RTGROUP, XFS_SICK_RG_SUPER },
};

/* Return the health status mask for this scrub type. */

fs/xfs/scrub/rgsuper.c

0 → 100644
+68 −0
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * Copyright (c) 2022-2024 Oracle.  All Rights Reserved.
 * Author: Darrick J. Wong <djwong@kernel.org>
 */
#include "xfs.h"
#include "xfs_fs.h"
#include "xfs_shared.h"
#include "xfs_format.h"
#include "xfs_trans_resv.h"
#include "xfs_mount.h"
#include "xfs_rtgroup.h"
#include "scrub/scrub.h"
#include "scrub/common.h"

/* Set us up with a transaction and an empty context. */
int
xchk_setup_rgsuperblock(
	struct xfs_scrub	*sc)
{
	return xchk_trans_alloc(sc, 0);
}

/* Cross-reference with the other rt metadata. */
STATIC void
xchk_rgsuperblock_xref(
	struct xfs_scrub	*sc)
{
	if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)
		return;

	xchk_xref_is_used_rt_space(sc, xfs_rgbno_to_rtb(sc->sr.rtg, 0), 1);
}

int
xchk_rgsuperblock(
	struct xfs_scrub	*sc)
{
	xfs_rgnumber_t		rgno = sc->sm->sm_agno;
	int			error;

	/*
	 * Only rtgroup 0 has a superblock.  We may someday want to use higher
	 * rgno for other functions, similar to what we do with the primary
	 * super scrub function.
	 */
	if (rgno != 0)
		return -ENOENT;

	/*
	 * Grab an active reference to the rtgroup structure.  If we can't get
	 * it, we're racing with something that's tearing down the group, so
	 * signal that the group no longer exists.  Take the rtbitmap in shared
	 * mode so that the group can't change while we're doing things.
	 */
	error = xchk_rtgroup_init_existing(sc, rgno, &sc->sr);
	if (!xchk_xref_process_error(sc, 0, 0, &error))
		return error;

	xchk_rtgroup_lock(&sc->sr, XFS_RTGLOCK_BITMAP_SHARED);

	/*
	 * Since we already validated the rt superblock at mount time, we don't
	 * need to check its contents again.  All we need is to cross-reference.
	 */
	xchk_rgsuperblock_xref(sc);
	return 0;
}
Loading