fs/btrfs/block-group.h
Source file repositories/reference/linux-study-clean/fs/btrfs/block-group.h
File Facts
- System
- Linux kernel
- Corpus path
fs/btrfs/block-group.h- Extension
.h- Size
- 14224 bytes
- Lines
- 428
- 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/atomic.hlinux/mutex.hlinux/list.hlinux/spinlock.hlinux/refcount.hlinux/wait.hlinux/sizes.hlinux/rwsem.hlinux/rbtree.huapi/linux/btrfs_tree.hfree-space-cache.h
Detected Declarations
struct btrfs_chunk_mapstruct btrfs_fs_infostruct btrfs_inodestruct btrfs_trans_handlestruct btrfs_caching_controlstruct btrfs_block_groupenum btrfs_disk_cache_stateenum btrfs_block_group_size_classenum btrfs_discard_stateenum btrfs_chunk_alloc_enumenum btrfs_block_group_flagsenum btrfs_caching_typefunction btrfs_block_group_endfunction btrfs_is_block_group_usedfunction btrfs_is_block_group_data_onlyfunction btrfs_block_group_available_spacefunction btrfs_data_alloc_profilefunction btrfs_metadata_alloc_profilefunction btrfs_system_alloc_profilefunction btrfs_block_group_done
Annotated Snippet
struct btrfs_caching_control {
struct list_head list;
struct mutex mutex;
wait_queue_head_t wait;
struct btrfs_work work;
struct btrfs_block_group *block_group;
/* Track progress of caching during allocation. */
atomic_t progress;
refcount_t count;
};
/* Once caching_thread() finds this much free space, it will wake up waiters. */
#define CACHING_CTL_WAKE_UP SZ_2M
struct btrfs_block_group {
struct btrfs_fs_info *fs_info;
struct btrfs_inode *inode;
spinlock_t lock;
unsigned int ro;
u64 start;
u64 length;
u64 pinned;
u64 reserved;
u64 used;
u64 delalloc_bytes;
u64 bytes_super;
u64 flags;
u64 cache_generation;
u64 global_root_id;
u64 remap_bytes;
u32 identity_remap_count;
/* The last commited identity_remap_count value of this block group. */
u32 last_identity_remap_count;
/*
* The last committed used bytes of this block group, if the above @used
* is still the same as @last_used, we don't need to update block
* group item of this block group.
*/
u64 last_used;
/* The last committed remap_bytes value of this block group. */
u64 last_remap_bytes;
/* The last committed flags value for this block group. */
u64 last_flags;
/*
* If the free space extent count exceeds this number, convert the block
* group to bitmaps.
*/
u32 bitmap_high_thresh;
/*
* If the free space extent count drops below this number, convert the
* block group back to extents.
*/
u32 bitmap_low_thresh;
/*
* It is just used for the delayed data space allocation because
* only the data space allocation and the relative metadata update
* can be done cross the transaction.
*/
struct rw_semaphore data_rwsem;
/* For raid56, this is a full stripe, without parity */
unsigned long full_stripe_len;
unsigned long runtime_flags;
enum btrfs_disk_cache_state disk_cache_state;
/* Cache tracking stuff */
enum btrfs_caching_type cached;
struct btrfs_caching_control *caching_ctl;
struct btrfs_space_info *space_info;
/* Free space cache stuff */
struct btrfs_free_space_ctl *free_space_ctl;
/* Block group cache stuff */
struct rb_node cache_node;
/* For block groups in the same raid type */
struct list_head list;
refcount_t refs;
/*
* When non-zero it means the block group's logical address and its
* device extents can not be reused for future block group allocations
* until the counter goes down to 0. This is to prevent them from being
Annotation
- Immediate include surface: `linux/atomic.h`, `linux/mutex.h`, `linux/list.h`, `linux/spinlock.h`, `linux/refcount.h`, `linux/wait.h`, `linux/sizes.h`, `linux/rwsem.h`.
- Detected declarations: `struct btrfs_chunk_map`, `struct btrfs_fs_info`, `struct btrfs_inode`, `struct btrfs_trans_handle`, `struct btrfs_caching_control`, `struct btrfs_block_group`, `enum btrfs_disk_cache_state`, `enum btrfs_block_group_size_class`, `enum btrfs_discard_state`, `enum btrfs_chunk_alloc_enum`.
- 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.