fs/xfs/xfs_bmap_util.c
Source file repositories/reference/linux-study-clean/fs/xfs/xfs_bmap_util.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/xfs_bmap_util.c- Extension
.c- Size
- 46362 bytes
- Lines
- 1747
- 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_log_format.hxfs_trans_resv.hxfs_bit.hxfs_mount.hxfs_defer.hxfs_inode.hxfs_btree.hxfs_trans.hxfs_alloc.hxfs_bmap.hxfs_bmap_util.hxfs_bmap_btree.hxfs_rtalloc.hxfs_error.hxfs_quota.hxfs_trans_space.hxfs_trace.hxfs_icache.hxfs_iomap.hxfs_reflink.hxfs_rtbitmap.hxfs_rtgroup.hxfs_zone_alloc.h
Detected Declarations
function Copyrightfunction xfs_zero_extentfunction xfs_bmap_count_leavesfunction for_each_xfs_iextfunction xfs_bmap_count_blocksfunction xfs_getbmap_report_onefunction xfs_getbmap_report_holefunction xfs_getbmap_fullfunction xfs_getbmap_next_recfunction xfs_bmap_punch_delalloc_rangefunction xfs_can_free_eofblocksfunction xfs_free_eofblocksfunction xfs_alloc_file_spacefunction xfs_unmap_extentfunction xfs_flush_unmap_rangefunction xfs_free_file_spacefunction xfs_prepare_shiftfunction xfs_collapse_file_spacefunction xfs_insert_file_spacefunction xfs_swap_extent_flushfunction xfs_swap_extent_rmapfunction xfs_swap_extent_forksfunction formatfunction xfs_swap_change_ownerfunction xfs_swap_extentsfunction This
Annotated Snippet
if (!isnullstartblock(got.br_startblock)) {
*count += got.br_blockcount;
numrecs++;
}
}
return numrecs;
}
/*
* Count fsblocks of the given fork. Delayed allocation extents are
* not counted towards the totals.
*/
int
xfs_bmap_count_blocks(
struct xfs_trans *tp,
struct xfs_inode *ip,
int whichfork,
xfs_extnum_t *nextents,
xfs_filblks_t *count)
{
struct xfs_mount *mp = ip->i_mount;
struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
struct xfs_btree_cur *cur;
xfs_filblks_t btblocks = 0;
int error;
*nextents = 0;
*count = 0;
if (!ifp)
return 0;
switch (ifp->if_format) {
case XFS_DINODE_FMT_BTREE:
error = xfs_iread_extents(tp, ip, whichfork);
if (error)
return error;
cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork);
error = xfs_btree_count_blocks(cur, &btblocks);
xfs_btree_del_cursor(cur, error);
if (error)
return error;
/*
* xfs_btree_count_blocks includes the root block contained in
* the inode fork in @btblocks, so subtract one because we're
* only interested in allocated disk blocks.
*/
*count += btblocks - 1;
fallthrough;
case XFS_DINODE_FMT_EXTENTS:
*nextents = xfs_bmap_count_leaves(ifp, count);
break;
}
return 0;
}
static int
xfs_getbmap_report_one(
struct xfs_inode *ip,
struct getbmapx *bmv,
struct kgetbmap *out,
int64_t bmv_end,
struct xfs_bmbt_irec *got)
{
struct kgetbmap *p = out + bmv->bmv_entries;
bool shared = false;
int error;
error = xfs_reflink_trim_around_shared(ip, got, &shared);
if (error)
return error;
if (isnullstartblock(got->br_startblock) ||
got->br_startblock == DELAYSTARTBLOCK) {
/*
* Take the flush completion as being a point-in-time snapshot
* where there are no delalloc extents, and if any new ones
* have been created racily, just skip them as being 'after'
* the flush and so don't get reported.
*/
if (!(bmv->bmv_iflags & BMV_IF_DELALLOC))
return 0;
p->bmv_oflags |= BMV_OF_DELALLOC;
p->bmv_block = -2;
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 Copyright`, `function xfs_zero_extent`, `function xfs_bmap_count_leaves`, `function for_each_xfs_iext`, `function xfs_bmap_count_blocks`, `function xfs_getbmap_report_one`, `function xfs_getbmap_report_hole`, `function xfs_getbmap_full`, `function xfs_getbmap_next_rec`, `function xfs_bmap_punch_delalloc_range`.
- 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.