fs/xfs/scrub/rtsummary_repair.c
Source file repositories/reference/linux-study-clean/fs/xfs/scrub/rtsummary_repair.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/scrub/rtsummary_repair.c- Extension
.c- Size
- 5123 bytes
- Lines
- 187
- 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_btree.hxfs_log_format.hxfs_trans.hxfs_rtalloc.hxfs_inode.hxfs_bit.hxfs_bmap.hxfs_bmap_btree.hxfs_exchmaps.hxfs_rtbitmap.hscrub/scrub.hscrub/common.hscrub/trace.hscrub/repair.hscrub/tempfile.hscrub/tempexch.hscrub/reap.hscrub/xfile.hscrub/rtsummary.h
Detected Declarations
function Copyrightfunction xrep_rtsummary_prep_buffunction xrep_rtsummary
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Copyright (c) 2020-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_btree.h"
#include "xfs_log_format.h"
#include "xfs_trans.h"
#include "xfs_rtalloc.h"
#include "xfs_inode.h"
#include "xfs_bit.h"
#include "xfs_bmap.h"
#include "xfs_bmap_btree.h"
#include "xfs_exchmaps.h"
#include "xfs_rtbitmap.h"
#include "scrub/scrub.h"
#include "scrub/common.h"
#include "scrub/trace.h"
#include "scrub/repair.h"
#include "scrub/tempfile.h"
#include "scrub/tempexch.h"
#include "scrub/reap.h"
#include "scrub/xfile.h"
#include "scrub/rtsummary.h"
/* Set us up to repair the rtsummary file. */
int
xrep_setup_rtsummary(
struct xfs_scrub *sc,
struct xchk_rtsummary *rts)
{
struct xfs_mount *mp = sc->mp;
unsigned long long blocks;
int error;
error = xrep_tempfile_create(sc, S_IFREG);
if (error)
return error;
/*
* If we're doing a repair, we reserve enough blocks to write out a
* completely new summary file, plus twice as many blocks as we would
* need if we can only allocate one block per data fork mapping. This
* should cover the preallocation of the temporary file and exchanging
* the extent mappings.
*
* We cannot use xfs_exchmaps_estimate because we have not yet
* constructed the replacement rtsummary and therefore do not know how
* many extents it will use. By the time we do, we will have a dirty
* transaction (which we cannot drop because we cannot drop the
* rtsummary ILOCK) and cannot ask for more reservation.
*/
blocks = mp->m_rsumblocks;
blocks += xfs_bmbt_calc_size(mp, blocks) * 2;
if (blocks > UINT_MAX)
return -EOPNOTSUPP;
rts->resblks += blocks;
return 0;
}
static int
xrep_rtsummary_prep_buf(
struct xfs_scrub *sc,
struct xfs_buf *bp,
void *data)
{
struct xchk_rtsummary *rts = data;
struct xfs_mount *mp = sc->mp;
union xfs_suminfo_raw *ondisk;
int error;
rts->args.mp = mp;
rts->args.tp = sc->tp;
rts->args.rtg = sc->sr.rtg;
rts->args.sumbp = bp;
ondisk = xfs_rsumblock_infoptr(&rts->args, 0);
rts->args.sumbp = NULL;
error = xfsum_copyout(sc, rts->prep_wordoff, ondisk, mp->m_blockwsize);
if (error)
return error;
if (xfs_has_rtgroups(sc->mp)) {
Annotation
- Immediate include surface: `xfs_platform.h`, `xfs_fs.h`, `xfs_shared.h`, `xfs_format.h`, `xfs_trans_resv.h`, `xfs_mount.h`, `xfs_btree.h`, `xfs_log_format.h`.
- Detected declarations: `function Copyright`, `function xrep_rtsummary_prep_buf`, `function xrep_rtsummary`.
- 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.