Skip to content

Commit 47874c9

Browse files
bjohnstoMikulas Patocka
authored andcommitted
dm vdo: add dmsetup message for returning configuration info
Add a new dmsetup message called config, which will return useful configuration information for the vdo volume and the uds index associated with it. The output is a YAML string, and contains a version number to allow future additions to the content. Signed-off-by: Bruce Johnston <[email protected]> Signed-off-by: Matthew Sakai <[email protected]> Signed-off-by: Mikulas Patocka <[email protected]>
1 parent 3a59b2e commit 47874c9

File tree

4 files changed

+59
-2
lines changed

4 files changed

+59
-2
lines changed

Documentation/admin-guide/device-mapper/vdo.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,12 @@ The messages are:
251251
by the vdostats userspace program to interpret the output
252252
buffer.
253253

254-
dump:
254+
config:
255+
Outputs useful vdo configuration information. Mostly used
256+
by users who want to recreate a similar VDO volume and
257+
want to know the creation configuration used.
258+
259+
dump:
255260
Dumps many internal structures to the system log. This is
256261
not always safe to run, so it should only be used to debug
257262
a hung vdo. Optional parameters to specify structures to

drivers/md/dm-vdo/dm-vdo-target.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1105,6 +1105,9 @@ static int vdo_message(struct dm_target *ti, unsigned int argc, char **argv,
11051105
if ((argc == 1) && (strcasecmp(argv[0], "stats") == 0)) {
11061106
vdo_write_stats(vdo, result_buffer, maxlen);
11071107
result = 1;
1108+
} else if ((argc == 1) && (strcasecmp(argv[0], "config") == 0)) {
1109+
vdo_write_config(vdo, &result_buffer, &maxlen);
1110+
result = 1;
11081111
} else {
11091112
result = vdo_status_to_errno(process_vdo_message(vdo, argc, argv));
11101113
}
@@ -2832,7 +2835,7 @@ static void vdo_resume(struct dm_target *ti)
28322835
static struct target_type vdo_target_bio = {
28332836
.features = DM_TARGET_SINGLETON,
28342837
.name = "vdo",
2835-
.version = { 9, 0, 0 },
2838+
.version = { 9, 1, 0 },
28362839
.module = THIS_MODULE,
28372840
.ctr = vdo_ctr,
28382841
.dtr = vdo_dtr,

drivers/md/dm-vdo/message-stats.c

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55

66
#include "dedupe.h"
7+
#include "indexer.h"
78
#include "logger.h"
89
#include "memory-alloc.h"
910
#include "message-stats.h"
@@ -430,3 +431,50 @@ int vdo_write_stats(struct vdo *vdo, char *buf, unsigned int maxlen)
430431
vdo_free(stats);
431432
return VDO_SUCCESS;
432433
}
434+
435+
static void write_index_memory(u32 mem, char **buf, unsigned int *maxlen)
436+
{
437+
char *prefix = "memorySize : ";
438+
439+
/* Convert index memory to fractional value */
440+
if (mem == (u32)UDS_MEMORY_CONFIG_256MB)
441+
write_string(prefix, "0.25, ", NULL, buf, maxlen);
442+
else if (mem == (u32)UDS_MEMORY_CONFIG_512MB)
443+
write_string(prefix, "0.50, ", NULL, buf, maxlen);
444+
else if (mem == (u32)UDS_MEMORY_CONFIG_768MB)
445+
write_string(prefix, "0.75, ", NULL, buf, maxlen);
446+
else
447+
write_u32(prefix, mem, ", ", buf, maxlen);
448+
}
449+
450+
static void write_index_config(struct index_config *config, char **buf,
451+
unsigned int *maxlen)
452+
{
453+
write_string("index : ", "{ ", NULL, buf, maxlen);
454+
/* index mem size */
455+
write_index_memory(config->mem, buf, maxlen);
456+
/* whether the index is sparse or not */
457+
write_bool("isSparse : ", config->sparse, ", ", buf, maxlen);
458+
write_string(NULL, "}", ", ", buf, maxlen);
459+
}
460+
461+
int vdo_write_config(struct vdo *vdo, char **buf, unsigned int *maxlen)
462+
{
463+
struct vdo_config *config = &vdo->states.vdo.config;
464+
465+
write_string(NULL, "{ ", NULL, buf, maxlen);
466+
/* version */
467+
write_u32("version : ", 1, ", ", buf, maxlen);
468+
/* physical size */
469+
write_block_count_t("physicalSize : ", config->physical_blocks * VDO_BLOCK_SIZE, ", ",
470+
buf, maxlen);
471+
/* logical size */
472+
write_block_count_t("logicalSize : ", config->logical_blocks * VDO_BLOCK_SIZE, ", ",
473+
buf, maxlen);
474+
/* slab size */
475+
write_block_count_t("slabSize : ", config->slab_size, ", ", buf, maxlen);
476+
/* index config */
477+
write_index_config(&vdo->geometry.index_config, buf, maxlen);
478+
write_string(NULL, "}", NULL, buf, maxlen);
479+
return VDO_SUCCESS;
480+
}

drivers/md/dm-vdo/message-stats.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include "types.h"
1010

11+
int vdo_write_config(struct vdo *vdo, char **buf, unsigned int *maxlen);
1112
int vdo_write_stats(struct vdo *vdo, char *buf, unsigned int maxlen);
1213

1314
#endif /* VDO_MESSAGE_STATS_H */

0 commit comments

Comments
 (0)