fs/xfs/scrub/newbt.c
Source file repositories/reference/linux-study-clean/fs/xfs/scrub/newbt.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/scrub/newbt.c- Extension
.c- Size
- 15391 bytes
- Lines
- 612
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- 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_btree_staging.hxfs_log_format.hxfs_trans.hxfs_sb.hxfs_inode.hxfs_alloc.hxfs_rmap.hxfs_ag.hxfs_defer.hxfs_metafile.hxfs_quota.hscrub/scrub.hscrub/common.hscrub/trace.hscrub/repair.hscrub/newbt.h
Detected Declarations
function Copyrightfunction xrep_newbt_init_agfunction xrep_newbt_init_inodefunction xrep_newbt_init_metadir_inodefunction reservationsfunction xrep_newbt_add_blocksfunction xrep_newbt_add_extentfunction xrep_newbt_validate_ag_alloc_hintfunction xrep_newbt_alloc_ag_blocksfunction xrep_newbt_validate_file_alloc_hintfunction xrep_newbt_alloc_file_blocksfunction xrep_newbt_alloc_blocksfunction xrep_newbt_free_extentfunction xrep_newbt_freefunction list_for_each_entry_safefunction xrep_newbt_commitfunction xrep_newbt_cancelfunction xrep_newbt_claim_blockfunction xrep_newbt_unused_blocks
Annotated Snippet
if (agno != pag_agno(sc->sa.pag)) {
ASSERT(agno == pag_agno(sc->sa.pag));
return -EFSCORRUPTED;
}
trace_xrep_newbt_alloc_ag_blocks(sc->sa.pag,
XFS_FSB_TO_AGBNO(mp, args.fsbno), args.len,
xnr->oinfo.oi_owner);
error = xrep_newbt_add_blocks(xnr, sc->sa.pag, &args);
if (error)
return error;
nr_blocks -= args.len;
xnr->alloc_hint = args.fsbno + args.len;
error = xrep_defer_finish(sc);
if (error)
return error;
}
return 0;
}
/* Don't let our allocation hint take us beyond EOFS */
static inline void
xrep_newbt_validate_file_alloc_hint(
struct xrep_newbt *xnr)
{
struct xfs_scrub *sc = xnr->sc;
if (xfs_verify_fsbno(sc->mp, xnr->alloc_hint))
return;
xnr->alloc_hint = XFS_AGB_TO_FSB(sc->mp, 0, XFS_AGFL_BLOCK(sc->mp) + 1);
}
/* Allocate disk space for our new file-based btree. */
STATIC int
xrep_newbt_alloc_file_blocks(
struct xrep_newbt *xnr,
uint64_t nr_blocks)
{
struct xfs_scrub *sc = xnr->sc;
struct xfs_mount *mp = sc->mp;
int error = 0;
ASSERT(xnr->resv != XFS_AG_RESV_METAFILE);
while (nr_blocks > 0) {
struct xfs_alloc_arg args = {
.tp = sc->tp,
.mp = mp,
.oinfo = xnr->oinfo,
.minlen = 1,
.maxlen = nr_blocks,
.prod = 1,
.resv = xnr->resv,
};
struct xfs_perag *pag;
xfs_agnumber_t agno;
xrep_newbt_validate_file_alloc_hint(xnr);
if (xnr->alloc_vextent)
error = xnr->alloc_vextent(sc, &args, xnr->alloc_hint);
else
error = xfs_alloc_vextent_start_ag(&args,
xnr->alloc_hint);
if (error)
return error;
if (args.fsbno == NULLFSBLOCK)
return -ENOSPC;
agno = XFS_FSB_TO_AGNO(mp, args.fsbno);
pag = xfs_perag_get(mp, agno);
if (!pag) {
ASSERT(0);
return -EFSCORRUPTED;
}
trace_xrep_newbt_alloc_file_blocks(pag,
XFS_FSB_TO_AGBNO(mp, args.fsbno), args.len,
xnr->oinfo.oi_owner);
error = xrep_newbt_add_blocks(xnr, pag, &args);
xfs_perag_put(pag);
if (error)
return error;
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_btree_staging.h`.
- Detected declarations: `function Copyright`, `function xrep_newbt_init_ag`, `function xrep_newbt_init_inode`, `function xrep_newbt_init_metadir_inode`, `function reservations`, `function xrep_newbt_add_blocks`, `function xrep_newbt_add_extent`, `function xrep_newbt_validate_ag_alloc_hint`, `function xrep_newbt_alloc_ag_blocks`, `function xrep_newbt_validate_file_alloc_hint`.
- 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.