Linux Audio

Check our new training course

Loading...
Note: File does not exist in v6.9.4.
 1// SPDX-License-Identifier: GPL-2.0-or-later
 2/*
 3 * Copyright (c) 2022-2024 Oracle.  All Rights Reserved.
 4 * Author: Darrick J. Wong <djwong@kernel.org>
 5 */
 6#include "xfs.h"
 7#include "xfs_fs.h"
 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"
15#include "xfs_sb.h"
16#include "scrub/scrub.h"
17#include "scrub/common.h"
18#include "scrub/repair.h"
19
20/* Set us up with a transaction and an empty context. */
21int
22xchk_setup_rgsuperblock(
23	struct xfs_scrub	*sc)
24{
25	return xchk_trans_alloc(sc, 0);
26}
27
28/* Cross-reference with the other rt metadata. */
29STATIC void
30xchk_rgsuperblock_xref(
31	struct xfs_scrub	*sc)
32{
33	if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)
34		return;
35
36	xchk_xref_is_used_rt_space(sc, xfs_rgbno_to_rtb(sc->sr.rtg, 0), 1);
37}
38
39int
40xchk_rgsuperblock(
41	struct xfs_scrub	*sc)
42{
43	xfs_rgnumber_t		rgno = sc->sm->sm_agno;
44	int			error;
45
46	/*
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.
50	 */
51	if (rgno != 0)
52		return -ENOENT;
53
54	/*
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.
59	 */
60	error = xchk_rtgroup_init_existing(sc, rgno, &sc->sr);
61	if (!xchk_xref_process_error(sc, 0, 0, &error))
62		return error;
63
64	xchk_rtgroup_lock(&sc->sr, XFS_RTGLOCK_BITMAP_SHARED);
65
66	/*
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.
69	 */
70	xchk_rgsuperblock_xref(sc);
71	return 0;
72}
73
74#ifdef CONFIG_XFS_ONLINE_REPAIR
75int
76xrep_rgsuperblock(
77	struct xfs_scrub	*sc)
78{
79	ASSERT(rtg_rgno(sc->sr.rtg) == 0);
80
81	xfs_log_sb(sc->tp);
82	return 0;
83}
84#endif /* CONFIG_XFS_ONLINE_REPAIR */