Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

dm vdo: add geometry block initialization to encodings.c

Add vdo_initialize_volume_geometry() to populate the geometry block,
computing the space required for the two main regions on disk.

Add uds_compute_index_size() to calculate the space required for the
UDS indexer from the UDS configuration.

Signed-off-by: Bruce Johnston <bjohnsto@redhat.com>
Reviewed-by: Matthew Sakai <msakai@redhat.com>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>

authored by

Bruce Johnston and committed by
Mikulas Patocka
4b4a8d95 0be6c2b1

+103
+69
drivers/md/dm-vdo/encodings.c
··· 12 12 #include "permassert.h" 13 13 14 14 #include "constants.h" 15 + #include "indexer.h" 15 16 #include "status-codes.h" 16 17 #include "types.h" 17 18 ··· 1486 1485 return result; 1487 1486 1488 1487 return ((checksum != saved_checksum) ? VDO_CHECKSUM_MISMATCH : VDO_SUCCESS); 1488 + } 1489 + 1490 + /** 1491 + * vdo_compute_index_blocks() - Compute the number of blocks that the indexer will use. 1492 + * @config: The index config from which the blocks are calculated. 1493 + * @index_blocks_ptr: The number of blocks the index will use. 1494 + * 1495 + * Return: VDO_SUCCESS or an error code. 1496 + */ 1497 + static int vdo_compute_index_blocks(const struct index_config *config, 1498 + block_count_t *index_blocks_ptr) 1499 + { 1500 + int result; 1501 + u64 index_bytes; 1502 + struct uds_parameters uds_parameters = { 1503 + .memory_size = config->mem, 1504 + .sparse = config->sparse, 1505 + }; 1506 + 1507 + result = uds_compute_index_size(&uds_parameters, &index_bytes); 1508 + if (result != UDS_SUCCESS) 1509 + return vdo_log_error_strerror(result, "error computing index size"); 1510 + 1511 + *index_blocks_ptr = index_bytes / VDO_BLOCK_SIZE; 1512 + return VDO_SUCCESS; 1513 + } 1514 + 1515 + /** 1516 + * vdo_initialize_volume_geometry() - Initialize the volume geometry so it can be written out. 1517 + * @nonce: The nonce to use to identify the vdo. 1518 + * @uuid: The uuid to use to identify the vdo. 1519 + * @index_config: The config used for structure initialization. 1520 + * @geometry: The volume geometry to initialize. 1521 + * 1522 + * Return: VDO_SUCCESS or an error code. 1523 + */ 1524 + int vdo_initialize_volume_geometry(nonce_t nonce, uuid_t *uuid, 1525 + const struct index_config *index_config, 1526 + struct volume_geometry *geometry) 1527 + { 1528 + int result; 1529 + block_count_t index_blocks = 0; 1530 + 1531 + result = vdo_compute_index_blocks(index_config, &index_blocks); 1532 + if (result != VDO_SUCCESS) 1533 + return result; 1534 + 1535 + *geometry = (struct volume_geometry) { 1536 + /* This is for backwards compatibility. */ 1537 + .unused = 0, 1538 + .nonce = nonce, 1539 + .bio_offset = 0, 1540 + .regions = { 1541 + [VDO_INDEX_REGION] = { 1542 + .id = VDO_INDEX_REGION, 1543 + .start_block = 1, 1544 + }, 1545 + [VDO_DATA_REGION] = { 1546 + .id = VDO_DATA_REGION, 1547 + .start_block = 1 + index_blocks, 1548 + } 1549 + } 1550 + }; 1551 + 1552 + memcpy(&(geometry->uuid), uuid, sizeof(uuid_t)); 1553 + memcpy(&geometry->index_config, index_config, sizeof(struct index_config)); 1554 + 1555 + return VDO_SUCCESS; 1489 1556 }
+4
drivers/md/dm-vdo/encodings.h
··· 803 803 vdo_get_index_region_start(geometry); 804 804 } 805 805 806 + int vdo_initialize_volume_geometry(nonce_t nonce, uuid_t *uuid, 807 + const struct index_config *index_config, 808 + struct volume_geometry *geometry); 809 + 806 810 int __must_check vdo_parse_geometry_block(unsigned char *block, 807 811 struct volume_geometry *geometry); 808 812
+26
drivers/md/dm-vdo/indexer/index-layout.c
··· 249 249 return UDS_SUCCESS; 250 250 } 251 251 252 + int uds_compute_index_size(const struct uds_parameters *parameters, u64 *index_size) 253 + { 254 + int result; 255 + struct uds_configuration *index_config; 256 + struct save_layout_sizes sizes; 257 + 258 + if (index_size == NULL) { 259 + vdo_log_error("Missing output size pointer"); 260 + return -EINVAL; 261 + } 262 + 263 + result = uds_make_configuration(parameters, &index_config); 264 + if (result != UDS_SUCCESS) { 265 + vdo_log_error_strerror(result, "cannot compute index size"); 266 + return result; 267 + } 268 + 269 + result = compute_sizes(index_config, &sizes); 270 + uds_free_configuration(index_config); 271 + if (result != UDS_SUCCESS) 272 + return result; 273 + 274 + *index_size = sizes.total_size; 275 + return UDS_SUCCESS; 276 + } 277 + 252 278 /* Create unique data using the current time and a pseudorandom number. */ 253 279 static void create_unique_nonce_data(u8 *buffer) 254 280 {
+4
drivers/md/dm-vdo/indexer/indexer.h
··· 282 282 ); 283 283 }; 284 284 285 + /* Compute the number of bytes needed to store an index. */ 286 + int __must_check uds_compute_index_size(const struct uds_parameters *parameters, 287 + u64 *index_size); 288 + 285 289 /* A session is required for most index operations. */ 286 290 int __must_check uds_create_index_session(struct uds_index_session **session); 287 291