fs/xfs/xfs_bmap_item.c
Source file repositories/reference/linux-study-clean/fs/xfs/xfs_bmap_item.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/xfs_bmap_item.c- Extension
.c- Size
- 19493 bytes
- Lines
- 721
- 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_format.hxfs_log_format.hxfs_trans_resv.hxfs_bit.hxfs_shared.hxfs_mount.hxfs_defer.hxfs_inode.hxfs_trans.hxfs_trans_priv.hxfs_bmap_item.hxfs_log.hxfs_bmap.hxfs_icache.hxfs_bmap_btree.hxfs_trans_space.hxfs_error.hxfs_log_priv.hxfs_log_recover.hxfs_ag.hxfs_trace.h
Detected Declarations
function xfs_bui_item_freefunction xfs_bui_releasefunction xfs_bui_item_sizefunction xfs_bui_log_spacefunction xfs_bui_item_formatfunction xfs_bui_item_unpinfunction xfs_bui_item_releasefunction xfs_bui_initfunction xfs_bud_item_sizefunction xfs_bud_log_spacefunction xfs_bud_item_formatfunction xfs_bud_item_releasefunction xfs_bud_item_intentfunction xfs_bmap_update_diff_itemsfunction xfs_bmap_update_log_itemfunction xfs_bmap_update_create_intentfunction xfs_bmap_update_create_donefunction xfs_bmap_update_get_groupfunction xfs_bmap_defer_addfunction xfs_bmap_update_cancel_itemfunction xfs_bmap_update_finish_itemfunction xfs_bmap_update_abort_intentfunction xfs_bui_validatefunction xfs_bui_recover_workfunction xfs_bmap_recover_workfunction xfs_bmap_relog_intentfunction xfs_bui_item_matchfunction xfs_bui_copy_formatfunction xlog_recover_bui_commit_pass2function xlog_recover_bud_commit_pass2
Annotated Snippet
xfs_ifork_is_realtime(ip, work->bi_whichfork)) {
error = -EFSCORRUPTED;
goto err_cancel;
}
if (work->bi_type == XFS_BMAP_MAP)
iext_delta = XFS_IEXT_ADD_NOSPLIT_CNT;
else
iext_delta = XFS_IEXT_PUNCH_HOLE_CNT;
error = xfs_iext_count_extend(tp, ip, work->bi_whichfork, iext_delta);
if (error)
goto err_cancel;
error = xlog_recover_finish_intent(tp, dfp);
if (error == -EFSCORRUPTED)
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
&buip->bui_format, sizeof(buip->bui_format));
if (error)
goto err_cancel;
/*
* Commit transaction, which frees the transaction and saves the inode
* for later replay activities.
*/
error = xfs_defer_ops_capture_and_commit(tp, capture_list);
if (error)
goto err_unlock;
xfs_iunlock(ip, XFS_ILOCK_EXCL);
xfs_irele(ip);
return 0;
err_cancel:
xfs_trans_cancel(tp);
err_unlock:
xfs_iunlock(ip, XFS_ILOCK_EXCL);
err_rele:
xfs_irele(ip);
return error;
}
/* Relog an intent item to push the log tail forward. */
static struct xfs_log_item *
xfs_bmap_relog_intent(
struct xfs_trans *tp,
struct xfs_log_item *intent,
struct xfs_log_item *done_item)
{
struct xfs_bui_log_item *buip;
struct xfs_map_extent *map;
unsigned int count;
count = BUI_ITEM(intent)->bui_format.bui_nextents;
map = BUI_ITEM(intent)->bui_format.bui_extents;
buip = xfs_bui_init(tp->t_mountp);
memcpy(buip->bui_format.bui_extents, map, count * sizeof(*map));
atomic_set(&buip->bui_next_extent, count);
return &buip->bui_item;
}
const struct xfs_defer_op_type xfs_bmap_update_defer_type = {
.name = "bmap",
.max_items = XFS_BUI_MAX_FAST_EXTENTS,
.create_intent = xfs_bmap_update_create_intent,
.abort_intent = xfs_bmap_update_abort_intent,
.create_done = xfs_bmap_update_create_done,
.finish_item = xfs_bmap_update_finish_item,
.cancel_item = xfs_bmap_update_cancel_item,
.recover_work = xfs_bmap_recover_work,
.relog_intent = xfs_bmap_relog_intent,
};
STATIC bool
xfs_bui_item_match(
struct xfs_log_item *lip,
uint64_t intent_id)
{
return BUI_ITEM(lip)->bui_format.bui_id == intent_id;
}
static const struct xfs_item_ops xfs_bui_item_ops = {
.flags = XFS_ITEM_INTENT,
.iop_size = xfs_bui_item_size,
.iop_format = xfs_bui_item_format,
.iop_unpin = xfs_bui_item_unpin,
.iop_release = xfs_bui_item_release,
.iop_match = xfs_bui_item_match,
Annotation
- Immediate include surface: `xfs_platform.h`, `xfs_fs.h`, `xfs_format.h`, `xfs_log_format.h`, `xfs_trans_resv.h`, `xfs_bit.h`, `xfs_shared.h`, `xfs_mount.h`.
- Detected declarations: `function xfs_bui_item_free`, `function xfs_bui_release`, `function xfs_bui_item_size`, `function xfs_bui_log_space`, `function xfs_bui_item_format`, `function xfs_bui_item_unpin`, `function xfs_bui_item_release`, `function xfs_bui_init`, `function xfs_bud_item_size`, `function xfs_bud_log_space`.
- 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.