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.

Dependency Surface

Detected Declarations

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

Implementation Notes