mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-02 01:18:26 +03:00
Add devices to segments report; some move->copy renaming.
This commit is contained in:
parent
4922197a33
commit
0b2b87b717
@ -1,5 +1,7 @@
|
||||
Version 2.00.16 -
|
||||
=============================
|
||||
Rename move->copy.
|
||||
Add devices to segments report.
|
||||
Begin separating out segment code. There's a lot of change here.
|
||||
Compress any (obsolete) long LVM1 pvids encountered.
|
||||
Support for tagged config files.
|
||||
|
@ -91,12 +91,12 @@
|
||||
#define DEFAULT_REP_HEADINGS 1
|
||||
#define DEFAULT_REP_SEPARATOR " "
|
||||
|
||||
#define DEFAULT_LVS_COLS "lv_name,vg_name,lv_attr,lv_size,origin,snap_percent,move_pv,move_percent"
|
||||
#define DEFAULT_LVS_COLS "lv_name,vg_name,lv_attr,lv_size,origin,snap_percent,move_pv,copy_percent"
|
||||
#define DEFAULT_VGS_COLS "vg_name,pv_count,lv_count,snap_count,vg_attr,vg_size,vg_free"
|
||||
#define DEFAULT_PVS_COLS "pv_name,vg_name,pv_fmt,pv_attr,pv_size,pv_free"
|
||||
#define DEFAULT_SEGS_COLS "lv_name,vg_name,lv_attr,stripes,segtype,seg_size"
|
||||
|
||||
#define DEFAULT_LVS_COLS_VERB "lv_name,vg_name,seg_count,lv_attr,lv_size,lv_major,lv_minor,origin,snap_percent,move_pv,move_percent,lv_uuid"
|
||||
#define DEFAULT_LVS_COLS_VERB "lv_name,vg_name,seg_count,lv_attr,lv_size,lv_major,lv_minor,origin,snap_percent,move_pv,copy_percent,lv_uuid"
|
||||
#define DEFAULT_VGS_COLS_VERB "vg_name,vg_attr,vg_extent_size,pv_count,lv_count,snap_count,vg_size,vg_free,vg_uuid"
|
||||
#define DEFAULT_PVS_COLS_VERB "pv_name,vg_name,pv_fmt,pv_attr,pv_size,pv_free,pv_uuid"
|
||||
#define DEFAULT_SEGS_COLS_VERB "lv_name,vg_name,lv_attr,seg_start,seg_size,stripes,segtype,stripesize,chunksize"
|
||||
|
@ -27,7 +27,7 @@ FIELD(LVS, lv, NUM, "LSize", size, 5, size64, "lv_size")
|
||||
FIELD(LVS, lv, NUM, "#Seg", lvid, 4, lvsegcount, "seg_count")
|
||||
FIELD(LVS, lv, STR, "Origin", lvid, 6, origin, "origin")
|
||||
FIELD(LVS, lv, NUM, "Snap%", lvid, 6, snpercent, "snap_percent")
|
||||
FIELD(LVS, lv, NUM, "Move%", lvid, 6, movepercent, "move_percent")
|
||||
FIELD(LVS, lv, NUM, "Copy%", lvid, 6, copypercent, "copy_percent")
|
||||
FIELD(LVS, lv, STR, "Move", lvid, 4, movepv, "move_pv")
|
||||
FIELD(LVS, lv, STR, "LV Tags", tags, 7, tags, "lv_tags")
|
||||
|
||||
@ -67,4 +67,5 @@ FIELD(SEGS, seg, NUM, "Chunk", chunk_size, 5, size32, "chunksize")
|
||||
FIELD(SEGS, seg, NUM, "Start", list, 5, segstart, "seg_start")
|
||||
FIELD(SEGS, seg, NUM, "SSize", list, 5, segsize, "seg_size")
|
||||
FIELD(SEGS, seg, STR, "Seg Tags", tags, 8, tags, "seg_tags")
|
||||
FIELD(SEGS, seg, STR, "Devices", list, 5, devices, "devices")
|
||||
/* *INDENT-ON* */
|
||||
|
@ -124,6 +124,68 @@ static int _dev_name_disp(struct report_handle *rh, struct field *field,
|
||||
return _string_disp(rh, field, &name);
|
||||
}
|
||||
|
||||
static int _devices_disp(struct report_handle *rh, struct field *field,
|
||||
const void *data)
|
||||
{
|
||||
const struct lv_segment *seg = (const struct lv_segment *) data;
|
||||
unsigned int s;
|
||||
const char *devname;
|
||||
uint32_t extent;
|
||||
char extent_str[32];
|
||||
|
||||
if (!pool_begin_object(rh->mem, 256)) {
|
||||
log_error("pool_begin_object failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (s = 0; s < seg->area_count; s++) {
|
||||
switch (seg->area[s].type) {
|
||||
case AREA_LV:
|
||||
devname = seg->area[s].u.lv.lv->name;
|
||||
extent = seg->area[s].u.lv.le;
|
||||
break;
|
||||
case AREA_PV:
|
||||
devname = dev_name(seg->area[s].u.pv.pv->dev);
|
||||
extent = seg->area[s].u.pv.pe;
|
||||
break;
|
||||
default:
|
||||
devname = "unknown";
|
||||
extent = 0;
|
||||
}
|
||||
|
||||
if (!pool_grow_object(rh->mem, devname, strlen(devname))) {
|
||||
log_error("pool_grow_object failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (lvm_snprintf(extent_str, sizeof(extent_str), "(%" PRIu32
|
||||
")", extent) < 0) {
|
||||
log_error("Extent number lvm_snprintf failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!pool_grow_object(rh->mem, extent_str, strlen(extent_str))) {
|
||||
log_error("pool_grow_object failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((s != seg->area_count - 1) &&
|
||||
!pool_grow_object(rh->mem, ",", 1)) {
|
||||
log_error("pool_grow_object failed");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!pool_grow_object(rh->mem, "\0", 1)) {
|
||||
log_error("pool_grow_object failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
field->report_string = pool_end_object(rh->mem);
|
||||
field->sort_value = (const void *) field->report_string;
|
||||
|
||||
return 1;
|
||||
}
|
||||
static int _tags_disp(struct report_handle *rh, struct field *field,
|
||||
const void *data)
|
||||
{
|
||||
@ -655,11 +717,11 @@ static int _snpercent_disp(struct report_handle *rh, struct field *field,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _movepercent_disp(struct report_handle *rh, struct field *field,
|
||||
static int _copypercent_disp(struct report_handle *rh, struct field *field,
|
||||
const void *data)
|
||||
{
|
||||
struct logical_volume *lv = (struct logical_volume *) data;
|
||||
float move_percent;
|
||||
float percent;
|
||||
uint64_t *sortval;
|
||||
char *repstr;
|
||||
|
||||
@ -669,26 +731,26 @@ static int _movepercent_disp(struct report_handle *rh, struct field *field,
|
||||
}
|
||||
|
||||
if (!(lv->status & PVMOVE) ||
|
||||
!lv_mirror_percent(lv, 0, &move_percent, NULL)) {
|
||||
!lv_mirror_percent(lv, 0, &percent, NULL)) {
|
||||
field->report_string = "";
|
||||
*sortval = UINT64_C(0);
|
||||
field->sort_value = sortval;
|
||||
return 1;
|
||||
}
|
||||
|
||||
move_percent = pvmove_percent(lv);
|
||||
percent = pvmove_percent(lv);
|
||||
|
||||
if (!(repstr = pool_zalloc(rh->mem, 8))) {
|
||||
log_error("pool_alloc failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (lvm_snprintf(repstr, 7, "%.2f", move_percent) < 0) {
|
||||
log_error("move percentage too large");
|
||||
if (lvm_snprintf(repstr, 7, "%.2f", percent) < 0) {
|
||||
log_error("copy percentage too large");
|
||||
return 0;
|
||||
}
|
||||
|
||||
*sortval = move_percent * UINT64_C(1000);
|
||||
*sortval = percent * UINT64_C(1000);
|
||||
field->sort_value = sortval;
|
||||
field->report_string = repstr;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user