drivers/md/dm-vdo/block-map.c
Source file repositories/reference/linux-study-clean/drivers/md/dm-vdo/block-map.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/md/dm-vdo/block-map.c- Extension
.c- Size
- 101451 bytes
- Lines
- 3339
- Domain
- Driver Families
- Bucket
- drivers/md
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
block-map.hlinux/bio.hlinux/ratelimit.herrors.hlogger.hmemory-alloc.hpermassert.haction-manager.hadmin-state.hcompletion.hconstants.hdata-vio.hencodings.hio-submitter.hphysical-zone.hrecovery-journal.hslab-depot.hstatus-codes.htypes.hvdo.hvio.hwait-queue.h
Detected Declarations
struct page_descriptorstruct write_if_not_dirtied_contextstruct block_map_tree_segmentstruct block_map_treestruct foreststruct cursor_levelstruct cursorsstruct cursorstruct cursorsfunction is_dirtyfunction is_presentfunction is_in_flightfunction is_incomingfunction is_outgoingfunction is_validfunction initialize_infofunction allocate_cache_componentsfunction assert_on_cache_threadfunction assert_io_allowedfunction report_cache_pressurefunction get_page_state_namefunction update_counterfunction update_lrufunction set_info_statefunction set_info_pbnfunction reset_page_infofunction find_free_pagefunction find_pagefunction select_lru_pagefunction complete_with_pagefunction complete_waiter_with_errorfunction complete_waiter_with_pagefunction distribute_page_over_waitqfunction set_persistent_errorfunction validate_completed_pagefunction check_for_drain_completefunction enter_zone_read_only_modefunction validate_completed_page_or_enter_read_only_modefunction handle_load_errorfunction page_is_loadedfunction handle_rebuild_read_errorfunction load_cache_page_endiofunction launch_page_loadfunction handle_flush_errorfunction flush_endiofunction save_pagesfunction schedule_page_savefunction launch_page_save
Annotated Snippet
struct page_descriptor {
root_count_t root_index;
height_t height;
page_number_t page_index;
slot_number_t slot;
} __packed;
union page_key {
struct page_descriptor descriptor;
u64 key;
};
struct write_if_not_dirtied_context {
struct block_map_zone *zone;
u8 generation;
};
struct block_map_tree_segment {
struct tree_page *levels[VDO_BLOCK_MAP_TREE_HEIGHT];
};
struct block_map_tree {
struct block_map_tree_segment *segments;
};
struct forest {
struct block_map *map;
size_t segments;
struct boundary *boundaries;
struct tree_page **pages;
struct block_map_tree trees[];
};
struct cursor_level {
page_number_t page_index;
slot_number_t slot;
};
struct cursors;
struct cursor {
struct vdo_waiter waiter;
struct block_map_tree *tree;
height_t height;
struct cursors *parent;
struct boundary boundary;
struct cursor_level levels[VDO_BLOCK_MAP_TREE_HEIGHT];
struct pooled_vio *vio;
};
struct cursors {
struct block_map_zone *zone;
struct vio_pool *pool;
vdo_entry_callback_fn entry_callback;
struct vdo_completion *completion;
root_count_t active_roots;
struct cursor cursors[];
};
static const physical_block_number_t NO_PAGE = 0xFFFFFFFFFFFFFFFF;
/* Used to indicate that the page holding the location of a tree root has been "loaded". */
static const physical_block_number_t VDO_INVALID_PBN = 0xFFFFFFFFFFFFFFFF;
const struct block_map_entry UNMAPPED_BLOCK_MAP_ENTRY = {
.mapping_state = VDO_MAPPING_STATE_UNMAPPED & 0x0F,
.pbn_high_nibble = 0,
.pbn_low_word = __cpu_to_le32(VDO_ZERO_BLOCK & UINT_MAX),
};
#define LOG_INTERVAL 4000
#define DISPLAY_INTERVAL 100000
/*
* For adjusting VDO page cache statistic fields which are only mutated on the logical zone thread.
* Prevents any compiler shenanigans from affecting other threads reading those stats.
*/
#define ADD_ONCE(value, delta) WRITE_ONCE(value, (value) + (delta))
static inline bool is_dirty(const struct page_info *info)
{
return info->state == PS_DIRTY;
}
static inline bool is_present(const struct page_info *info)
{
return (info->state == PS_RESIDENT) || (info->state == PS_DIRTY);
}
static inline bool is_in_flight(const struct page_info *info)
Annotation
- Immediate include surface: `block-map.h`, `linux/bio.h`, `linux/ratelimit.h`, `errors.h`, `logger.h`, `memory-alloc.h`, `permassert.h`, `action-manager.h`.
- Detected declarations: `struct page_descriptor`, `struct write_if_not_dirtied_context`, `struct block_map_tree_segment`, `struct block_map_tree`, `struct forest`, `struct cursor_level`, `struct cursors`, `struct cursor`, `struct cursors`, `function is_dirty`.
- Atlas domain: Driver Families / drivers/md.
- 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.