drivers/md/dm-vdo/indexer/delta-index.c
Source file repositories/reference/linux-study-clean/drivers/md/dm-vdo/indexer/delta-index.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/md/dm-vdo/indexer/delta-index.c- Extension
.c- Size
- 64041 bytes
- Lines
- 1968
- 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
delta-index.hlinux/bitops.hlinux/bits.hlinux/compiler.hlinux/limits.hlinux/log2.hcpu.herrors.hlogger.hmemory-alloc.hnumeric.hpermassert.hstring-utils.htime-utils.hconfig.hindexer.h
Detected Declarations
struct delta_index_headerstruct delta_page_headerfunction get_delta_list_byte_startfunction get_delta_list_byte_sizefunction rebalance_delta_zonefunction get_zone_memory_sizefunction uds_reset_delta_indexfunction compute_coding_constantsfunction uds_uninitialize_delta_indexfunction initialize_delta_zonefunction uds_initialize_delta_indexfunction get_fieldfunction set_fieldfunction get_immutable_header_offsetfunction get_immutable_startfunction set_immutable_startfunction verify_delta_index_pagefunction uds_initialize_delta_index_pagefunction get_big_fieldfunction set_big_fieldfunction set_zerofunction move_bits_downfunction move_bits_upfunction move_bitsfunction listsfunction compute_new_list_offsetsfunction rebalance_listsfunction uds_start_restoring_delta_indexfunction restore_delta_list_to_zonefunction restore_delta_list_datafunction uds_finish_restoring_delta_indexfunction uds_check_guard_delta_listsfunction flush_delta_listfunction uds_start_saving_delta_indexfunction uds_finish_saving_delta_indexfunction uds_write_guard_delta_listfunction uds_compute_delta_index_save_bytesfunction assert_not_at_endfunction uds_next_delta_index_entryfunction get_delta_entry_offsetfunction decode_deltafunction uds_next_delta_index_entryfunction uds_remember_delta_index_offsetfunction set_deltafunction get_collision_namefunction set_collision_namefunction uds_get_delta_index_entryfunction uds_get_delta_entry_collision
Annotated Snippet
struct delta_index_header {
char magic[MAGIC_SIZE];
u32 zone_number;
u32 zone_count;
u32 first_list;
u32 list_count;
u64 record_count;
u64 collision_count;
};
/*
* Header data used for immutable delta index pages. This data is followed by the delta list offset
* table.
*/
struct delta_page_header {
/* Externally-defined nonce */
u64 nonce;
/* The virtual chapter number */
u64 virtual_chapter_number;
/* Index of the first delta list on the page */
u16 first_list;
/* Number of delta lists on the page */
u16 list_count;
} __packed;
static inline u64 get_delta_list_byte_start(const struct delta_list *delta_list)
{
return delta_list->start / BITS_PER_BYTE;
}
static inline u16 get_delta_list_byte_size(const struct delta_list *delta_list)
{
unsigned int bit_offset = delta_list->start % BITS_PER_BYTE;
return BITS_TO_BYTES(bit_offset + delta_list->size);
}
static void rebalance_delta_zone(const struct delta_zone *delta_zone, u32 first,
u32 last)
{
struct delta_list *delta_list;
u64 new_start;
if (first == last) {
/* Only one list is moving, and we know there is space. */
delta_list = &delta_zone->delta_lists[first];
new_start = delta_zone->new_offsets[first];
if (delta_list->start != new_start) {
u64 source;
u64 destination;
source = get_delta_list_byte_start(delta_list);
delta_list->start = new_start;
destination = get_delta_list_byte_start(delta_list);
memmove(delta_zone->memory + destination,
delta_zone->memory + source,
get_delta_list_byte_size(delta_list));
}
} else {
/*
* There is more than one list. Divide the problem in half, and use recursive calls
* to process each half. Note that after this computation, first <= middle, and
* middle < last.
*/
u32 middle = (first + last) / 2;
delta_list = &delta_zone->delta_lists[middle];
new_start = delta_zone->new_offsets[middle];
/*
* The direction that our middle list is moving determines which half of the
* problem must be processed first.
*/
if (new_start > delta_list->start) {
rebalance_delta_zone(delta_zone, middle + 1, last);
rebalance_delta_zone(delta_zone, first, middle);
} else {
rebalance_delta_zone(delta_zone, first, middle);
rebalance_delta_zone(delta_zone, middle + 1, last);
}
}
}
static inline size_t get_zone_memory_size(unsigned int zone_count, size_t memory_size)
{
/* Round up so that each zone is a multiple of 64K in size. */
size_t ALLOC_BOUNDARY = 64 * 1024;
return (memory_size / zone_count + ALLOC_BOUNDARY - 1) & -ALLOC_BOUNDARY;
}
Annotation
- Immediate include surface: `delta-index.h`, `linux/bitops.h`, `linux/bits.h`, `linux/compiler.h`, `linux/limits.h`, `linux/log2.h`, `cpu.h`, `errors.h`.
- Detected declarations: `struct delta_index_header`, `struct delta_page_header`, `function get_delta_list_byte_start`, `function get_delta_list_byte_size`, `function rebalance_delta_zone`, `function get_zone_memory_size`, `function uds_reset_delta_index`, `function compute_coding_constants`, `function uds_uninitialize_delta_index`, `function initialize_delta_zone`.
- 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.