fs/btrfs/ctree.h
Source file repositories/reference/linux-study-clean/fs/btrfs/ctree.h
File Facts
- System
- Linux kernel
- Corpus path
fs/btrfs/ctree.h- Extension
.h- Size
- 23954 bytes
- Lines
- 751
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/cleanup.hlinux/spinlock.hlinux/rbtree.hlinux/mutex.hlinux/wait.hlinux/list.hlinux/atomic.hlinux/xarray.hlinux/refcount.huapi/linux/btrfs_tree.hlocking.haccessors.h
Detected Declarations
struct extent_bufferstruct btrfs_block_rsvstruct btrfs_trans_handlestruct btrfs_block_groupstruct btrfs_pathstruct btrfs_qgroup_swapped_blocksstruct btrfs_rootstruct btrfs_replace_extent_infostruct btrfs_drop_extents_argsstruct btrfs_file_privatestruct btrfs_item_batchfunction btrfs_root_readonlyfunction btrfs_root_deadfunction btrfs_root_idfunction btrfs_get_root_log_transidfunction btrfs_set_root_log_transidfunction btrfs_get_root_last_log_commitfunction btrfs_set_root_last_log_commitfunction btrfs_get_root_last_transfunction btrfs_set_root_last_transfunction btrfs_root_origin_generationfunction BTRFS_LEAF_DATA_SIZEfunction BTRFS_MAX_ITEM_SIZEfunction BTRFS_NODEPTRS_PER_BLOCKfunction BTRFS_MAX_XATTR_SIZEfunction btrfs_comp_keysfunction btrfs_comp_keysfunction btrfs_del_itemfunction btrfs_insert_empty_itemfunction btrfs_next_leaffunction btrfs_next_itemfunction btrfs_is_fstreefunction btrfs_is_data_reloc_root
Annotated Snippet
struct btrfs_path {
struct extent_buffer *nodes[BTRFS_MAX_LEVEL];
int slots[BTRFS_MAX_LEVEL];
/* if there is real range locking, this locks field will change */
u8 locks[BTRFS_MAX_LEVEL];
u8 reada;
u8 lowest_level;
/*
* set by btrfs_split_item, tells search_slot to keep all locks
* and to force calls to keep space in the nodes
*/
bool search_for_split:1;
/* Keep some upper locks as we walk down. */
bool keep_locks:1;
bool skip_locking:1;
bool search_commit_root:1;
bool need_commit_sem:1;
bool skip_release_on_error:1;
/*
* Indicate that new item (btrfs_search_slot) is extending already
* existing item and ins_len contains only the data size and not item
* header (ie. sizeof(struct btrfs_item) is not included).
*/
bool search_for_extension:1;
/* Stop search if any locks need to be taken (for read) */
bool nowait:1;
};
#define BTRFS_PATH_AUTO_FREE(path_name) \
struct btrfs_path *path_name __free(btrfs_free_path) = NULL
/*
* This defines an on-stack path that will be auto released when exiting the scope.
*
* It is compatible with any existing manual btrfs_release_path() calls.
*/
#define BTRFS_PATH_AUTO_RELEASE(path_name) \
struct btrfs_path path_name __free(btrfs_release_path) = { 0 }
/*
* The state of btrfs root
*/
enum {
/*
* btrfs_record_root_in_trans is a multi-step process, and it can race
* with the balancing code. But the race is very small, and only the
* first time the root is added to each transaction. So IN_TRANS_SETUP
* is used to tell us when more checks are required
*/
BTRFS_ROOT_IN_TRANS_SETUP,
/*
* Set if tree blocks of this root can be shared by other roots.
* Only subvolume trees and their reloc trees have this bit set.
* Conflicts with TRACK_DIRTY bit.
*
* This affects two things:
*
* - How balance works
* For shareable roots, we need to use reloc tree and do path
* replacement for balance, and need various pre/post hooks for
* snapshot creation to handle them.
*
* While for non-shareable trees, we just simply do a tree search
* with COW.
*
* - How dirty roots are tracked
* For shareable roots, btrfs_record_root_in_trans() is needed to
* track them, while non-subvolume roots have TRACK_DIRTY bit, they
* don't need to set this manually.
*/
BTRFS_ROOT_SHAREABLE,
BTRFS_ROOT_TRACK_DIRTY,
BTRFS_ROOT_IN_RADIX,
BTRFS_ROOT_ORPHAN_ITEM_INSERTED,
BTRFS_ROOT_DEFRAG_RUNNING,
BTRFS_ROOT_FORCE_COW,
BTRFS_ROOT_MULTI_LOG_TASKS,
BTRFS_ROOT_DIRTY,
BTRFS_ROOT_DELETING,
/*
* Reloc tree is orphan, only kept here for qgroup delayed subtree scan
*
* Set for the subvolume tree owning the reloc tree.
*/
BTRFS_ROOT_DEAD_RELOC_TREE,
/* Mark dead root stored on device whose cleanup needs to be resumed */
BTRFS_ROOT_DEAD_TREE,
Annotation
- Immediate include surface: `linux/cleanup.h`, `linux/spinlock.h`, `linux/rbtree.h`, `linux/mutex.h`, `linux/wait.h`, `linux/list.h`, `linux/atomic.h`, `linux/xarray.h`.
- Detected declarations: `struct extent_buffer`, `struct btrfs_block_rsv`, `struct btrfs_trans_handle`, `struct btrfs_block_group`, `struct btrfs_path`, `struct btrfs_qgroup_swapped_blocks`, `struct btrfs_root`, `struct btrfs_replace_extent_info`, `struct btrfs_drop_extents_args`, `struct btrfs_file_private`.
- 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.