1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright 2023 Red Hat
11 #include "io-factory.h"
14 * The uds_configuration records a variety of parameters used to configure a new UDS index. Some
15 * parameters are provided by the client, while others are fixed or derived from user-supplied
16 * values. It is created when an index is created, and it is recorded in the index metadata.
20 DEFAULT_VOLUME_INDEX_MEAN_DELTA
= 4096,
21 DEFAULT_CACHE_CHAPTERS
= 7,
22 DEFAULT_SPARSE_SAMPLE_RATE
= 32,
26 /* A set of configuration parameters for the indexer. */
27 struct uds_configuration
{
28 /* Storage device for the index */
29 struct block_device
*bdev
;
31 /* The maximum allowable size of the index */
34 /* The offset where the index should start */
37 /* Parameters for the volume */
39 /* The volume layout */
40 struct index_geometry
*geometry
;
42 /* Index owner's nonce */
45 /* The number of threads used to process index requests */
46 unsigned int zone_count
;
48 /* The number of threads used to read volume pages */
49 unsigned int read_threads
;
51 /* Size of the page cache and sparse chapter index cache in chapters */
54 /* Parameters for the volume index */
56 /* The mean delta for the volume index */
57 u32 volume_index_mean_delta
;
59 /* Sampling rate for sparse indexing */
60 u32 sparse_sample_rate
;
63 /* On-disk structure of data for a version 8.02 index. */
64 struct uds_configuration_8_02
{
65 /* Smaller (16), Small (64) or large (256) indices */
66 u32 record_pages_per_chapter
;
67 /* Total number of chapters per volume */
68 u32 chapters_per_volume
;
69 /* Number of sparse chapters per volume */
70 u32 sparse_chapters_per_volume
;
71 /* Size of the page cache, in chapters */
75 /* The volume index mean delta to use */
76 u32 volume_index_mean_delta
;
77 /* Size of a page, used for both record pages and index pages */
79 /* Sampling rate for sparse indexing */
80 u32 sparse_sample_rate
;
81 /* Index owner's nonce */
83 /* Virtual chapter remapped from physical chapter 0 */
85 /* New physical chapter which remapped chapter was moved to */
86 u64 remapped_physical
;
89 /* On-disk structure of data for a version 6.02 index. */
90 struct uds_configuration_6_02
{
91 /* Smaller (16), Small (64) or large (256) indices */
92 u32 record_pages_per_chapter
;
93 /* Total number of chapters per volume */
94 u32 chapters_per_volume
;
95 /* Number of sparse chapters per volume */
96 u32 sparse_chapters_per_volume
;
97 /* Size of the page cache, in chapters */
101 /* The volume index mean delta to use */
102 u32 volume_index_mean_delta
;
103 /* Size of a page, used for both record pages and index pages */
105 /* Sampling rate for sparse indexing */
106 u32 sparse_sample_rate
;
107 /* Index owner's nonce */
111 int __must_check
uds_make_configuration(const struct uds_parameters
*params
,
112 struct uds_configuration
**config_ptr
);
114 void uds_free_configuration(struct uds_configuration
*config
);
116 int __must_check
uds_validate_config_contents(struct buffered_reader
*reader
,
117 struct uds_configuration
*config
);
119 int __must_check
uds_write_config_contents(struct buffered_writer
*writer
,
120 struct uds_configuration
*config
, u32 version
);
122 void uds_log_configuration(struct uds_configuration
*config
);
124 #endif /* UDS_CONFIG_H */