drivers/md/dm-vdo/indexer/volume.c
Source file repositories/reference/linux-study-clean/drivers/md/dm-vdo/indexer/volume.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/md/dm-vdo/indexer/volume.c- Extension
.c- Size
- 54928 bytes
- Lines
- 1692
- 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.
- 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
volume.hlinux/atomic.hlinux/dm-bufio.hlinux/err.herrors.hlogger.hmemory-alloc.hpermassert.hstring-utils.hthread-utils.hchapter-index.hconfig.hgeometry.hhash-utils.hindex.hsparse-cache.h
Detected Declarations
function map_to_page_numberfunction map_to_chapter_numberfunction is_record_pagefunction map_to_physical_pagefunction get_invalidate_counterfunction set_invalidate_counterfunction search_pendingfunction begin_pending_searchfunction end_pending_searchfunction wait_for_pending_searchesfunction release_page_bufferfunction clear_cache_pagefunction make_page_most_recentfunction put_page_in_cachefunction cancel_page_in_cachefunction next_queue_positionfunction advance_queue_positionfunction read_queue_is_fullfunction enqueue_readfunction enqueue_page_readfunction release_queued_requestsfunction init_chapter_index_pagefunction initialize_index_pagefunction search_record_pagefunction get_record_from_zonefunction process_entryfunction release_queued_requestsfunction read_thread_functionfunction get_page_and_indexfunction get_page_from_cachefunction read_page_lockedfunction get_volume_page_lockedfunction get_volume_page_protectedfunction get_volume_pagefunction uds_get_volume_record_pagefunction uds_get_volume_index_pagefunction search_cached_index_pagefunction uds_search_cached_record_pagefunction uds_prefetch_volume_chapterfunction uds_read_chapter_index_from_volumefunction uds_search_volume_page_cachefunction uds_search_volume_page_cache_for_rebuildfunction invalidate_pagefunction uds_forget_chapterfunction donate_index_page_lockedfunction write_index_pagesfunction encode_treefunction encode_record_page
Annotated Snippet
if (last_used <= oldest_time) {
oldest_time = last_used;
oldest_index = i;
}
}
page = &cache->cache[oldest_index];
if (page->physical_page != cache->indexable_pages) {
WRITE_ONCE(cache->index[page->physical_page], cache->cache_slots);
wait_for_pending_searches(cache, page->physical_page);
}
page->read_pending = true;
clear_cache_page(cache, page);
return page;
}
/* Make a newly filled cache entry available to other threads. */
static int put_page_in_cache(struct page_cache *cache, u32 physical_page,
struct cached_page *page)
{
int result;
/* We hold the read_threads_mutex. */
result = VDO_ASSERT((page->read_pending), "page to install has a pending read");
if (result != VDO_SUCCESS)
return result;
page->physical_page = physical_page;
make_page_most_recent(cache, page);
page->read_pending = false;
/*
* We hold the read_threads_mutex, but we must have a write memory barrier before making
* the cached_page available to the readers that do not hold the mutex. The corresponding
* read memory barrier is in get_page_and_index().
*/
smp_wmb();
/* This assignment also clears the queued flag. */
WRITE_ONCE(cache->index[physical_page], page - cache->cache);
return UDS_SUCCESS;
}
static void cancel_page_in_cache(struct page_cache *cache, u32 physical_page,
struct cached_page *page)
{
int result;
/* We hold the read_threads_mutex. */
result = VDO_ASSERT((page->read_pending), "page to install has a pending read");
if (result != VDO_SUCCESS)
return;
clear_cache_page(cache, page);
page->read_pending = false;
/* Clear the mapping and the queued flag for the new page. */
WRITE_ONCE(cache->index[physical_page], cache->cache_slots);
}
static inline u16 next_queue_position(u16 position)
{
return (position + 1) % VOLUME_CACHE_MAX_QUEUED_READS;
}
static inline void advance_queue_position(u16 *position)
{
*position = next_queue_position(*position);
}
static inline bool read_queue_is_full(struct page_cache *cache)
{
return cache->read_queue_first == next_queue_position(cache->read_queue_last);
}
static bool enqueue_read(struct page_cache *cache, struct uds_request *request,
u32 physical_page)
{
struct queued_read *queue_entry;
u16 last = cache->read_queue_last;
u16 read_queue_index;
/* We hold the read_threads_mutex. */
if ((cache->index[physical_page] & VOLUME_CACHE_QUEUED_FLAG) == 0) {
/* This page has no existing entry in the queue. */
if (read_queue_is_full(cache))
return false;
/* Fill in the read queue entry. */
Annotation
- Immediate include surface: `volume.h`, `linux/atomic.h`, `linux/dm-bufio.h`, `linux/err.h`, `errors.h`, `logger.h`, `memory-alloc.h`, `permassert.h`.
- Detected declarations: `function map_to_page_number`, `function map_to_chapter_number`, `function is_record_page`, `function map_to_physical_page`, `function get_invalidate_counter`, `function set_invalidate_counter`, `function search_pending`, `function begin_pending_search`, `function end_pending_search`, `function wait_for_pending_searches`.
- Atlas domain: Driver Families / drivers/md.
- 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.