fs/xfs/libxfs/xfs_defer.c
Source file repositories/reference/linux-study-clean/fs/xfs/libxfs/xfs_defer.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/libxfs/xfs_defer.c- Extension
.c- Size
- 34977 bytes
- Lines
- 1246
- 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_log_format.hxfs_trans_resv.hxfs_mount.hxfs_defer.hxfs_trans.hxfs_trans_priv.hxfs_buf_item.hxfs_inode.hxfs_inode_item.hxfs_trace.hxfs_icache.hxfs_log.hxfs_log_priv.hxfs_rmap.hxfs_refcount.hxfs_bmap.hxfs_alloc.hxfs_buf.hxfs_da_format.hxfs_da_btree.hxfs_attr.hxfs_exchmaps.h
Detected Declarations
function extentfunction xfs_defer_barrier_abort_intentfunction xfs_defer_barrier_finish_itemfunction xfs_defer_barrier_cancel_itemfunction xfs_defer_create_donefunction xfs_defer_create_intentfunction xfs_defer_create_intentsfunction list_for_each_entryfunction xfs_defer_pending_abortfunction xfs_defer_pending_cancel_workfunction xfs_defer_pending_abort_listfunction xfs_defer_trans_abortfunction releasefunction list_for_each_entryfunction xfs_defer_restore_resourcesfunction xfs_defer_trans_rollfunction xfs_defer_cancel_listfunction xfs_defer_relog_intentfunction xfs_defer_relogfunction list_for_each_entryfunction xfs_defer_finish_onefunction xfs_defer_isolate_pausedfunction list_for_each_entry_safefunction rollfunction xfs_defer_finishfunction xfs_defer_cancelfunction xfs_defer_find_lastfunction xfs_defer_can_appendfunction xfs_defer_allocfunction xfs_defer_addfunction xfs_defer_add_barrierfunction xfs_defer_start_recoveryfunction xfs_defer_cancel_recoveryfunction xfs_defer_finish_recoveryfunction xfs_defer_movefunction xfs_defer_ops_capturefunction xfs_defer_ops_capture_abortfunction xfs_defer_ops_capture_and_commitfunction xfs_defer_ops_continuefunction xfs_defer_resources_relefunction xfs_defer_init_cachefunction xfs_defer_destroy_cachefunction xfs_defer_init_item_cachesfunction xfs_defer_destroy_item_cachesfunction xfs_defer_item_pausefunction xfs_defer_item_unpause
Annotated Snippet
switch (lip->li_type) {
case XFS_LI_BUF:
bli = container_of(lip, struct xfs_buf_log_item,
bli_item);
if (bli->bli_flags & XFS_BLI_HOLD) {
if (dres->dr_bufs >= XFS_DEFER_OPS_NR_BUFS) {
ASSERT(0);
return -EFSCORRUPTED;
}
if (bli->bli_flags & XFS_BLI_ORDERED)
dres->dr_ordered |=
(1U << dres->dr_bufs);
else
xfs_trans_dirty_buf(tp, bli->bli_buf);
dres->dr_bp[dres->dr_bufs++] = bli->bli_buf;
}
break;
case XFS_LI_INODE:
ili = container_of(lip, struct xfs_inode_log_item,
ili_item);
if (ili->ili_lock_flags == 0) {
if (dres->dr_inos >= XFS_DEFER_OPS_NR_INODES) {
ASSERT(0);
return -EFSCORRUPTED;
}
xfs_trans_log_inode(tp, ili->ili_inode,
XFS_ILOG_CORE);
dres->dr_ip[dres->dr_inos++] = ili->ili_inode;
}
break;
default:
break;
}
}
return 0;
}
/* Attach the held resources to the transaction. */
static void
xfs_defer_restore_resources(
struct xfs_trans *tp,
struct xfs_defer_resources *dres)
{
unsigned short i;
/* Rejoin the joined inodes. */
for (i = 0; i < dres->dr_inos; i++)
xfs_trans_ijoin(tp, dres->dr_ip[i], 0);
/* Rejoin the buffers and dirty them so the log moves forward. */
for (i = 0; i < dres->dr_bufs; i++) {
xfs_trans_bjoin(tp, dres->dr_bp[i]);
if (dres->dr_ordered & (1U << i))
xfs_trans_ordered_buf(tp, dres->dr_bp[i]);
xfs_trans_bhold(tp, dres->dr_bp[i]);
}
}
/* Roll a transaction so we can do some deferred op processing. */
STATIC int
xfs_defer_trans_roll(
struct xfs_trans **tpp)
{
struct xfs_defer_resources dres = { };
int error;
error = xfs_defer_save_resources(&dres, *tpp);
if (error)
return error;
trace_xfs_defer_trans_roll(*tpp, _RET_IP_);
/*
* Roll the transaction. Rolling always given a new transaction (even
* if committing the old one fails!) to hand back to the caller, so we
* join the held resources to the new transaction so that we always
* return with the held resources joined to @tpp, no matter what
* happened.
*/
error = xfs_trans_roll(tpp);
xfs_defer_restore_resources(*tpp, &dres);
if (error)
trace_xfs_defer_trans_roll_error(*tpp, error);
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_mount.h`, `xfs_defer.h`.
- Detected declarations: `function extent`, `function xfs_defer_barrier_abort_intent`, `function xfs_defer_barrier_finish_item`, `function xfs_defer_barrier_cancel_item`, `function xfs_defer_create_done`, `function xfs_defer_create_intent`, `function xfs_defer_create_intents`, `function list_for_each_entry`, `function xfs_defer_pending_abort`, `function xfs_defer_pending_cancel_work`.
- 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.