fs/xfs/xfs_trans_ail.c
Source file repositories/reference/linux-study-clean/fs/xfs/xfs_trans_ail.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/xfs_trans_ail.c- Extension
.c- Size
- 26824 bytes
- Lines
- 981
- 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_mount.hxfs_trans.hxfs_trans_priv.hxfs_trace.hxfs_errortag.hxfs_error.hxfs_log.hxfs_log_priv.h
Detected Declarations
function Copyrightfunction xfs_ail_maxfunction xfs_ail_nextfunction __xfs_ail_min_lsnfunction xfs_ail_min_lsnfunction xfs_trans_ail_cursor_initfunction invalidatedfunction xfs_trans_ail_cursor_donefunction xfs_trans_ail_cursor_clearfunction list_for_each_entryfunction xfs_trans_ail_cursor_firstfunction list_for_each_entryfunction __xfs_trans_ail_cursor_lastfunction list_for_each_entry_reversefunction xfs_trans_ail_cursor_lastfunction xfs_ail_splicefunction xfs_ail_deletefunction xfsaild_resubmit_itemfunction xfsaild_push_itemfunction xfs_ail_calc_push_targetfunction xfsaild_process_logitemfunction xfsaild_pushfunction xfs_ail_min_lsnfunction xfsaildfunction kthread_should_stopfunction xfs_ail_push_all_syncfunction __xfs_ail_assign_tail_lsnfunction updatefunction xfs_ail_update_finishfunction xfs_ail_update_finishfunction xfs_trans_ail_insertfunction xfs_ail_update_finishfunction xfs_trans_ail_deletefunction xfs_trans_ail_initfunction xfs_trans_ail_destroy
Annotated Snippet
xfs_ail_min_lsn(ailp))) {
ailp->ail_log_flush = 0;
XFS_STATS_INC(mp, xs_push_ail_flush);
xlog_cil_flush(ailp->ail_log);
}
spin_lock(&ailp->ail_lock);
WRITE_ONCE(ailp->ail_target, xfs_ail_calc_push_target(ailp));
if (ailp->ail_target == NULLCOMMITLSN)
goto out_done;
/* we're done if the AIL is empty or our push has reached the end */
lip = xfs_trans_ail_cursor_first(ailp, &cur, ailp->ail_last_pushed_lsn);
if (!lip)
goto out_done_cursor;
XFS_STATS_INC(mp, xs_push_ail);
ASSERT(ailp->ail_target != NULLCOMMITLSN);
lsn = lip->li_lsn;
while ((XFS_LSN_CMP(lip->li_lsn, ailp->ail_target) <= 0)) {
if (test_bit(XFS_LI_FLUSHING, &lip->li_flags))
goto next_item;
xfsaild_process_logitem(ailp, lip, &stuck, &flushing);
count++;
/*
* Are there too many items we can't do anything with?
*
* If we are skipping too many items because we can't flush
* them or they are already being flushed, we back off and
* given them time to complete whatever operation is being
* done. i.e. remove pressure from the AIL while we can't make
* progress so traversals don't slow down further inserts and
* removals to/from the AIL.
*
* The value of 100 is an arbitrary magic number based on
* observation.
*/
if (stuck > 100)
break;
next_item:
lip = xfs_trans_ail_cursor_next(ailp, &cur);
if (lip == NULL)
break;
if (lip->li_lsn != lsn && count > 1000)
break;
lsn = lip->li_lsn;
}
out_done_cursor:
xfs_trans_ail_cursor_done(&cur);
out_done:
spin_unlock(&ailp->ail_lock);
if (xfs_buf_delwri_submit_nowait(&ailp->ail_buf_list))
ailp->ail_log_flush++;
if (!count || XFS_LSN_CMP(lsn, ailp->ail_target) >= 0) {
/*
* We reached the target or the AIL is empty, so wait a bit
* longer for I/O to complete and remove pushed items from the
* AIL before we start the next scan from the start of the AIL.
*/
tout = 50;
ailp->ail_last_pushed_lsn = 0;
} else if (((stuck + flushing) * 100) / count > 90) {
/*
* Either there is a lot of contention on the AIL or we are
* stuck due to operations in progress. "Stuck" in this case
* is defined as >90% of the items we tried to push were stuck.
*
* Backoff a bit more to allow some I/O to complete before
* restarting from the start of the AIL. This prevents us from
* spinning on the same items, and if they are pinned will all
* the restart to issue a log force to unpin the stuck items.
*/
tout = 20;
ailp->ail_last_pushed_lsn = 0;
} else {
/*
* Assume we have more work to do in a short while.
*/
tout = 0;
}
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_trans.h`.
- Detected declarations: `function Copyright`, `function xfs_ail_max`, `function xfs_ail_next`, `function __xfs_ail_min_lsn`, `function xfs_ail_min_lsn`, `function xfs_trans_ail_cursor_init`, `function invalidated`, `function xfs_trans_ail_cursor_done`, `function xfs_trans_ail_cursor_clear`, `function list_for_each_entry`.
- 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.