drivers/md/dm-vdo/indexer/chapter-index.c
Source file repositories/reference/linux-study-clean/drivers/md/dm-vdo/indexer/chapter-index.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/md/dm-vdo/indexer/chapter-index.c- Extension
.c- Size
- 9255 bytes
- Lines
- 294
- 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
chapter-index.herrors.hlogger.hmemory-alloc.hpermassert.hhash-utils.hindexer.h
Detected Declarations
function uds_make_open_chapter_indexfunction uds_free_open_chapter_indexfunction uds_empty_open_chapter_indexfunction was_entry_foundfunction uds_put_open_chapter_index_recordfunction uds_pack_open_chapter_index_pagefunction uds_initialize_chapter_index_pagefunction uds_validate_chapter_index_pagefunction uds_search_chapter_index_page
Annotated Snippet
if ((first_list + *lists_packed) == list_count) {
/* All lists are packed. */
break;
} else if (*lists_packed == 0) {
/*
* The next delta list does not fit on a page. This delta list will be
* removed.
*/
} else if (last_page) {
/*
* This is the last page and there are lists left unpacked, but all of the
* remaining lists must fit on the page. Find a list that contains entries
* and remove the entire list. Try the first list that does not fit. If it
* is empty, we will select the last list that already fits and has any
* entries.
*/
} else {
/* This page is done. */
break;
}
if (removals == 0) {
uds_get_delta_index_stats(delta_index, &stats);
vdo_log_warning("The chapter index for chapter %llu contains %llu entries with %llu collisions",
(unsigned long long) chapter_number,
(unsigned long long) stats.record_count,
(unsigned long long) stats.collision_count);
}
list_number = *lists_packed;
do {
if (list_number < 0)
return UDS_OVERFLOW;
next_list = first_list + list_number--;
result = uds_start_delta_index_search(delta_index, next_list, 0,
&entry);
if (result != UDS_SUCCESS)
return result;
result = uds_next_delta_index_entry(&entry);
if (result != UDS_SUCCESS)
return result;
} while (entry.at_end);
do {
result = uds_remove_delta_index_entry(&entry);
if (result != UDS_SUCCESS)
return result;
removals++;
} while (!entry.at_end);
}
if (removals > 0) {
vdo_log_warning("To avoid chapter index page overflow in chapter %llu, %u entries were removed from the chapter index",
(unsigned long long) chapter_number, removals);
}
return UDS_SUCCESS;
}
/* Make a new chapter index page, initializing it with the data from a given index_page buffer. */
int uds_initialize_chapter_index_page(struct delta_index_page *index_page,
const struct index_geometry *geometry,
u8 *page_buffer, u64 volume_nonce)
{
return uds_initialize_delta_index_page(index_page, volume_nonce,
geometry->chapter_mean_delta,
geometry->chapter_payload_bits,
page_buffer, geometry->bytes_per_page);
}
/* Validate a chapter index page read during rebuild. */
int uds_validate_chapter_index_page(const struct delta_index_page *index_page,
const struct index_geometry *geometry)
{
int result;
const struct delta_index *delta_index = &index_page->delta_index;
u32 first = index_page->lowest_list_number;
u32 last = index_page->highest_list_number;
u32 list_number;
/* We walk every delta list from start to finish. */
for (list_number = first; list_number <= last; list_number++) {
struct delta_index_entry entry;
result = uds_start_delta_index_search(delta_index, list_number - first,
0, &entry);
if (result != UDS_SUCCESS)
Annotation
- Immediate include surface: `chapter-index.h`, `errors.h`, `logger.h`, `memory-alloc.h`, `permassert.h`, `hash-utils.h`, `indexer.h`.
- Detected declarations: `function uds_make_open_chapter_index`, `function uds_free_open_chapter_index`, `function uds_empty_open_chapter_index`, `function was_entry_found`, `function uds_put_open_chapter_index_record`, `function uds_pack_open_chapter_index_page`, `function uds_initialize_chapter_index_page`, `function uds_validate_chapter_index_page`, `function uds_search_chapter_index_page`.
- 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.