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"
17 #include "scrub/scrub.h"
18 #include "scrub/common.h"
19 #include "scrub/repair.h"
21 /* Set us up with a transaction and an empty context. */
23 xchk_setup_rgsuperblock(
26 return xchk_trans_alloc(sc, 0);
29 /* Cross-reference with the other rt metadata. */
31 xchk_rgsuperblock_xref(
34 if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)
37 xchk_xref_is_used_rt_space(sc, xfs_rgbno_to_rtb(sc->sr.rtg, 0), 1);
38 xchk_xref_is_only_rt_owned_by(sc, 0, 1, &XFS_RMAP_OINFO_FS);
45 xfs_rgnumber_t rgno = sc->sm->sm_agno;
49 * Only rtgroup 0 has a superblock. We may someday want to use higher
50 * rgno for other functions, similar to what we do with the primary
51 * super scrub function.
57 * Grab an active reference to the rtgroup structure. If we can't get
58 * it, we're racing with something that's tearing down the group, so
59 * signal that the group no longer exists. Take the rtbitmap in shared
60 * mode so that the group can't change while we're doing things.
62 error = xchk_rtgroup_init_existing(sc, rgno, &sc->sr);
63 if (!xchk_xref_process_error(sc, 0, 0, &error))
66 error = xchk_rtgroup_lock(sc, &sc->sr, XFS_RTGLOCK_BITMAP_SHARED);
71 * Since we already validated the rt superblock at mount time, we don't
72 * need to check its contents again. All we need is to cross-reference.
74 xchk_rgsuperblock_xref(sc);
78 #ifdef CONFIG_XFS_ONLINE_REPAIR
83 ASSERT(rtg_rgno(sc->sr.rtg) == 0);
88 #endif /* CONFIG_XFS_ONLINE_REPAIR */