fs/xfs/xfs_log_recover.c
Source file repositories/reference/linux-study-clean/fs/xfs/xfs_log_recover.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/xfs_log_recover.c- Extension
.c- Size
- 101415 bytes
- Lines
- 3579
- 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_bit.hxfs_sb.hxfs_mount.hxfs_defer.hxfs_inode.hxfs_trans.hxfs_log.hxfs_log_priv.hxfs_log_recover.hxfs_trans_priv.hxfs_alloc.hxfs_ialloc.hxfs_trace.hxfs_icache.hxfs_error.hxfs_buf_item.hxfs_ag.hxfs_quota.hxfs_reflink.h
Detected Declarations
function xlog_verify_bnofunction xlog_alloc_bufferfunction xlog_alignfunction xlog_do_iofunction xlog_bread_noalignfunction xlog_breadfunction xlog_bwritefunction xlog_header_check_dumpfunction xlog_header_check_recoverfunction xlog_header_check_mountfunction findsfunction xlog_find_verify_cyclefunction xlog_logrec_hblksfunction xlog_find_verify_log_recordfunction xlog_find_headfunction xlog_rseek_logrec_hdrfunction xlog_seek_logrec_hdrfunction tailfunction xlog_verify_tailfunction xlog_wrap_logbnofunction xlog_check_unmount_recfunction xlog_set_statefunction xlog_find_tailfunction cleanfunction xlog_find_zeroedfunction xlog_clear_stale_blocksfunction xlog_write_log_recordsfunction xlog_clear_stale_blocksfunction xlog_recover_release_intentfunction list_for_each_entry_safefunction xlog_recover_igetfunction xlog_recover_iget_handlefunction xlog_find_item_opsfunction xlog_recover_reorder_transfunction xlog_buf_readaheadfunction xlog_recover_intent_itemfunction xlog_recover_items_pass2function list_for_each_entryfunction xlog_recover_commit_transfunction list_for_each_entry_safefunction xlog_recover_add_itemfunction xlog_recover_add_to_cont_transfunction xlog_recover_add_to_transfunction xlog_recover_free_transfunction list_for_each_entry_safefunction xlog_recovery_process_transfunction xlog_recover_ophdr_to_transfunction xlog_recover_process_ophdr
Annotated Snippet
if (cycle == stop_on_cycle_no) {
*new_blk = i+j;
goto out;
}
buf += BBSIZE;
}
}
*new_blk = -1;
out:
kvfree(buffer);
return error;
}
static inline int
xlog_logrec_hblks(struct xlog *log, struct xlog_rec_header *rh)
{
if (xfs_has_logv2(log->l_mp)) {
int h_size = be32_to_cpu(rh->h_size);
if ((be32_to_cpu(rh->h_version) & XLOG_VERSION_2) &&
h_size > XLOG_HEADER_CYCLE_SIZE)
return DIV_ROUND_UP(h_size, XLOG_HEADER_CYCLE_SIZE);
}
return 1;
}
/*
* Potentially backup over partial log record write.
*
* In the typical case, last_blk is the number of the block directly after
* a good log record. Therefore, we subtract one to get the block number
* of the last block in the given buffer. extra_bblks contains the number
* of blocks we would have read on a previous read. This happens when the
* last log record is split over the end of the physical log.
*
* extra_bblks is the number of blocks potentially verified on a previous
* call to this routine.
*/
STATIC int
xlog_find_verify_log_record(
struct xlog *log,
xfs_daddr_t start_blk,
xfs_daddr_t *last_blk,
int extra_bblks)
{
xfs_daddr_t i;
char *buffer;
char *offset = NULL;
struct xlog_rec_header *head = NULL;
int error = 0;
int smallmem = 0;
int num_blks = *last_blk - start_blk;
int xhdrs;
ASSERT(start_blk != 0 || *last_blk != start_blk);
buffer = xlog_alloc_buffer(log, num_blks);
if (!buffer) {
buffer = xlog_alloc_buffer(log, 1);
if (!buffer)
return -ENOMEM;
smallmem = 1;
} else {
error = xlog_bread(log, start_blk, num_blks, buffer, &offset);
if (error)
goto out;
offset += ((num_blks - 1) << BBSHIFT);
}
for (i = (*last_blk) - 1; i >= 0; i--) {
if (i < start_blk) {
/* valid log record not found */
xfs_warn(log->l_mp,
"Log inconsistent (didn't find previous header)");
ASSERT(0);
error = -EFSCORRUPTED;
goto out;
}
if (smallmem) {
error = xlog_bread(log, i, 1, buffer, &offset);
if (error)
goto out;
}
head = (struct xlog_rec_header *)offset;
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_sb.h`.
- Detected declarations: `function xlog_verify_bno`, `function xlog_alloc_buffer`, `function xlog_align`, `function xlog_do_io`, `function xlog_bread_noalign`, `function xlog_bread`, `function xlog_bwrite`, `function xlog_header_check_dump`, `function xlog_header_check_recover`, `function xlog_header_check_mount`.
- 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.