drivers/md/dm-vdo/indexer/volume-index.c

Source file repositories/reference/linux-study-clean/drivers/md/dm-vdo/indexer/volume-index.c

File Facts

System
Linux kernel
Corpus path
drivers/md/dm-vdo/indexer/volume-index.c
Extension
.c
Size
43587 bytes
Lines
1282
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

struct sub_index_parameters {
	/* The number of bits in address mask */
	u8 address_bits;
	/* The number of bits in chapter number */
	u8 chapter_bits;
	/* The mean delta */
	u32 mean_delta;
	/* The number of delta lists */
	u64 list_count;
	/* The number of chapters used */
	u32 chapter_count;
	/* The number of bits per chapter */
	size_t chapter_size_in_bits;
	/* The number of bytes of delta list memory */
	size_t memory_size;
	/* The number of bytes the index should keep free at all times */
	size_t target_free_bytes;
};

struct split_config {
	/* The hook subindex configuration */
	struct uds_configuration hook_config;
	struct index_geometry hook_geometry;

	/* The non-hook subindex configuration */
	struct uds_configuration non_hook_config;
	struct index_geometry non_hook_geometry;
};

struct chapter_range {
	u32 chapter_start;
	u32 chapter_count;
};

#define MAGIC_SIZE 8

static const char MAGIC_START_5[] = "MI5-0005";

struct sub_index_data {
	char magic[MAGIC_SIZE]; /* MAGIC_START_5 */
	u64 volume_nonce;
	u64 virtual_chapter_low;
	u64 virtual_chapter_high;
	u32 first_list;
	u32 list_count;
};

static const char MAGIC_START_6[] = "MI6-0001";

struct volume_index_data {
	char magic[MAGIC_SIZE]; /* MAGIC_START_6 */
	u32 sparse_sample_rate;
};

static inline u32 extract_address(const struct volume_sub_index *sub_index,
				  const struct uds_record_name *name)
{
	return uds_extract_volume_index_bytes(name) & sub_index->address_mask;
}

static inline u32 extract_dlist_num(const struct volume_sub_index *sub_index,
				    const struct uds_record_name *name)
{
	u64 bits = uds_extract_volume_index_bytes(name);

	return (bits >> sub_index->address_bits) % sub_index->list_count;
}

static inline const struct volume_sub_index_zone *
get_zone_for_record(const struct volume_index_record *record)
{
	return &record->sub_index->zones[record->zone_number];
}

static inline u64 convert_index_to_virtual(const struct volume_index_record *record,
					   u32 index_chapter)
{
	const struct volume_sub_index_zone *volume_index_zone = get_zone_for_record(record);
	u32 rolling_chapter = ((index_chapter - volume_index_zone->virtual_chapter_low) &
			       record->sub_index->chapter_mask);

	return volume_index_zone->virtual_chapter_low + rolling_chapter;
}

static inline u32 convert_virtual_to_index(const struct volume_sub_index *sub_index,
					   u64 virtual_chapter)
{
	return virtual_chapter & sub_index->chapter_mask;
}

Annotation

Implementation Notes