fs/btrfs/accessors.h
Source file repositories/reference/linux-study-clean/fs/btrfs/accessors.h
File Facts
- System
- Linux kernel
- Corpus path
fs/btrfs/accessors.h- Extension
.h- Size
- 42532 bytes
- Lines
- 1051
- 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.
- 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
linux/unaligned.hlinux/stddef.hlinux/types.hlinux/align.hlinux/build_bug.hlinux/compiler.hlinux/string.hlinux/mm.huapi/linux/btrfs_tree.hfs.hextent_io.h
Detected Declarations
struct extent_bufferfunction get_unaligned_le8function put_unaligned_le8function btrfs_device_total_bytesfunction btrfs_set_device_total_bytesfunction btrfs_device_uuidfunction btrfs_device_fsidfunction btrfs_stripe_offset_nrfunction btrfs_set_stripe_offset_nrfunction btrfs_stripe_devid_nrfunction btrfs_set_stripe_devid_nrfunction btrfs_tree_block_keyfunction btrfs_set_tree_block_keyfunction btrfs_extent_inline_ref_sizefunction btrfs_node_blockptrfunction btrfs_set_node_blockptrfunction btrfs_node_ptr_generationfunction btrfs_set_node_ptr_generationfunction btrfs_node_key_ptr_offsetfunction btrfs_set_node_keyfunction btrfs_item_nr_offsetfunction btrfs_item_data_endfunction btrfs_item_keyfunction btrfs_set_item_keyfunction btrfs_dir_ftypefunction btrfs_stack_dir_ftypefunction btrfs_dir_item_keyfunction btrfs_set_dir_item_keyfunction btrfs_free_space_keyfunction btrfs_set_free_space_keyfunction btrfs_disk_key_to_cpufunction btrfs_cpu_key_to_diskfunction btrfs_node_key_to_cpufunction btrfs_item_key_to_cpufunction btrfs_dir_item_key_to_cpufunction btrfs_disk_key_to_cpufunction btrfs_cpu_key_to_diskfunction btrfs_node_key_to_cpufunction btrfs_item_key_to_cpufunction btrfs_dir_item_key_to_cpufunction btrfs_header_flagfunction btrfs_set_header_flagfunction btrfs_clear_header_flagfunction btrfs_header_backref_revfunction btrfs_set_header_backref_revfunction btrfs_is_leaffunction btrfs_balance_datafunction btrfs_set_balance_data
Annotated Snippet
#ifndef BTRFS_ACCESSORS_H
#define BTRFS_ACCESSORS_H
#include <linux/unaligned.h>
#include <linux/stddef.h>
#include <linux/types.h>
#include <linux/align.h>
#include <linux/build_bug.h>
#include <linux/compiler.h>
#include <linux/string.h>
#include <linux/mm.h>
#include <uapi/linux/btrfs_tree.h>
#include "fs.h"
#include "extent_io.h"
struct extent_buffer;
/*
* Some macros to generate set/get functions for the struct fields. This
* assumes there is a lefoo_to_cpu for every type, so lets make a simple one
* for u8:
*/
#define le8_to_cpu(v) (v)
#define cpu_to_le8(v) (v)
#define __le8 u8
static inline u8 get_unaligned_le8(const void *p)
{
return *(const u8 *)p;
}
static inline void put_unaligned_le8(u8 val, void *p)
{
*(u8 *)p = val;
}
#define read_eb_member(eb, ptr, type, member, result) (\
read_extent_buffer(eb, (char *)(result), \
((unsigned long)(ptr)) + \
offsetof(type, member), \
sizeof_field(type, member)))
#define write_eb_member(eb, ptr, type, member, source) ( \
write_extent_buffer(eb, (const char *)(source), \
((unsigned long)(ptr)) + \
offsetof(type, member), \
sizeof_field(type, member)))
#define DECLARE_BTRFS_SETGET_BITS(bits) \
u##bits btrfs_get_##bits(const struct extent_buffer *eb, \
const void *ptr, unsigned long off); \
void btrfs_set_##bits(const struct extent_buffer *eb, void *ptr, \
unsigned long off, u##bits val);
DECLARE_BTRFS_SETGET_BITS(8)
DECLARE_BTRFS_SETGET_BITS(16)
DECLARE_BTRFS_SETGET_BITS(32)
DECLARE_BTRFS_SETGET_BITS(64)
#define BTRFS_SETGET_FUNCS(name, type, member, bits) \
static inline u##bits btrfs_##name(const struct extent_buffer *eb, \
const type *s) \
{ \
static_assert(sizeof(u##bits) == sizeof_field(type, member)); \
return btrfs_get_##bits(eb, s, offsetof(type, member)); \
} \
static inline void btrfs_set_##name(const struct extent_buffer *eb, type *s, \
u##bits val) \
{ \
static_assert(sizeof(u##bits) == sizeof_field(type, member)); \
btrfs_set_##bits(eb, s, offsetof(type, member), val); \
}
#define BTRFS_SETGET_HEADER_FUNCS(name, type, member, bits) \
static inline u##bits btrfs_##name(const struct extent_buffer *eb) \
{ \
const type *p = folio_address(eb->folios[0]) + \
offset_in_page(eb->start); \
return get_unaligned_le##bits(&p->member); \
} \
static inline void btrfs_set_##name(const struct extent_buffer *eb, \
u##bits val) \
{ \
type *p = folio_address(eb->folios[0]) + offset_in_page(eb->start); \
put_unaligned_le##bits(val, &p->member); \
}
#define BTRFS_SETGET_STACK_FUNCS(name, type, member, bits) \
static inline u##bits btrfs_##name(const type *s) \
{ \
Annotation
- Immediate include surface: `linux/unaligned.h`, `linux/stddef.h`, `linux/types.h`, `linux/align.h`, `linux/build_bug.h`, `linux/compiler.h`, `linux/string.h`, `linux/mm.h`.
- Detected declarations: `struct extent_buffer`, `function get_unaligned_le8`, `function put_unaligned_le8`, `function btrfs_device_total_bytes`, `function btrfs_set_device_total_bytes`, `function btrfs_device_uuid`, `function btrfs_device_fsid`, `function btrfs_stripe_offset_nr`, `function btrfs_set_stripe_offset_nr`, `function btrfs_stripe_devid_nr`.
- 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.