drivers/md/dm-vdo/indexer/open-chapter.c
Source file repositories/reference/linux-study-clean/drivers/md/dm-vdo/indexer/open-chapter.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/md/dm-vdo/indexer/open-chapter.c- Extension
.c- Size
- 13411 bytes
- Lines
- 425
- 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
open-chapter.hlinux/log2.hlogger.hmemory-alloc.hnumeric.hpermassert.hconfig.hhash-utils.h
Detected Declarations
function records_sizefunction slots_sizefunction uds_make_open_chapterfunction uds_reset_open_chapterfunction probe_chapter_slotsfunction uds_search_open_chapterfunction uds_put_open_chapterfunction uds_remove_from_open_chapterfunction uds_free_open_chapterfunction fill_delta_chapter_indexfunction uds_close_open_chapterfunction uds_save_open_chapterfunction uds_compute_saved_open_chapter_sizefunction load_version20function uds_load_open_chapter
Annotated Snippet
if (zone->size == zone->capacity) {
fill_record = &zone->records[zone->size];
break;
}
}
records_per_chapter = index->geometry->records_per_chapter;
records_per_page = index->geometry->records_per_page;
for (records = 0; records < records_per_chapter; records++) {
struct uds_volume_record *record = &collated_records[records];
struct open_chapter_zone *open_chapter;
/* The record arrays in the zones are 1-based. */
record_index = 1 + (records / zone_count);
page_number = records / records_per_page;
open_chapter = chapter_zones[records % zone_count];
/* Use the fill record in place of an unused record. */
if (record_index > open_chapter->size ||
open_chapter->slots[record_index].deleted) {
*record = *fill_record;
continue;
}
*record = open_chapter->records[record_index];
result = uds_put_open_chapter_index_record(index, &record->name,
page_number);
switch (result) {
case UDS_SUCCESS:
break;
case UDS_OVERFLOW:
overflow_count++;
break;
default:
vdo_log_error_strerror(result,
"failed to build open chapter index");
return result;
}
}
if (overflow_count > 0)
vdo_log_warning("Failed to add %d entries to chapter index",
overflow_count);
return UDS_SUCCESS;
}
int uds_close_open_chapter(struct open_chapter_zone **chapter_zones,
unsigned int zone_count, struct volume *volume,
struct open_chapter_index *chapter_index,
struct uds_volume_record *collated_records,
u64 virtual_chapter_number)
{
int result;
uds_empty_open_chapter_index(chapter_index, virtual_chapter_number);
result = fill_delta_chapter_index(chapter_zones, zone_count, chapter_index,
collated_records);
if (result != UDS_SUCCESS)
return result;
return uds_write_chapter(volume, chapter_index, collated_records);
}
int uds_save_open_chapter(struct uds_index *index, struct buffered_writer *writer)
{
int result;
struct open_chapter_zone *open_chapter;
struct uds_volume_record *record;
u8 record_count_data[sizeof(u32)];
u32 record_count = 0;
unsigned int record_index;
unsigned int z;
result = uds_write_to_buffered_writer(writer, OPEN_CHAPTER_MAGIC,
OPEN_CHAPTER_MAGIC_LENGTH);
if (result != UDS_SUCCESS)
return result;
result = uds_write_to_buffered_writer(writer, OPEN_CHAPTER_VERSION,
OPEN_CHAPTER_VERSION_LENGTH);
if (result != UDS_SUCCESS)
return result;
for (z = 0; z < index->zone_count; z++) {
open_chapter = index->zones[z]->open_chapter;
record_count += open_chapter->size - open_chapter->deletions;
}
Annotation
- Immediate include surface: `open-chapter.h`, `linux/log2.h`, `logger.h`, `memory-alloc.h`, `numeric.h`, `permassert.h`, `config.h`, `hash-utils.h`.
- Detected declarations: `function records_size`, `function slots_size`, `function uds_make_open_chapter`, `function uds_reset_open_chapter`, `function probe_chapter_slots`, `function uds_search_open_chapter`, `function uds_put_open_chapter`, `function uds_remove_from_open_chapter`, `function uds_free_open_chapter`, `function fill_delta_chapter_index`.
- 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.