fs/xfs/scrub/rgsuper.c
Source file repositories/reference/linux-study-clean/fs/xfs/scrub/rgsuper.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/scrub/rgsuper.c- Extension
.c- Size
- 2161 bytes
- Lines
- 89
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
xfs_platform.hxfs_fs.hxfs_shared.hxfs_format.hxfs_trans_resv.hxfs_mount.hxfs_rtgroup.hxfs_log_format.hxfs_trans.hxfs_sb.hxfs_rmap.hscrub/scrub.hscrub/common.hscrub/repair.h
Detected Declarations
function Copyrightfunction xchk_rgsuperblock_xreffunction xchk_rgsuperblockfunction xrep_rgsuperblock
Annotated Snippet
// 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_platform.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 "xfs_log_format.h"
#include "xfs_trans.h"
#include "xfs_sb.h"
#include "xfs_rmap.h"
#include "scrub/scrub.h"
#include "scrub/common.h"
#include "scrub/repair.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);
xchk_xref_is_only_rt_owned_by(sc, 0, 1, &XFS_RMAP_OINFO_FS);
}
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;
error = xchk_rtgroup_lock(sc, &sc->sr, XFS_RTGLOCK_BITMAP_SHARED);
if (error)
return error;
/*
* 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;
}
#ifdef CONFIG_XFS_ONLINE_REPAIR
int
xrep_rgsuperblock(
struct xfs_scrub *sc)
{
ASSERT(rtg_rgno(sc->sr.rtg) == 0);
xfs_log_sb(sc->tp);
return 0;
}
#endif /* CONFIG_XFS_ONLINE_REPAIR */
Annotation
- Immediate include surface: `xfs_platform.h`, `xfs_fs.h`, `xfs_shared.h`, `xfs_format.h`, `xfs_trans_resv.h`, `xfs_mount.h`, `xfs_rtgroup.h`, `xfs_log_format.h`.
- Detected declarations: `function Copyright`, `function xchk_rgsuperblock_xref`, `function xchk_rgsuperblock`, `function xrep_rgsuperblock`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.