1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (c) 2022-2024 Oracle. All Rights Reserved.
8 #include "xfs_shared.h"
9 #include "xfs_format.h"
10 #include "xfs_trans_resv.h"
11 #include "xfs_mount.h"
12 #include "xfs_rtgroup.h"
13 #include "xfs_log_format.h"
14 #include "xfs_trans.h"
16 #include "scrub/scrub.h"
17 #include "scrub/common.h"
18 #include "scrub/repair.h"
20 /* Set us up with a transaction and an empty context. */
22 xchk_setup_rgsuperblock(
25 return xchk_trans_alloc(sc, 0);
28 /* Cross-reference with the other rt metadata. */
30 xchk_rgsuperblock_xref(
33 if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)
36 xchk_xref_is_used_rt_space(sc, xfs_rgbno_to_rtb(sc->sr.rtg, 0), 1);
43 xfs_rgnumber_t rgno = sc->sm->sm_agno;
47 * Only rtgroup 0 has a superblock. We may someday want to use higher
48 * rgno for other functions, similar to what we do with the primary
49 * super scrub function.
55 * Grab an active reference to the rtgroup structure. If we can't get
56 * it, we're racing with something that's tearing down the group, so
57 * signal that the group no longer exists. Take the rtbitmap in shared
58 * mode so that the group can't change while we're doing things.
60 error = xchk_rtgroup_init_existing(sc, rgno, &sc->sr);
61 if (!xchk_xref_process_error(sc, 0, 0, &error))
64 xchk_rtgroup_lock(&sc->sr, XFS_RTGLOCK_BITMAP_SHARED);
67 * Since we already validated the rt superblock at mount time, we don't
68 * need to check its contents again. All we need is to cross-reference.
70 xchk_rgsuperblock_xref(sc);
74 #ifdef CONFIG_XFS_ONLINE_REPAIR
79 ASSERT(rtg_rgno(sc->sr.rtg) == 0);
84 #endif /* CONFIG_XFS_ONLINE_REPAIR */