fs/xfs/xfs_trans_buf.c
Source file repositories/reference/linux-study-clean/fs/xfs/xfs_trans_buf.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/xfs_trans_buf.c- Extension
.c- Size
- 21276 bytes
- Lines
- 795
- 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.
- 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_buf_item.hxfs_trans_priv.hxfs_trace.h
Detected Declarations
function Copyrightfunction list_for_each_entryfunction _xfs_trans_bjoinfunction xfs_trans_bjoinfunction get_buffunction __xfs_trans_getsbfunction xfs_trans_getsbfunction xfs_trans_getrtsbfunction read_buffunction xfs_trans_buf_is_dirtyfunction xfs_trans_brelsefunction xfs_trans_bdetachfunction iop_committingfunction xfs_trans_bhold_releasefunction xfs_trans_dirty_buffunction xfs_trans_log_buffunction timefunction xfs_trans_inode_buffunction xfs_trans_stale_inode_buffunction xfs_buf_item_committedfunction xfs_trans_ordered_buffunction xfs_trans_buf_set_typefunction xfs_trans_buf_copy_typefunction xfs_trans_inode_buf
Annotated Snippet
if (xfs_is_shutdown(tp->t_mountp)) {
xfs_buf_stale(bp);
bp->b_flags |= XBF_DONE;
}
ASSERT(bp->b_transp == tp);
bip = bp->b_log_item;
ASSERT(bip != NULL);
ASSERT(atomic_read(&bip->bli_refcount) > 0);
bip->bli_recur++;
trace_xfs_trans_get_buf_recur(bip);
*bpp = bp;
return 0;
}
error = xfs_buf_get_map(target, map, nmaps, flags, &bp);
if (error)
return error;
ASSERT(!bp->b_error);
_xfs_trans_bjoin(tp, bp, 1);
trace_xfs_trans_get_buf(bp->b_log_item);
*bpp = bp;
return 0;
}
/*
* Get and lock the superblock buffer for the given transaction.
*/
static struct xfs_buf *
__xfs_trans_getsb(
struct xfs_trans *tp,
struct xfs_buf *bp)
{
/*
* Just increment the lock recursion count if the buffer is already
* attached to this transaction.
*/
if (bp->b_transp == tp) {
struct xfs_buf_log_item *bip = bp->b_log_item;
ASSERT(bip != NULL);
ASSERT(atomic_read(&bip->bli_refcount) > 0);
bip->bli_recur++;
trace_xfs_trans_getsb_recur(bip);
} else {
xfs_buf_lock(bp);
xfs_buf_hold(bp);
_xfs_trans_bjoin(tp, bp, 1);
trace_xfs_trans_getsb(bp->b_log_item);
}
return bp;
}
struct xfs_buf *
xfs_trans_getsb(
struct xfs_trans *tp)
{
return __xfs_trans_getsb(tp, tp->t_mountp->m_sb_bp);
}
struct xfs_buf *
xfs_trans_getrtsb(
struct xfs_trans *tp)
{
if (!tp->t_mountp->m_rtsb_bp)
return NULL;
return __xfs_trans_getsb(tp, tp->t_mountp->m_rtsb_bp);
}
/*
* Get and lock the buffer for the caller if it is not already
* locked within the given transaction. If it has not yet been
* read in, read it from disk. If it is already locked
* within the transaction and already read in, just increment its
* lock recursion count and return a pointer to it.
*
* If the transaction pointer is NULL, make this just a normal
* read_buf() call.
*/
int
xfs_trans_read_buf_map(
struct xfs_mount *mp,
struct xfs_trans *tp,
struct xfs_buftarg *target,
struct xfs_buf_map *map,
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 list_for_each_entry`, `function _xfs_trans_bjoin`, `function xfs_trans_bjoin`, `function get_buf`, `function __xfs_trans_getsb`, `function xfs_trans_getsb`, `function xfs_trans_getrtsb`, `function read_buf`, `function xfs_trans_buf_is_dirty`.
- 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.