fs/btrfs/fs.h
Source file repositories/reference/linux-study-clean/fs/btrfs/fs.h
File Facts
- System
- Linux kernel
- Corpus path
fs/btrfs/fs.h- Extension
.h- Size
- 37081 bytes
- Lines
- 1245
- 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.
- 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
crypto/blake2b.hcrypto/sha2.hlinux/blkdev.hlinux/sizes.hlinux/time64.hlinux/compiler.hlinux/math.hlinux/atomic.hlinux/percpu_counter.hlinux/completion.hlinux/lockdep.hlinux/spinlock.hlinux/mutex.hlinux/rwsem.hlinux/semaphore.hlinux/list.hlinux/pagemap.hlinux/radix-tree.hlinux/workqueue.hlinux/wait.hlinux/wait_bit.hlinux/sched.hlinux/rbtree.hlinux/xxhash.hlinux/fserror.huapi/linux/btrfs.huapi/linux/btrfs_tree.hextent-io-tree.hasync-thread.hblock-rsv.hmessages.h
Detected Declarations
struct inodestruct super_blockstruct kobjectstruct reloc_controlstruct uliststruct btrfs_devicestruct btrfs_block_groupstruct btrfs_rootstruct btrfs_fs_devicesstruct btrfs_transactionstruct btrfs_balance_controlstruct btrfs_subpage_infostruct btrfs_stripe_hash_tablestruct btrfs_space_infostruct btrfs_dev_replacestruct btrfs_free_clusterstruct btrfs_discard_ctlstruct btrfs_commit_statsstruct btrfs_delayed_rootstruct btrfs_free_space_ctlstruct btrfs_free_spacestruct btrfs_fs_infostruct btrfs_csum_ctxenum btrfs_compression_typeenum btrfs_exclusive_operationfunction btrfs_alloc_write_maskfunction btrfs_min_folio_sizefunction btrfs_get_fs_generationfunction btrfs_set_fs_generationfunction btrfs_get_last_trans_committedfunction btrfs_set_last_trans_committedfunction btrfs_set_last_root_drop_genfunction btrfs_get_last_root_drop_genfunction btrfs_csum_bytes_to_leavesfunction btrfs_calc_insert_metadata_sizefunction btrfs_calc_metadata_sizefunction count_max_extentsfunction btrfs_blocks_per_foliofunction btrfs_is_empty_uuidfunction btrfs_fs_closingfunction btrfs_fs_closing_donefunction btrfs_need_cleaner_sleepfunction btrfs_wake_unfinished_dropfunction btrfs_is_shutdownfunction btrfs_force_shutdownfunction btrfs_is_testingfunction btrfs_is_testing
Annotated Snippet
struct btrfs_dev_replace {
/* See #define above */
u64 replace_state;
/* Seconds since 1-Jan-1970 */
time64_t time_started;
/* Seconds since 1-Jan-1970 */
time64_t time_stopped;
atomic64_t num_write_errors;
atomic64_t num_uncorrectable_read_errors;
u64 cursor_left;
u64 committed_cursor_left;
u64 cursor_left_last_write_of_item;
u64 cursor_right;
/* See #define above */
u64 cont_reading_from_srcdev_mode;
int is_valid;
int item_needs_writeback;
struct btrfs_device *srcdev;
struct btrfs_device *tgtdev;
struct mutex lock_finishing_cancel_unmount;
struct rw_semaphore rwsem;
struct btrfs_scrub_progress scrub_progress;
struct percpu_counter bio_counter;
wait_queue_head_t replace_wait;
struct task_struct *replace_task;
};
/*
* Free clusters are used to claim free space in relatively large chunks,
* allowing us to do less seeky writes. They are used for all metadata
* allocations. In ssd_spread mode they are also used for data allocations.
*/
struct btrfs_free_cluster {
spinlock_t lock;
spinlock_t refill_lock;
struct rb_root root;
/* Largest extent in this cluster */
u64 max_size;
/* First extent starting offset */
u64 window_start;
/* We did a full search and couldn't create a cluster */
bool fragmented;
struct btrfs_block_group *block_group;
/*
* When a cluster is allocated from a block group, we put the cluster
* onto a list in the block group so that it can be freed before the
* block group is freed.
*/
struct list_head block_group_list;
};
/* Discard control. */
/*
* Async discard uses multiple lists to differentiate the discard filter
* parameters. Index 0 is for completely free block groups where we need to
* ensure the entire block group is trimmed without being lossy. Indices
* afterwards represent monotonically decreasing discard filter sizes to
* prioritize what should be discarded next.
*/
#define BTRFS_NR_DISCARD_LISTS 3
#define BTRFS_DISCARD_INDEX_UNUSED 0
#define BTRFS_DISCARD_INDEX_START 1
struct btrfs_discard_ctl {
struct workqueue_struct *discard_workers;
struct delayed_work work;
spinlock_t lock;
struct btrfs_block_group *block_group;
struct list_head discard_list[BTRFS_NR_DISCARD_LISTS];
u64 prev_discard;
u64 prev_discard_time;
atomic_t discardable_extents;
atomic64_t discardable_bytes;
u64 max_discard_size;
u64 delay_ms;
u32 iops_limit;
u32 kbps_limit;
u64 discard_extent_bytes;
u64 discard_bitmap_bytes;
Annotation
- Immediate include surface: `crypto/blake2b.h`, `crypto/sha2.h`, `linux/blkdev.h`, `linux/sizes.h`, `linux/time64.h`, `linux/compiler.h`, `linux/math.h`, `linux/atomic.h`.
- Detected declarations: `struct inode`, `struct super_block`, `struct kobject`, `struct reloc_control`, `struct ulist`, `struct btrfs_device`, `struct btrfs_block_group`, `struct btrfs_root`, `struct btrfs_fs_devices`, `struct btrfs_transaction`.
- 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.