fs/xfs/xfs_log.c
Source file repositories/reference/linux-study-clean/fs/xfs/xfs_log.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/xfs_log.c- Extension
.c- Size
- 100183 bytes
- Lines
- 3478
- 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_errortag.hxfs_error.hxfs_trans.hxfs_trans_priv.hxfs_log.hxfs_log_priv.hxfs_trace.hxfs_sysfs.hxfs_sb.hxfs_health.hxfs_zone_alloc.h
Detected Declarations
struct xlog_write_datafunction xlog_grant_sub_spacefunction xlog_grant_add_spacefunction xlog_grant_head_initfunction xlog_grant_return_spacefunction smp_wmbfunction xlog_grant_head_wake_allfunction xlog_ticket_reservationfunction xlog_grant_head_wakefunction list_for_each_entryfunction xlog_grant_head_waitfunction xlog_grant_head_checkfunction xfs_log_writablefunction xfs_log_regrantfunction xfs_log_reservefunction xlog_state_iclog_releasefunction xlog_state_release_iclogfunction xfs_log_mountfunction xfs_log_mountfunction xfs_log_mount_cancelfunction xlog_force_iclogfunction xlog_wait_iclog_completionfunction xlog_wait_on_iclogfunction xlog_write_one_vecfunction xlog_write_unmount_recordfunction xlog_unmount_writefunction xfs_log_unmount_verify_iclogfunction xfs_log_unmount_writefunction XFS_TEST_ERRORfunction xfs_log_quiescefunction xfs_log_cleanfunction xfs_log_unmountfunction xfs_log_item_initfunction xfs_log_space_wakefunction xfs_log_need_coveredfunction xfs_log_coverfunction xlog_ioend_workfunction xlog_get_iclog_buffer_sizefunction xfs_log_work_queuefunction xlog_clear_incompatfunction xfs_log_workerfunction xlog_alloc_logfunction xlog_pack_datafunction xlog_cksumfunction xlog_bio_end_iofunction xlog_write_iclogfunction xlog_split_iclogfunction xlog_calc_iclog_size
Annotated Snippet
struct xlog_write_data {
struct xlog_ticket *ticket;
struct xlog_in_core *iclog;
uint32_t bytes_left;
uint32_t record_cnt;
uint32_t data_cnt;
int log_offset;
};
struct kmem_cache *xfs_log_ticket_cache;
/* Local miscellaneous function prototypes */
STATIC struct xlog *
xlog_alloc_log(
struct xfs_mount *mp,
struct xfs_buftarg *log_target,
xfs_daddr_t blk_offset,
int num_bblks);
STATIC void
xlog_dealloc_log(
struct xlog *log);
/* local state machine functions */
STATIC void xlog_state_done_syncing(
struct xlog_in_core *iclog);
STATIC void xlog_state_do_callback(
struct xlog *log);
STATIC int
xlog_state_get_iclog_space(
struct xlog *log,
struct xlog_write_data *data);
STATIC void
xlog_sync(
struct xlog *log,
struct xlog_in_core *iclog,
struct xlog_ticket *ticket);
#if defined(DEBUG)
STATIC void
xlog_verify_iclog(
struct xlog *log,
struct xlog_in_core *iclog,
int count);
STATIC void
xlog_verify_tail_lsn(
struct xlog *log,
struct xlog_in_core *iclog);
#else
#define xlog_verify_iclog(a,b,c)
#define xlog_verify_tail_lsn(a,b)
#endif
STATIC int
xlog_iclogs_empty(
struct xlog *log);
static int
xfs_log_cover(struct xfs_mount *);
static inline void
xlog_grant_sub_space(
struct xlog_grant_head *head,
int64_t bytes)
{
atomic64_sub(bytes, &head->grant);
}
static inline void
xlog_grant_add_space(
struct xlog_grant_head *head,
int64_t bytes)
{
atomic64_add(bytes, &head->grant);
}
static void
xlog_grant_head_init(
struct xlog_grant_head *head)
{
atomic64_set(&head->grant, 0);
INIT_LIST_HEAD(&head->waiters);
spin_lock_init(&head->lock);
}
void
xlog_grant_return_space(
struct xlog *log,
xfs_lsn_t old_head,
xfs_lsn_t new_head)
{
int64_t diff = xlog_lsn_sub(log, new_head, old_head);
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_errortag.h`.
- Detected declarations: `struct xlog_write_data`, `function xlog_grant_sub_space`, `function xlog_grant_add_space`, `function xlog_grant_head_init`, `function xlog_grant_return_space`, `function smp_wmb`, `function xlog_grant_head_wake_all`, `function xlog_ticket_reservation`, `function xlog_grant_head_wake`, `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.