1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

integrity: report raidintegritymode randintegrityblocksize

reported for the raid lv and the integrity images
This commit is contained in:
David Teigland 2020-09-01 14:39:34 -05:00
parent f2c1de783c
commit 47b5fb138c
3 changed files with 88 additions and 0 deletions

View File

@ -84,6 +84,8 @@ FIELD(LVS, lv, STR, "SyncAction", lvid, 0, raidsyncaction, raid_sync_action, "Fo
FIELD(LVS, lv, NUM, "WBehind", lvid, 0, raidwritebehind, raid_write_behind, "For RAID1, the number of outstanding writes allowed to writemostly devices.", 0)
FIELD(LVS, lv, NUM, "MinSync", lvid, 0, raidminrecoveryrate, raid_min_recovery_rate, "For RAID1, the minimum recovery I/O load in kiB/sec/disk.", 0)
FIELD(LVS, lv, NUM, "MaxSync", lvid, 0, raidmaxrecoveryrate, raid_max_recovery_rate, "For RAID1, the maximum recovery I/O load in kiB/sec/disk.", 0)
FIELD(LVS, lv, STR, "IntegMode", lvid, 0, raidintegritymode, raidintegritymode, "The integrity mode", 0)
FIELD(LVS, lv, NUM, "IntegBlkSize", lvid, 0, raidintegrityblocksize, raidintegrityblocksize, "The integrity block size", 0)
FIELD(LVS, lv, STR, "Move", lvid, 0, movepv, move_pv, "For pvmove, Source PV of temporary LV created by pvmove.", 0)
FIELD(LVS, lv, STR, "Move UUID", lvid, 38, movepvuuid, move_pv_uuid, "For pvmove, the UUID of Source PV of temporary LV created by pvmove.", 0)
FIELD(LVS, lv, STR, "Convert", lvid, 0, convertlv, convert_lv, "For lvconvert, Name of temporary LV created by lvconvert.", 0)

View File

@ -91,6 +91,36 @@ static uint32_t _raidmaxrecoveryrate(const struct logical_volume *lv)
return first_seg(lv)->max_recovery_rate;
}
static const char *_raidintegritymode(const struct logical_volume *lv)
{
struct integrity_settings *settings;
if (lv_raid_has_integrity((struct logical_volume *)lv))
lv_get_raid_integrity_settings((struct logical_volume *)lv, &settings);
else if (lv_is_integrity(lv))
settings = &first_seg(lv)->integrity_settings;
if (settings->mode[0] == 'B')
return "bitmap";
if (settings->mode[0] == 'J')
return "journal";
return "unknown";
}
static uint32_t _raidintegrityblocksize(const struct logical_volume *lv)
{
struct integrity_settings *settings;
if (lv_raid_has_integrity((struct logical_volume *)lv))
lv_get_raid_integrity_settings((struct logical_volume *)lv, &settings);
else if (lv_is_integrity(lv))
settings = &first_seg(lv)->integrity_settings;
else
return 0;
return settings->block_size;
}
static dm_percent_t _snap_percent(const struct logical_volume *lv)
{
dm_percent_t percent;
@ -400,6 +430,10 @@ GET_LV_NUM_PROPERTY_FN(raid_max_recovery_rate, _raidmaxrecoveryrate(lv))
#define _raid_max_recovery_rate_set prop_not_implemented_set
GET_LV_STR_PROPERTY_FN(raid_sync_action, _raidsyncaction(lv))
#define _raid_sync_action_set prop_not_implemented_set
GET_LV_STR_PROPERTY_FN(raidintegritymode, _raidintegritymode(lv))
#define _raidintegritymode_set prop_not_implemented_set
GET_LV_NUM_PROPERTY_FN(raidintegrityblocksize, _raidintegrityblocksize(lv))
#define _raidintegrityblocksize_set prop_not_implemented_set
GET_LV_STR_PROPERTY_FN(move_pv, lv_move_pv_dup(lv->vg->vgmem, lv))
#define _move_pv_set prop_not_implemented_set
GET_LV_STR_PROPERTY_FN(move_pv_uuid, lv_move_pv_uuid_dup(lv->vg->vgmem, lv))

View File

@ -3271,6 +3271,58 @@ static int _raidmaxrecoveryrate_disp(struct dm_report *rh __attribute__((unused)
return _field_set_value(field, "", &GET_TYPE_RESERVED_VALUE(num_undef_64));
}
static int _raidintegritymode_disp(struct dm_report *rh __attribute__((unused)),
struct dm_pool *mem,
struct dm_report_field *field,
const void *data,
void *private __attribute__((unused)))
{
struct logical_volume *lv = (struct logical_volume *) data;
struct integrity_settings *settings;
const char *mode = NULL;
char *repstr;
if (lv_raid_has_integrity(lv))
lv_get_raid_integrity_settings(lv, &settings);
else if (lv_is_integrity(lv))
settings = &first_seg(lv)->integrity_settings;
if (settings->mode[0]) {
if (settings->mode[0] == 'B')
mode = "bitmap";
else if (settings->mode[0] == 'J')
mode = "journal";
if (mode) {
if (!(repstr = dm_pool_strdup(mem, mode))) {
log_error("Failed to allocate buffer for mode.");
return 0;
}
return _field_set_value(field, repstr, NULL);
}
}
return _field_set_value(field, "", NULL);
}
static int _raidintegrityblocksize_disp(struct dm_report *rh __attribute__((unused)),
struct dm_pool *mem,
struct dm_report_field *field,
const void *data,
void *private __attribute__((unused)))
{
struct logical_volume *lv = (struct logical_volume *) data;
struct integrity_settings *settings;
if (lv_raid_has_integrity(lv))
lv_get_raid_integrity_settings(lv, &settings);
else if (lv_is_integrity(lv))
settings = &first_seg(lv)->integrity_settings;
else
return dm_report_field_int32(rh, field, &GET_TYPE_RESERVED_VALUE(num_undef_32));
return dm_report_field_uint32(rh, field, &settings->block_size);
}
static int _datapercent_disp(struct dm_report *rh, struct dm_pool *mem,
struct dm_report_field *field,
const void *data, void *private)