fs/xfs/libxfs/xfs_rtrefcount_btree.h

Source file repositories/reference/linux-study-clean/fs/xfs/libxfs/xfs_rtrefcount_btree.h

File Facts

System
Linux kernel
Corpus path
fs/xfs/libxfs/xfs_rtrefcount_btree.h
Extension
.h
Size
5532 bytes
Lines
190
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

#ifndef __XFS_RTREFCOUNT_BTREE_H__
#define __XFS_RTREFCOUNT_BTREE_H__

struct xfs_buf;
struct xfs_btree_cur;
struct xfs_mount;
struct xbtree_ifakeroot;
struct xfs_rtgroup;

/* refcounts only exist on crc enabled filesystems */
#define XFS_RTREFCOUNT_BLOCK_LEN	XFS_BTREE_LBLOCK_CRC_LEN

struct xfs_btree_cur *xfs_rtrefcountbt_init_cursor(struct xfs_trans *tp,
		struct xfs_rtgroup *rtg);
struct xfs_btree_cur *xfs_rtrefcountbt_stage_cursor(struct xfs_mount *mp,
		struct xfs_rtgroup *rtg, struct xfs_inode *ip,
		struct xbtree_ifakeroot *ifake);
void xfs_rtrefcountbt_commit_staged_btree(struct xfs_btree_cur *cur,
		struct xfs_trans *tp);
unsigned int xfs_rtrefcountbt_maxrecs(struct xfs_mount *mp,
		unsigned int blocklen, bool leaf);
void xfs_rtrefcountbt_compute_maxlevels(struct xfs_mount *mp);
unsigned int xfs_rtrefcountbt_droot_maxrecs(unsigned int blocklen, bool leaf);

/*
 * Addresses of records, keys, and pointers within an incore rtrefcountbt block.
 *
 * (note that some of these may appear unused, but they are used in userspace)
 */
static inline struct xfs_refcount_rec *
xfs_rtrefcount_rec_addr(
	struct xfs_btree_block	*block,
	unsigned int		index)
{
	return (struct xfs_refcount_rec *)
		((char *)block + XFS_RTREFCOUNT_BLOCK_LEN +
		 (index - 1) * sizeof(struct xfs_refcount_rec));
}

static inline struct xfs_refcount_key *
xfs_rtrefcount_key_addr(
	struct xfs_btree_block	*block,
	unsigned int		index)
{
	return (struct xfs_refcount_key *)
		((char *)block + XFS_RTREFCOUNT_BLOCK_LEN +
		 (index - 1) * sizeof(struct xfs_refcount_key));
}

static inline xfs_rtrefcount_ptr_t *
xfs_rtrefcount_ptr_addr(
	struct xfs_btree_block	*block,
	unsigned int		index,
	unsigned int		maxrecs)
{
	return (xfs_rtrefcount_ptr_t *)
		((char *)block + XFS_RTREFCOUNT_BLOCK_LEN +
		 maxrecs * sizeof(struct xfs_refcount_key) +
		 (index - 1) * sizeof(xfs_rtrefcount_ptr_t));
}

unsigned int xfs_rtrefcountbt_maxlevels_ondisk(void);
int __init xfs_rtrefcountbt_init_cur_cache(void);
void xfs_rtrefcountbt_destroy_cur_cache(void);

xfs_filblks_t xfs_rtrefcountbt_calc_reserves(struct xfs_mount *mp);
unsigned long long xfs_rtrefcountbt_calc_size(struct xfs_mount *mp,
		unsigned long long len);

/* Addresses of key, pointers, and records within an ondisk rtrefcount block. */

static inline struct xfs_refcount_rec *
xfs_rtrefcount_droot_rec_addr(
	struct xfs_rtrefcount_root	*block,
	unsigned int			index)
{
	return (struct xfs_refcount_rec *)
		((char *)(block + 1) +
		 (index - 1) * sizeof(struct xfs_refcount_rec));
}

static inline struct xfs_refcount_key *
xfs_rtrefcount_droot_key_addr(
	struct xfs_rtrefcount_root	*block,
	unsigned int			index)
{
	return (struct xfs_refcount_key *)
		((char *)(block + 1) +
		 (index - 1) * sizeof(struct xfs_refcount_key));
}

Annotation

Implementation Notes