fs/btrfs/extent_io.h
Source file repositories/reference/linux-study-clean/fs/btrfs/extent_io.h
File Facts
- System
- Linux kernel
- Corpus path
fs/btrfs/extent_io.h- Extension
.h- Size
- 13913 bytes
- Lines
- 426
- 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
linux/rbtree.hlinux/refcount.hlinux/fiemap.hlinux/btrfs_tree.hlinux/spinlock.hlinux/atomic.hlinux/rwsem.hlinux/list.hlinux/slab.hmessages.hulist.hmisc.h
Detected Declarations
struct pagestruct filestruct foliostruct inodestruct fiemap_extent_infostruct readahead_controlstruct address_spacestruct writeback_controlstruct extent_io_treestruct extent_map_treestruct extent_statestruct btrfs_block_groupstruct btrfs_fs_infostruct btrfs_inodestruct btrfs_rootstruct btrfs_trans_handlestruct btrfs_tree_parent_checkstruct extent_bufferstruct btrfs_eb_write_contextstruct extent_changesetfunction offset_in_eb_foliofunction get_eb_offset_in_foliofunction get_eb_folio_indexfunction extent_changeset_initfunction add_extent_changesetfunction extent_changeset_tracks_rangesfunction extent_changeset_preallocfunction extent_changeset_releasefunction extent_changeset_freefunction wait_on_extent_buffer_writebackfunction num_extent_pagesfunction num_extent_foliosfunction extent_buffer_uptodatefunction extent_buffer_under_iofunction write_extent_buffer_chunk_tree_uuidfunction write_extent_buffer_fsidfunction btrfs_clear_folio_dirty_tag
Annotated Snippet
struct extent_buffer {
u64 start;
u32 len;
u32 folio_size;
unsigned long bflags;
struct btrfs_fs_info *fs_info;
/*
* The address where the eb can be accessed without any cross-page handling.
* This can be NULL if not possible.
*/
void *addr;
spinlock_t refs_lock;
refcount_t refs;
int read_mirror;
/* Inhibit WB_SYNC_NONE writeback when > 0. */
atomic_t writeback_inhibitors;
/* >= 0 if eb belongs to a log tree, -1 otherwise */
s8 log_index;
u8 folio_shift;
struct rcu_head rcu_head;
struct rw_semaphore lock;
/*
* Pointers to all the folios of the extent buffer.
*
* For now the folio is always order 0 (aka, a single page).
*/
struct folio *folios[INLINE_EXTENT_BUFFER_PAGES];
#ifdef CONFIG_BTRFS_DEBUG
struct list_head leak_list;
pid_t lock_owner;
#endif
};
struct btrfs_eb_write_context {
struct writeback_control *wbc;
struct extent_buffer *eb;
/* Block group @eb resides in. Only used for zoned mode. */
struct btrfs_block_group *zoned_bg;
};
static inline unsigned long offset_in_eb_folio(const struct extent_buffer *eb,
u64 start)
{
ASSERT(eb->folio_size);
return start & (eb->folio_size - 1);
}
/*
* Get the correct offset inside the page of extent buffer.
*
* @eb: target extent buffer
* @start: offset inside the extent buffer
*
* Will handle both sectorsize == PAGE_SIZE and sectorsize < PAGE_SIZE cases.
*/
static inline size_t get_eb_offset_in_folio(const struct extent_buffer *eb,
unsigned long offset)
{
/*
* 1) sectorsize == PAGE_SIZE and nodesize >= PAGE_SIZE case
* 1.1) One large folio covering the whole eb
* The eb->start is aligned to folio size, thus adding it
* won't cause any difference.
* 1.2) Several page sized folios
* The eb->start is aligned to folio (page) size, thus
* adding it won't cause any difference.
*
* 2) sectorsize < PAGE_SIZE and nodesize < PAGE_SIZE case
* In this case there would only be one page sized folio, and there
* may be several different extent buffers in the page/folio.
* We need to add eb->start to properly access the offset inside
* that eb.
*/
return offset_in_folio(eb->folios[0], offset + eb->start);
}
static inline unsigned long get_eb_folio_index(const struct extent_buffer *eb,
unsigned long offset)
{
/*
* 1) sectorsize == PAGE_SIZE and nodesize >= PAGE_SIZE case
* 1.1) One large folio covering the whole eb.
* the folio_shift would be large enough to always make us
* return 0 as index.
* 1.2) Several page sized folios
* The folio_shift would be PAGE_SHIFT, giving us the correct
Annotation
- Immediate include surface: `linux/rbtree.h`, `linux/refcount.h`, `linux/fiemap.h`, `linux/btrfs_tree.h`, `linux/spinlock.h`, `linux/atomic.h`, `linux/rwsem.h`, `linux/list.h`.
- Detected declarations: `struct page`, `struct file`, `struct folio`, `struct inode`, `struct fiemap_extent_info`, `struct readahead_control`, `struct address_space`, `struct writeback_control`, `struct extent_io_tree`, `struct extent_map_tree`.
- 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.