fs/btrfs/free-space-cache.h
Source file repositories/reference/linux-study-clean/fs/btrfs/free-space-cache.h
File Facts
- System
- Linux kernel
- Corpus path
fs/btrfs/free-space-cache.h- Extension
.h- Size
- 5813 bytes
- Lines
- 175
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/rbtree.hlinux/list.hlinux/spinlock.hlinux/mutex.hlinux/freezer.hfs.h
Detected Declarations
struct inodestruct pagestruct btrfs_fs_infostruct btrfs_pathstruct btrfs_trans_handlestruct btrfs_trim_block_groupstruct btrfs_free_spacestruct btrfs_free_space_ctlstruct btrfs_io_ctlenum btrfs_trim_statefunction btrfs_free_space_trimmedfunction btrfs_free_space_trimming_bitmapfunction btrfs_trim_interrupted
Annotated Snippet
struct btrfs_free_space {
struct rb_node offset_index;
struct rb_node bytes_index;
u64 offset;
u64 bytes;
u64 max_extent_size;
unsigned long *bitmap;
struct list_head list;
enum btrfs_trim_state trim_state;
s32 bitmap_extents;
};
static inline bool btrfs_free_space_trimmed(struct btrfs_free_space *info)
{
return (info->trim_state == BTRFS_TRIM_STATE_TRIMMED);
}
static inline bool btrfs_free_space_trimming_bitmap(
struct btrfs_free_space *info)
{
return (info->trim_state == BTRFS_TRIM_STATE_TRIMMING);
}
static inline bool btrfs_trim_interrupted(void)
{
return fatal_signal_pending(current) || freezing(current);
}
/*
* Deltas are an effective way to populate global statistics. Give macro names
* to make it clear what we're doing. An example is discard_extents in
* btrfs_free_space_ctl.
*/
enum {
BTRFS_STAT_CURR,
BTRFS_STAT_PREV,
BTRFS_STAT_NR_ENTRIES,
};
struct btrfs_free_space_ctl {
struct rb_root free_space_offset;
struct rb_root_cached free_space_bytes;
spinlock_t tree_lock;
int extents_thresh;
int free_extents;
int total_bitmaps;
u64 free_space;
s32 discardable_extents[BTRFS_STAT_NR_ENTRIES];
s64 discardable_bytes[BTRFS_STAT_NR_ENTRIES];
struct btrfs_block_group *block_group;
struct mutex cache_writeout_mutex;
struct list_head trimming_ranges;
};
struct btrfs_io_ctl {
void *cur, *orig;
struct page *page;
struct page **pages;
struct btrfs_fs_info *fs_info;
struct inode *inode;
unsigned long size;
int index;
int num_pages;
int entries;
int bitmaps;
};
int __init btrfs_free_space_init(void);
void __cold btrfs_free_space_exit(void);
struct inode *lookup_free_space_inode(struct btrfs_block_group *block_group,
struct btrfs_path *path);
int create_free_space_inode(struct btrfs_trans_handle *trans,
struct btrfs_block_group *block_group,
struct btrfs_path *path);
int btrfs_remove_free_space_inode(struct btrfs_trans_handle *trans,
struct inode *inode,
struct btrfs_block_group *block_group);
int btrfs_truncate_free_space_cache(struct btrfs_trans_handle *trans,
struct btrfs_block_group *block_group,
struct inode *inode);
int load_free_space_cache(struct btrfs_block_group *block_group);
int btrfs_wait_cache_io(struct btrfs_trans_handle *trans,
struct btrfs_block_group *block_group,
struct btrfs_path *path);
int btrfs_write_out_cache(struct btrfs_trans_handle *trans,
struct btrfs_block_group *block_group,
struct btrfs_path *path);
void btrfs_init_free_space_ctl(struct btrfs_block_group *block_group,
Annotation
- Immediate include surface: `linux/rbtree.h`, `linux/list.h`, `linux/spinlock.h`, `linux/mutex.h`, `linux/freezer.h`, `fs.h`.
- Detected declarations: `struct inode`, `struct page`, `struct btrfs_fs_info`, `struct btrfs_path`, `struct btrfs_trans_handle`, `struct btrfs_trim_block_group`, `struct btrfs_free_space`, `struct btrfs_free_space_ctl`, `struct btrfs_io_ctl`, `enum btrfs_trim_state`.
- 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.