fs/xfs/xfs_rtalloc.c
Source file repositories/reference/linux-study-clean/fs/xfs/xfs_rtalloc.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/xfs_rtalloc.c- Extension
.c- Size
- 56813 bytes
- Lines
- 2224
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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_log_format.hxfs_trans_resv.hxfs_bit.hxfs_mount.hxfs_inode.hxfs_alloc.hxfs_bmap.hxfs_bmap_btree.hxfs_bmap_util.hxfs_trans.hxfs_trans_space.hxfs_icache.hxfs_rtalloc.hxfs_sb.hxfs_rtbitmap.hxfs_rtrmap_btree.hxfs_quota.hxfs_log_priv.hxfs_health.hxfs_da_format.hxfs_metafile.hxfs_rtgroup.hxfs_error.hxfs_trace.hxfs_rtrefcount_btree.hxfs_reflink.hxfs_zone_alloc.h
Detected Declarations
function xfs_rtcopy_summaryfunction xfs_rtalloc_align_lenfunction xfs_rtallocate_clamp_lenfunction xfs_rtunmount_rtgfunction xfs_alloc_rsum_cachefunction sizefunction xfs_rtginode_ensurefunction xfs_growfs_rt_alloc_fake_mountfunction xfs_growfs_rt_free_newfunction xfs_growfs_rt_nrblocksfunction xfs_growfs_rt_init_rtsbfunction xfs_growfs_rt_sb_fieldsfunction xfs_growfs_rt_zonedfunction xfs_growfs_rt_bmblockfunction sizefunction xfs_last_rtgroup_extentsfunction numberfunction xfs_growfs_rt_alloc_blocksfunction xfs_growfs_rtgfunction xfs_growfs_check_rtgeomfunction allowedfunction xfs_grow_last_rtgfunction xfs_rt_check_sizefunction xfs_growfs_rtfunction xfs_rtmount_readsbfunction xfs_rtmount_freesbfunction xfs_rtalloc_count_frextentfunction xfs_rtalloc_reinit_frextentsfunction xfs_rtmount_iread_extentsfunction xfs_rtmount_rtgfunction xfs_rtmount_inodesfunction xfs_rtunmount_inodesfunction xfs_rtalloc_align_minmaxfunction xfs_rtalloc_check_busyfunction xfs_rtallocate_adjust_for_busyfunction xfs_rtallocate_rtgfunction xfs_rtallocate_rtgsfunction xfs_rtallocate_alignfunction xfs_bmap_rtalloc
Annotated Snippet
if (low > high) {
*maxlog = -1;
return 0;
}
}
/*
* Loop over logs of extent sizes.
*/
for (log = high; log >= low; log--) {
/*
* Get one summary datum.
*/
error = xfs_rtget_summary(args, log, bbno, &sum);
if (error) {
return error;
}
/*
* If there are any, return success.
*/
if (sum) {
*maxlog = log;
goto out;
}
}
/*
* Found nothing, return failure.
*/
*maxlog = -1;
out:
/* There were no extents at levels > log. */
if (rsum_cache && log + 1 < rsum_cache[bbno])
rsum_cache[bbno] = log + 1;
return 0;
}
/*
* Copy and transform the summary file, given the old and new
* parameters in the mount structures.
*/
STATIC int
xfs_rtcopy_summary(
struct xfs_rtalloc_args *oargs,
struct xfs_rtalloc_args *nargs)
{
xfs_fileoff_t bbno; /* bitmap block number */
int error;
int log; /* summary level number (log length) */
xfs_suminfo_t sum; /* summary data */
for (log = oargs->mp->m_rsumlevels - 1; log >= 0; log--) {
for (bbno = oargs->mp->m_sb.sb_rbmblocks - 1;
(xfs_srtblock_t)bbno >= 0;
bbno--) {
error = xfs_rtget_summary(oargs, log, bbno, &sum);
if (error)
goto out;
if (XFS_IS_CORRUPT(oargs->mp, sum < 0)) {
error = -EFSCORRUPTED;
goto out;
}
if (sum == 0)
continue;
error = xfs_rtmodify_summary(oargs, log, bbno, -sum);
if (error)
goto out;
error = xfs_rtmodify_summary(nargs, log, bbno, sum);
if (error)
goto out;
}
}
error = 0;
out:
xfs_rtbuf_cache_relse(oargs);
return error;
}
/*
* Mark an extent specified by start and len allocated.
* Updates all the summary information as well as the bitmap.
*/
STATIC int
xfs_rtallocate_range(
struct xfs_rtalloc_args *args,
xfs_rtxnum_t start, /* start rtext to allocate */
xfs_rtxlen_t len) /* in/out: summary block number */
{
struct xfs_mount *mp = args->mp;
xfs_rtxnum_t end; /* end of the allocated rtext */
int error;
xfs_rtxnum_t postblock = 0; /* first rtext allocated > end */
Annotation
- Immediate include surface: `xfs_platform.h`, `xfs_fs.h`, `xfs_shared.h`, `xfs_format.h`, `xfs_log_format.h`, `xfs_trans_resv.h`, `xfs_bit.h`, `xfs_mount.h`.
- Detected declarations: `function xfs_rtcopy_summary`, `function xfs_rtalloc_align_len`, `function xfs_rtallocate_clamp_len`, `function xfs_rtunmount_rtg`, `function xfs_alloc_rsum_cache`, `function size`, `function xfs_rtginode_ensure`, `function xfs_growfs_rt_alloc_fake_mount`, `function xfs_growfs_rt_free_new`, `function xfs_growfs_rt_nrblocks`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.