fs/xfs/libxfs/xfs_metafile.c
Source file repositories/reference/linux-study-clean/fs/xfs/libxfs/xfs_metafile.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/libxfs/xfs_metafile.c- Extension
.c- Size
- 8392 bytes
- Lines
- 328
- 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.
- 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_sb.hxfs_mount.hxfs_defer.hxfs_trans.hxfs_metafile.hxfs_trace.hxfs_inode.hxfs_quota.hxfs_errortag.hxfs_error.hxfs_alloc.hxfs_rtgroup.hxfs_rtrmap_btree.hxfs_rtrefcount_btree.h
Detected Declarations
function xfs_metafile_type_strfunction xfs_metafile_set_iflagfunction xfs_metafile_clear_iflagfunction xfs_metafile_resv_can_coverfunction numberfunction xfs_metafile_resv_alloc_spacefunction xfs_metafile_resv_free_spacefunction __xfs_metafile_resv_freefunction xfs_metafile_resv_freefunction xfs_metafile_resv_init
Annotated Snippet
if (xfs_has_rtrmapbt(mp)) {
used += rtg_rmap(rtg)->i_nblocks;
target += xfs_rtrmapbt_calc_reserves(mp);
}
if (xfs_has_rtreflink(mp)) {
used += rtg_refcount(rtg)->i_nblocks;
target += xfs_rtrefcountbt_calc_reserves(mp);
}
}
if (!target)
goto out_unlock;
/*
* Space taken by the per-AG metadata btrees are accounted on-disk as
* used space. We therefore only hide the space that is reserved but
* not used by the trees.
*/
if (used > target)
target = used;
else if (target > dblocks_avail)
target = dblocks_avail;
hidden_space = target - used;
error = xfs_dec_fdblocks(mp, hidden_space, true);
if (error) {
trace_xfs_metafile_resv_init_error(mp, 0);
goto out_unlock;
}
xfs_mod_sb_delalloc(mp, hidden_space);
mp->m_metafile_resv_target = target;
mp->m_metafile_resv_used = used;
mp->m_metafile_resv_avail = hidden_space;
trace_xfs_metafile_resv_init(mp, target);
out_unlock:
mutex_unlock(&mp->m_metafile_resv_lock);
return error;
}
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_sb.h`.
- Detected declarations: `function xfs_metafile_type_str`, `function xfs_metafile_set_iflag`, `function xfs_metafile_clear_iflag`, `function xfs_metafile_resv_can_cover`, `function number`, `function xfs_metafile_resv_alloc_space`, `function xfs_metafile_resv_free_space`, `function __xfs_metafile_resv_free`, `function xfs_metafile_resv_free`, `function xfs_metafile_resv_init`.
- 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.