1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-22 17:35:59 +03:00

refactor: use new LVSINFO report type for lv_kernel_{major,minor,read_ahead} field

This commit is contained in:
Peter Rajnoha 2014-07-02 14:31:39 +02:00
parent ecb2be5d16
commit 4b9b1f2319
2 changed files with 13 additions and 15 deletions

View File

@ -39,9 +39,6 @@ FIELD(LVS, lv, STR, "Active", lvid, 6, lvactive, lv_active, "Active state of the
FIELD(LVS, lv, NUM, "Maj", major, 3, int32, lv_major, "Persistent major number or -1 if not persistent.", 0)
FIELD(LVS, lv, NUM, "Min", minor, 3, int32, lv_minor, "Persistent minor number or -1 if not persistent.", 0)
FIELD(LVS, lv, SIZ, "Rahead", lvid, 6, lvreadahead, lv_read_ahead, "Read ahead setting in current units.", 0)
FIELD(LVS, lv, NUM, "KMaj", lvid, 4, lvkmaj, lv_kernel_major, "Currently assigned major number or -1 if LV is not active.", 0)
FIELD(LVS, lv, NUM, "KMin", lvid, 4, lvkmin, lv_kernel_minor, "Currently assigned minor number or -1 if LV is not active.", 0)
FIELD(LVS, lv, SIZ, "KRahead", lvid, 7, lvkreadahead, lv_kernel_read_ahead, "Currently-in-use read ahead setting in current units.", 0)
FIELD(LVS, lv, SIZ, "LSize", size, 5, size64, lv_size, "Size of LV in current units.", 0)
FIELD(LVS, lv, SIZ, "MSize", lvid, 6, lvmetadatasize, lv_metadata_size, "For thin pools, the size of the LV that holds the metadata.", 0)
FIELD(LVS, lv, NUM, "#Seg", lvid, 4, lvsegcount, seg_count, "Number of segments in LV.", 0)
@ -69,6 +66,10 @@ FIELD(LVS, lv, STR, "Time", lvid, 26, lvtime, lv_time, "Creation time of the LV,
FIELD(LVS, lv, STR, "Host", lvid, 10, lvhost, lv_host, "Creation host of the LV, if known.", 0)
FIELD(LVS, lv, STR_LIST, "Modules", lvid, 7, modules, lv_modules, "Kernel device-mapper modules required for this LV.", 0)
FIELD(LVSINFO, lv, NUM, "KMaj", lvid, 4, lvkmaj, lv_kernel_major, "Currently assigned major number or -1 if LV is not active.", 0)
FIELD(LVSINFO, lv, NUM, "KMin", lvid, 4, lvkmin, lv_kernel_minor, "Currently assigned minor number or -1 if LV is not active.", 0)
FIELD(LVSINFO, lv, SIZ, "KRahead", lvid, 7, lvkreadahead, lv_kernel_read_ahead, "Currently-in-use read ahead setting in current units.", 0)
FIELD(LABEL, label, STR, "Fmt", type, 3, pvfmt, pv_fmt, "Type of metadata.", 0)
FIELD(LABEL, label, STR, "PV UUID", type, 38, pvuuid, pv_uuid, "Unique identifier.", 0)
FIELD(LABEL, label, SIZ, "DevSize", dev, 7, devsize, dev_size, "Size of underlying device in current units.", 0)

View File

@ -195,11 +195,10 @@ static int _lvkmaj_disp(struct dm_report *rh, struct dm_pool *mem __attribute__(
struct dm_report_field *field,
const void *data, void *private __attribute__((unused)))
{
const struct logical_volume *lv = (const struct logical_volume *) data;
int major;
const struct lv_with_info *lvi = (const struct lv_with_info *) data;
if ((major = lv_kernel_major(lv)) >= 0)
return dm_report_field_int(rh, field, &major);
if (lvi->info && lvi->info->exists && lvi->info->major >= 0)
return dm_report_field_int(rh, field, &lvi->info->major);
return dm_report_field_int32(rh, field, &_reserved_number_undef_32);
}
@ -208,11 +207,10 @@ static int _lvkmin_disp(struct dm_report *rh, struct dm_pool *mem __attribute__(
struct dm_report_field *field,
const void *data, void *private __attribute__((unused)))
{
const struct logical_volume *lv = (const struct logical_volume *) data;
int minor;
const struct lv_with_info *lvi = (const struct lv_with_info *) data;
if ((minor = lv_kernel_minor(lv)) >= 0)
return dm_report_field_int(rh, field, &minor);
if (lvi->info && lvi->info->exists && lvi->info->minor >= 0)
return dm_report_field_int(rh, field, &lvi->info->minor);
return dm_report_field_int32(rh, field, &_reserved_number_undef_32);
}
@ -549,13 +547,12 @@ static int _lvkreadahead_disp(struct dm_report *rh, struct dm_pool *mem,
const void *data,
void *private)
{
const struct logical_volume *lv = (const struct logical_volume *) data;
uint32_t read_ahead = lv_kernel_read_ahead(lv);
const struct lv_with_info *lvi = (const struct lv_with_info *) data;
if (read_ahead == UINT32_MAX)
if (!lvi->info || !lvi->info->exists)
return dm_report_field_int32(rh, field, &_reserved_number_undef_32);
return _size32_disp(rh, mem, field, &read_ahead, private);
return _size32_disp(rh, mem, field, &lvi->info->read_ahead, private);
}
static int _vgsize_disp(struct dm_report *rh, struct dm_pool *mem,