fs/xfs/scrub/rcbag_btree.c
Source file repositories/reference/linux-study-clean/fs/xfs/scrub/rcbag_btree.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/scrub/rcbag_btree.c- Extension
.c- Size
- 8650 bytes
- Lines
- 353
- 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.
- 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_trans_resv.hxfs_mount.hxfs_defer.hxfs_btree.hxfs_buf_mem.hxfs_btree_mem.hxfs_error.hscrub/rcbag_btree.hscrub/trace.h
Detected Declarations
function rcbagbt_init_key_from_recfunction rcbagbt_init_rec_from_curfunction rcbagbt_cmp_key_with_curfunction rcbagbt_cmp_two_keysfunction rcbagbt_keys_inorderfunction rcbagbt_recs_inorderfunction rcbagbt_verifyfunction rcbagbt_rw_verifyfunction rcbagbt_mem_cursorfunction rcbagbt_mem_initfunction rcbagbt_block_maxrecsfunction rcbagbt_maxrecsfunction rcbagbt_maxlevels_possiblefunction rcbagbt_calc_sizefunction rcbagbt_init_cur_cachefunction rcbagbt_destroy_cur_cachefunction rcbagbt_lookup_eqfunction rcbagbt_get_recfunction rcbagbt_updatefunction rcbagbt_insert
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Copyright (c) 2022-2024 Oracle. All Rights Reserved.
* Author: Darrick J. Wong <djwong@kernel.org>
*/
#include "xfs_platform.h"
#include "xfs_fs.h"
#include "xfs_shared.h"
#include "xfs_format.h"
#include "xfs_trans_resv.h"
#include "xfs_mount.h"
#include "xfs_defer.h"
#include "xfs_btree.h"
#include "xfs_buf_mem.h"
#include "xfs_btree_mem.h"
#include "xfs_error.h"
#include "scrub/rcbag_btree.h"
#include "scrub/trace.h"
static struct kmem_cache *rcbagbt_cur_cache;
STATIC void
rcbagbt_init_key_from_rec(
union xfs_btree_key *key,
const union xfs_btree_rec *rec)
{
struct rcbag_key *bag_key = (struct rcbag_key *)key;
const struct rcbag_rec *bag_rec = (const struct rcbag_rec *)rec;
BUILD_BUG_ON(sizeof(struct rcbag_key) > sizeof(union xfs_btree_key));
BUILD_BUG_ON(sizeof(struct rcbag_rec) > sizeof(union xfs_btree_rec));
bag_key->rbg_startblock = bag_rec->rbg_startblock;
bag_key->rbg_blockcount = bag_rec->rbg_blockcount;
}
STATIC void
rcbagbt_init_rec_from_cur(
struct xfs_btree_cur *cur,
union xfs_btree_rec *rec)
{
struct rcbag_rec *bag_rec = (struct rcbag_rec *)rec;
struct rcbag_rec *bag_irec = (struct rcbag_rec *)&cur->bc_rec;
bag_rec->rbg_startblock = bag_irec->rbg_startblock;
bag_rec->rbg_blockcount = bag_irec->rbg_blockcount;
bag_rec->rbg_refcount = bag_irec->rbg_refcount;
}
STATIC int
rcbagbt_cmp_key_with_cur(
struct xfs_btree_cur *cur,
const union xfs_btree_key *key)
{
struct rcbag_rec *rec = (struct rcbag_rec *)&cur->bc_rec;
const struct rcbag_key *kp = (const struct rcbag_key *)key;
return cmp_int(kp->rbg_startblock, rec->rbg_startblock) ?:
cmp_int(kp->rbg_blockcount, rec->rbg_blockcount);
}
STATIC int
rcbagbt_cmp_two_keys(
struct xfs_btree_cur *cur,
const union xfs_btree_key *k1,
const union xfs_btree_key *k2,
const union xfs_btree_key *mask)
{
const struct rcbag_key *kp1 = (const struct rcbag_key *)k1;
const struct rcbag_key *kp2 = (const struct rcbag_key *)k2;
ASSERT(mask == NULL);
return cmp_int(kp1->rbg_startblock, kp2->rbg_startblock) ?:
cmp_int(kp1->rbg_blockcount, kp2->rbg_blockcount);
}
STATIC int
rcbagbt_keys_inorder(
struct xfs_btree_cur *cur,
const union xfs_btree_key *k1,
const union xfs_btree_key *k2)
{
const struct rcbag_key *kp1 = (const struct rcbag_key *)k1;
const struct rcbag_key *kp2 = (const struct rcbag_key *)k2;
if (kp1->rbg_startblock > kp2->rbg_startblock)
return 0;
if (kp1->rbg_startblock < kp2->rbg_startblock)
return 1;
Annotation
- Immediate include surface: `xfs_platform.h`, `xfs_fs.h`, `xfs_shared.h`, `xfs_format.h`, `xfs_trans_resv.h`, `xfs_mount.h`, `xfs_defer.h`, `xfs_btree.h`.
- Detected declarations: `function rcbagbt_init_key_from_rec`, `function rcbagbt_init_rec_from_cur`, `function rcbagbt_cmp_key_with_cur`, `function rcbagbt_cmp_two_keys`, `function rcbagbt_keys_inorder`, `function rcbagbt_recs_inorder`, `function rcbagbt_verify`, `function rcbagbt_rw_verify`, `function rcbagbt_mem_cursor`, `function rcbagbt_mem_init`.
- 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.