fs/xfs/xfs_buf_item_recover.c
Source file repositories/reference/linux-study-clean/fs/xfs/xfs_buf_item_recover.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/xfs_buf_item_recover.c- Extension
.c- Size
- 34797 bytes
- Lines
- 1217
- 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_bit.hxfs_mount.hxfs_trans.hxfs_buf_item.hxfs_trans_priv.hxfs_trace.hxfs_log.hxfs_log_priv.hxfs_log_recover.hxfs_error.hxfs_inode.hxfs_dir2.hxfs_quota.hxfs_alloc.hxfs_ag.hxfs_sb.hxfs_rtgroup.hxfs_rtbitmap.h
Detected Declarations
struct xfs_buf_cancelfunction xlog_find_buffer_cancelledfunction xlog_add_buffer_cancelledfunction xlog_is_buffer_cancelledfunction xlog_put_buffer_cancelledfunction xlog_recover_buf_reorderfunction xlog_recover_buf_ra_pass2function xlog_recover_buf_commit_pass1function bufferfunction xlog_recover_do_reg_bufferfunction xlog_recover_do_dquot_bufferfunction xlog_recover_inode_pass2function xlog_recover_do_primary_sb_bufferfunction xlog_recover_get_buf_lsnfunction xlog_recover_buf_commit_pass2function xfs_buf_daddrfunction be16_to_cpufunction xlog_check_buf_cancel_tablefunction xlog_alloc_buf_cancel_tablefunction xlog_free_buf_cancel_table
Annotated Snippet
struct xfs_buf_cancel {
xfs_daddr_t bc_blkno;
uint bc_len;
int bc_refcount;
struct list_head bc_list;
};
static struct xfs_buf_cancel *
xlog_find_buffer_cancelled(
struct xlog *log,
xfs_daddr_t blkno,
uint len)
{
struct list_head *bucket;
struct xfs_buf_cancel *bcp;
if (!log->l_buf_cancel_table)
return NULL;
bucket = XLOG_BUF_CANCEL_BUCKET(log, blkno);
list_for_each_entry(bcp, bucket, bc_list) {
if (bcp->bc_blkno == blkno && bcp->bc_len == len)
return bcp;
}
return NULL;
}
static bool
xlog_add_buffer_cancelled(
struct xlog *log,
xfs_daddr_t blkno,
uint len)
{
struct xfs_buf_cancel *bcp;
/*
* If we find an existing cancel record, this indicates that the buffer
* was cancelled multiple times. To ensure that during pass 2 we keep
* the record in the table until we reach its last occurrence in the
* log, a reference count is kept to tell how many times we expect to
* see this record during the second pass.
*/
bcp = xlog_find_buffer_cancelled(log, blkno, len);
if (bcp) {
bcp->bc_refcount++;
return false;
}
bcp = kmalloc_obj(struct xfs_buf_cancel, GFP_KERNEL | __GFP_NOFAIL);
bcp->bc_blkno = blkno;
bcp->bc_len = len;
bcp->bc_refcount = 1;
list_add_tail(&bcp->bc_list, XLOG_BUF_CANCEL_BUCKET(log, blkno));
return true;
}
/*
* Check if there is and entry for blkno, len in the buffer cancel record table.
*/
bool
xlog_is_buffer_cancelled(
struct xlog *log,
xfs_daddr_t blkno,
uint len)
{
return xlog_find_buffer_cancelled(log, blkno, len) != NULL;
}
/*
* Check if there is and entry for blkno, len in the buffer cancel record table,
* and decremented the reference count on it if there is one.
*
* Remove the cancel record once the refcount hits zero, so that if the same
* buffer is re-used again after its last cancellation we actually replay the
* changes made at that point.
*/
static bool
xlog_put_buffer_cancelled(
struct xlog *log,
xfs_daddr_t blkno,
uint len)
{
struct xfs_buf_cancel *bcp;
bcp = xlog_find_buffer_cancelled(log, blkno, len);
if (!bcp) {
ASSERT(0);
return false;
}
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_mount.h`.
- Detected declarations: `struct xfs_buf_cancel`, `function xlog_find_buffer_cancelled`, `function xlog_add_buffer_cancelled`, `function xlog_is_buffer_cancelled`, `function xlog_put_buffer_cancelled`, `function xlog_recover_buf_reorder`, `function xlog_recover_buf_ra_pass2`, `function xlog_recover_buf_commit_pass1`, `function buffer`, `function xlog_recover_do_reg_buffer`.
- 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.