fs/xfs/xfs_exchmaps_item.c
Source file repositories/reference/linux-study-clean/fs/xfs/xfs_exchmaps_item.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/xfs_exchmaps_item.c- Extension
.c- Size
- 16679 bytes
- Lines
- 612
- 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_format.hxfs_log_format.hxfs_trans_resv.hxfs_bit.hxfs_shared.hxfs_mount.hxfs_defer.hxfs_inode.hxfs_trans.hxfs_trans_priv.hxfs_exchmaps_item.hxfs_exchmaps.hxfs_log.hxfs_bmap.hxfs_icache.hxfs_bmap_btree.hxfs_trans_space.hxfs_error.hxfs_log_priv.hxfs_log_recover.hxfs_exchrange.hxfs_trace.h
Detected Declarations
function xfs_xmi_item_freefunction xfs_xmi_releasefunction xfs_xmi_item_sizefunction xfs_xmi_item_formatfunction xfs_xmi_item_unpinfunction xfs_xmi_item_releasefunction xfs_xmi_initfunction xfs_xmd_item_sizefunction xfs_xmd_item_formatfunction xfs_xmd_item_releasefunction xfs_xmd_item_intentfunction xfs_exchmaps_create_intentfunction xfs_exchmaps_create_donefunction xfs_exchmaps_defer_addfunction xfs_exchmaps_cancel_itemfunction xfs_exchmaps_finish_itemfunction xfs_exchmaps_abort_intentfunction xfs_xmi_validatefunction xfs_xmi_item_recover_intentfunction xfs_exchmaps_recover_workfunction xfs_exchmaps_relog_intentfunction xfs_xmi_item_matchfunction xlog_recover_xmi_commit_pass2function xlog_recover_xmd_commit_pass2
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Copyright (c) 2020-2024 Oracle. All Rights Reserved.
* Author: Darrick J. Wong <djwong@kernel.org>
*/
#include "xfs_platform.h"
#include "xfs_fs.h"
#include "xfs_format.h"
#include "xfs_log_format.h"
#include "xfs_trans_resv.h"
#include "xfs_bit.h"
#include "xfs_shared.h"
#include "xfs_mount.h"
#include "xfs_defer.h"
#include "xfs_inode.h"
#include "xfs_trans.h"
#include "xfs_trans_priv.h"
#include "xfs_exchmaps_item.h"
#include "xfs_exchmaps.h"
#include "xfs_log.h"
#include "xfs_bmap.h"
#include "xfs_icache.h"
#include "xfs_bmap_btree.h"
#include "xfs_trans_space.h"
#include "xfs_error.h"
#include "xfs_log_priv.h"
#include "xfs_log_recover.h"
#include "xfs_exchrange.h"
#include "xfs_trace.h"
struct kmem_cache *xfs_xmi_cache;
struct kmem_cache *xfs_xmd_cache;
static const struct xfs_item_ops xfs_xmi_item_ops;
static inline struct xfs_xmi_log_item *XMI_ITEM(struct xfs_log_item *lip)
{
return container_of(lip, struct xfs_xmi_log_item, xmi_item);
}
STATIC void
xfs_xmi_item_free(
struct xfs_xmi_log_item *xmi_lip)
{
kvfree(xmi_lip->xmi_item.li_lv_shadow);
kmem_cache_free(xfs_xmi_cache, xmi_lip);
}
/*
* Freeing the XMI requires that we remove it from the AIL if it has already
* been placed there. However, the XMI may not yet have been placed in the AIL
* when called by xfs_xmi_release() from XMD processing due to the ordering of
* committed vs unpin operations in bulk insert operations. Hence the reference
* count to ensure only the last caller frees the XMI.
*/
STATIC void
xfs_xmi_release(
struct xfs_xmi_log_item *xmi_lip)
{
ASSERT(atomic_read(&xmi_lip->xmi_refcount) > 0);
if (atomic_dec_and_test(&xmi_lip->xmi_refcount)) {
xfs_trans_ail_delete(&xmi_lip->xmi_item, 0);
xfs_xmi_item_free(xmi_lip);
}
}
STATIC void
xfs_xmi_item_size(
struct xfs_log_item *lip,
int *nvecs,
int *nbytes)
{
*nvecs += 1;
*nbytes += sizeof(struct xfs_xmi_log_format);
}
/*
* This is called to fill in the vector of log iovecs for the given xmi log
* item. We use only 1 iovec, and we point that at the xmi_log_format structure
* embedded in the xmi item.
*/
STATIC void
xfs_xmi_item_format(
struct xfs_log_item *lip,
struct xlog_format_buf *lfb)
{
struct xfs_xmi_log_item *xmi_lip = XMI_ITEM(lip);
xmi_lip->xmi_format.xmi_type = XFS_LI_XMI;
Annotation
- Immediate include surface: `xfs_platform.h`, `xfs_fs.h`, `xfs_format.h`, `xfs_log_format.h`, `xfs_trans_resv.h`, `xfs_bit.h`, `xfs_shared.h`, `xfs_mount.h`.
- Detected declarations: `function xfs_xmi_item_free`, `function xfs_xmi_release`, `function xfs_xmi_item_size`, `function xfs_xmi_item_format`, `function xfs_xmi_item_unpin`, `function xfs_xmi_item_release`, `function xfs_xmi_init`, `function xfs_xmd_item_size`, `function xfs_xmd_item_format`, `function xfs_xmd_item_release`.
- 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.