drivers/md/dm-vdo/indexer/config.c

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

File Facts

System
Linux kernel
Corpus path
drivers/md/dm-vdo/indexer/config.c
Extension
.c
Size
13089 bytes
Lines
377
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

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright 2023 Red Hat
 */

#include "config.h"

#include "logger.h"
#include "memory-alloc.h"
#include "numeric.h"
#include "string-utils.h"
#include "thread-utils.h"

static const u8 INDEX_CONFIG_MAGIC[] = "ALBIC";
static const u8 INDEX_CONFIG_VERSION_6_02[] = "06.02";
static const u8 INDEX_CONFIG_VERSION_8_02[] = "08.02";

#define DEFAULT_VOLUME_READ_THREADS 2
#define MAX_VOLUME_READ_THREADS 16
#define INDEX_CONFIG_MAGIC_LENGTH (sizeof(INDEX_CONFIG_MAGIC) - 1)
#define INDEX_CONFIG_VERSION_LENGTH ((int)(sizeof(INDEX_CONFIG_VERSION_6_02) - 1))

static bool is_version(const u8 *version, u8 *buffer)
{
	return memcmp(version, buffer, INDEX_CONFIG_VERSION_LENGTH) == 0;
}

static bool are_matching_configurations(struct uds_configuration *saved_config,
					struct index_geometry *saved_geometry,
					struct uds_configuration *user)
{
	struct index_geometry *geometry = user->geometry;
	bool result = true;

	if (saved_geometry->record_pages_per_chapter != geometry->record_pages_per_chapter) {
		vdo_log_error("Record pages per chapter (%u) does not match (%u)",
			      saved_geometry->record_pages_per_chapter,
			      geometry->record_pages_per_chapter);
		result = false;
	}

	if (saved_geometry->chapters_per_volume != geometry->chapters_per_volume) {
		vdo_log_error("Chapter count (%u) does not match (%u)",
			      saved_geometry->chapters_per_volume,
			      geometry->chapters_per_volume);
		result = false;
	}

	if (saved_geometry->sparse_chapters_per_volume != geometry->sparse_chapters_per_volume) {
		vdo_log_error("Sparse chapter count (%u) does not match (%u)",
			      saved_geometry->sparse_chapters_per_volume,
			      geometry->sparse_chapters_per_volume);
		result = false;
	}

	if (saved_config->cache_chapters != user->cache_chapters) {
		vdo_log_error("Cache size (%u) does not match (%u)",
			      saved_config->cache_chapters, user->cache_chapters);
		result = false;
	}

	if (saved_config->volume_index_mean_delta != user->volume_index_mean_delta) {
		vdo_log_error("Volume index mean delta (%u) does not match (%u)",
			      saved_config->volume_index_mean_delta,
			      user->volume_index_mean_delta);
		result = false;
	}

	if (saved_geometry->bytes_per_page != geometry->bytes_per_page) {
		vdo_log_error("Bytes per page value (%zu) does not match (%zu)",
			      saved_geometry->bytes_per_page, geometry->bytes_per_page);
		result = false;
	}

	if (saved_config->sparse_sample_rate != user->sparse_sample_rate) {
		vdo_log_error("Sparse sample rate (%u) does not match (%u)",
			      saved_config->sparse_sample_rate,
			      user->sparse_sample_rate);
		result = false;
	}

	if (saved_config->nonce != user->nonce) {
		vdo_log_error("Nonce (%llu) does not match (%llu)",
			      (unsigned long long) saved_config->nonce,
			      (unsigned long long) user->nonce);
		result = false;
	}

	return result;
}

Annotation

Implementation Notes