fs/xfs/libxfs/xfs_bmap_btree.c
Source file repositories/reference/linux-study-clean/fs/xfs/libxfs/xfs_bmap_btree.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/libxfs/xfs_bmap_btree.c- Extension
.c- Size
- 22905 bytes
- Lines
- 861
- 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_log_format.hxfs_trans_resv.hxfs_bit.hxfs_mount.hxfs_inode.hxfs_trans.hxfs_alloc.hxfs_btree.hxfs_btree_staging.hxfs_bmap_btree.hxfs_bmap.hxfs_error.hxfs_quota.hxfs_trace.hxfs_rmap.hxfs_ag.h
Detected Declarations
function xfs_bmbt_init_blockfunction xfs_bmdr_to_bmbtfunction xfs_bmbt_disk_get_allfunction xfs_bmbt_disk_get_blockcountfunction xfs_bmbt_disk_get_startofffunction xfs_bmbt_disk_set_allfunction xfs_bmbt_to_bmdrfunction xfs_bmbt_dup_cursorfunction xfs_bmbt_update_cursorfunction xfs_bmbt_alloc_blockfunction xfs_bmbt_free_blockfunction xfs_bmbt_get_minrecsfunction xfs_bmbt_get_maxrecsfunction xfs_bmbt_get_dmaxrecsfunction xfs_bmbt_init_key_from_recfunction xfs_bmbt_init_high_key_from_recfunction xfs_bmbt_init_rec_from_curfunction xfs_bmbt_cmp_key_with_curfunction xfs_bmbt_cmp_two_keysfunction xfs_bmbt_verifyfunction xfs_bmbt_read_verifyfunction xfs_bmbt_write_verifyfunction xfs_bmbt_keys_inorderfunction xfs_bmbt_recs_inorderfunction xfs_bmbt_keys_contiguousfunction xfs_bmbt_move_ptrsfunction xfs_bmap_broot_reallocfunction xfs_bmbt_broot_reallocfunction xfs_bmbt_init_cursorfunction xfs_bmbt_block_maxrecsfunction xfs_bmbt_commit_staged_btreefunction xfs_bmbt_maxrecsfunction xfs_bmbt_maxlevels_ondiskfunction xfs_bmdr_maxrecsfunction xfs_bmbt_change_ownerfunction xfs_bmbt_calc_sizefunction xfs_bmbt_init_cur_cachefunction xfs_bmbt_destroy_cur_cache
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
* All Rights Reserved.
*/
#include "xfs_platform.h"
#include "xfs_fs.h"
#include "xfs_shared.h"
#include "xfs_format.h"
#include "xfs_log_format.h"
#include "xfs_trans_resv.h"
#include "xfs_bit.h"
#include "xfs_mount.h"
#include "xfs_inode.h"
#include "xfs_trans.h"
#include "xfs_alloc.h"
#include "xfs_btree.h"
#include "xfs_btree_staging.h"
#include "xfs_bmap_btree.h"
#include "xfs_bmap.h"
#include "xfs_error.h"
#include "xfs_quota.h"
#include "xfs_trace.h"
#include "xfs_rmap.h"
#include "xfs_ag.h"
static struct kmem_cache *xfs_bmbt_cur_cache;
void
xfs_bmbt_init_block(
struct xfs_inode *ip,
struct xfs_btree_block *buf,
struct xfs_buf *bp,
__u16 level,
__u16 numrecs)
{
if (bp)
xfs_btree_init_buf(ip->i_mount, bp, &xfs_bmbt_ops, level,
numrecs, I_INO(ip));
else
xfs_btree_init_block(ip->i_mount, buf, &xfs_bmbt_ops, level,
numrecs, I_INO(ip));
}
/*
* Convert on-disk form of btree root to in-memory form.
*/
void
xfs_bmdr_to_bmbt(
struct xfs_inode *ip,
xfs_bmdr_block_t *dblock,
int dblocklen,
struct xfs_btree_block *rblock,
int rblocklen)
{
struct xfs_mount *mp = ip->i_mount;
int dmxr;
xfs_bmbt_key_t *fkp;
__be64 *fpp;
xfs_bmbt_key_t *tkp;
__be64 *tpp;
xfs_bmbt_init_block(ip, rblock, NULL, 0, 0);
rblock->bb_level = dblock->bb_level;
ASSERT(be16_to_cpu(rblock->bb_level) > 0);
rblock->bb_numrecs = dblock->bb_numrecs;
dmxr = xfs_bmdr_maxrecs(dblocklen, 0);
fkp = xfs_bmdr_key_addr(dblock, 1);
tkp = xfs_bmbt_key_addr(mp, rblock, 1);
fpp = xfs_bmdr_ptr_addr(dblock, 1, dmxr);
tpp = xfs_bmap_broot_ptr_addr(mp, rblock, 1, rblocklen);
dmxr = be16_to_cpu(dblock->bb_numrecs);
memcpy(tkp, fkp, sizeof(*fkp) * dmxr);
memcpy(tpp, fpp, sizeof(*fpp) * dmxr);
}
void
xfs_bmbt_disk_get_all(
const struct xfs_bmbt_rec *rec,
struct xfs_bmbt_irec *irec)
{
uint64_t l0 = get_unaligned_be64(&rec->l0);
uint64_t l1 = get_unaligned_be64(&rec->l1);
irec->br_startoff = (l0 & xfs_mask64lo(64 - BMBT_EXNTFLAG_BITLEN)) >> 9;
irec->br_startblock = ((l0 & xfs_mask64lo(9)) << 43) | (l1 >> 21);
irec->br_blockcount = l1 & xfs_mask64lo(21);
if (l0 >> (64 - BMBT_EXNTFLAG_BITLEN))
irec->br_state = XFS_EXT_UNWRITTEN;
else
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_bit.h`, `xfs_mount.h`.
- Detected declarations: `function xfs_bmbt_init_block`, `function xfs_bmdr_to_bmbt`, `function xfs_bmbt_disk_get_all`, `function xfs_bmbt_disk_get_blockcount`, `function xfs_bmbt_disk_get_startoff`, `function xfs_bmbt_disk_set_all`, `function xfs_bmbt_to_bmdr`, `function xfs_bmbt_dup_cursor`, `function xfs_bmbt_update_cursor`, `function xfs_bmbt_alloc_block`.
- 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.