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.

Dependency Surface

Detected Declarations

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

Implementation Notes