fs/xfs/xfs_refcount_item.c
Source file repositories/reference/linux-study-clean/fs/xfs/xfs_refcount_item.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/xfs_refcount_item.c- Extension
.c- Size
- 23527 bytes
- Lines
- 863
- 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_format.hxfs_log_format.hxfs_trans_resv.hxfs_bit.hxfs_shared.hxfs_mount.hxfs_defer.hxfs_trans.hxfs_trans_priv.hxfs_refcount_item.hxfs_log.hxfs_refcount.hxfs_error.hxfs_log_priv.hxfs_log_recover.hxfs_ag.hxfs_btree.hxfs_trace.hxfs_rtgroup.h
Detected Declarations
function xfs_cui_item_freefunction xfs_cui_releasefunction xfs_cui_item_sizefunction xfs_cui_log_spacefunction xfs_cui_item_formatfunction xfs_cui_item_unpinfunction xfs_cui_item_releasefunction xfs_cui_initfunction xfs_cud_item_sizefunction xfs_cud_log_spacefunction xfs_cud_item_formatfunction xfs_cud_item_releasefunction xfs_cud_item_intentfunction xfs_cui_item_isrtfunction xfs_refcount_update_diff_itemsfunction xfs_refcount_update_log_itemfunction __xfs_refcount_update_create_intentfunction xfs_refcount_update_create_intentfunction xfs_cud_type_from_cuifunction xfs_refcount_update_create_donefunction xfs_refcount_defer_addfunction xfs_refcount_update_cancel_itemfunction xfs_refcount_update_finish_itemfunction xfs_refcount_finish_one_cleanupfunction xfs_refcount_update_abort_intentfunction xfs_cui_validate_physfunction xfs_cui_recover_workfunction xfs_refcount_recover_workfunction xfs_refcount_relog_intentfunction xfs_rtrefcount_update_create_intentfunction xfs_rtrefcount_update_finish_itemfunction xfs_rtrefcount_finish_one_cleanupfunction xfs_cui_item_matchfunction xfs_cui_copy_formatfunction xlog_recover_cui_commit_pass2function xlog_recover_rtcui_commit_pass2function xlog_recover_rtcui_commit_pass2function xlog_recover_cud_commit_pass2function xlog_recover_rtcud_commit_pass2
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright (C) 2016 Oracle. All Rights Reserved.
* Author: Darrick J. Wong <darrick.wong@oracle.com>
*/
#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_trans.h"
#include "xfs_trans_priv.h"
#include "xfs_refcount_item.h"
#include "xfs_log.h"
#include "xfs_refcount.h"
#include "xfs_error.h"
#include "xfs_log_priv.h"
#include "xfs_log_recover.h"
#include "xfs_ag.h"
#include "xfs_btree.h"
#include "xfs_trace.h"
#include "xfs_rtgroup.h"
struct kmem_cache *xfs_cui_cache;
struct kmem_cache *xfs_cud_cache;
static const struct xfs_item_ops xfs_cui_item_ops;
static inline struct xfs_cui_log_item *CUI_ITEM(struct xfs_log_item *lip)
{
return container_of(lip, struct xfs_cui_log_item, cui_item);
}
STATIC void
xfs_cui_item_free(
struct xfs_cui_log_item *cuip)
{
kvfree(cuip->cui_item.li_lv_shadow);
if (cuip->cui_format.cui_nextents > XFS_CUI_MAX_FAST_EXTENTS)
kfree(cuip);
else
kmem_cache_free(xfs_cui_cache, cuip);
}
/*
* Freeing the CUI requires that we remove it from the AIL if it has already
* been placed there. However, the CUI may not yet have been placed in the AIL
* when called by xfs_cui_release() from CUD 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 CUI.
*/
STATIC void
xfs_cui_release(
struct xfs_cui_log_item *cuip)
{
ASSERT(atomic_read(&cuip->cui_refcount) > 0);
if (!atomic_dec_and_test(&cuip->cui_refcount))
return;
xfs_trans_ail_delete(&cuip->cui_item, 0);
xfs_cui_item_free(cuip);
}
STATIC void
xfs_cui_item_size(
struct xfs_log_item *lip,
int *nvecs,
int *nbytes)
{
struct xfs_cui_log_item *cuip = CUI_ITEM(lip);
*nvecs += 1;
*nbytes += xfs_cui_log_format_sizeof(cuip->cui_format.cui_nextents);
}
unsigned int xfs_cui_log_space(unsigned int nr)
{
return xlog_item_space(1, xfs_cui_log_format_sizeof(nr));
}
/*
* This is called to fill in the vector of log iovecs for the
* given cui log item. We use only 1 iovec, and we point that
* at the cui_log_format structure embedded in the cui item.
* It is at this point that we assert that all of the extent
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_cui_item_free`, `function xfs_cui_release`, `function xfs_cui_item_size`, `function xfs_cui_log_space`, `function xfs_cui_item_format`, `function xfs_cui_item_unpin`, `function xfs_cui_item_release`, `function xfs_cui_init`, `function xfs_cud_item_size`, `function xfs_cud_log_space`.
- 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.