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

libdm: reset report field widths in _destroy_rows()

For repeating reports field widths should be re-calculated for
each report interval. Not doing so will cause a single row with
wide field data to cause all subsequent rows to share the width:

Name                                      RgID ArID R/s     W/s    Histogram                                     Bounds
vg_hex-lv_home                               0    0 4522.00 834.00 0s:   991, 2ms:   152, 4ms:   161, 6ms:  4052 0s, 2ms, 4ms, 6ms
vg_hex-lv_swap                               0    0    0.00   0.00 0s: 0, 2ms: 0, 4ms: 0, 6ms: 0                 0s, 2ms, 4ms, 6ms
vg_hex-lv_root                               0    0 1754.00 683.00 0s:  369, 2ms:   65, 4ms:   90, 6ms: 1913     0s, 2ms, 4ms, 6ms
luks-79733921-3f68-4c92-9eb7-d0aca4c6ba3e    0    0 4522.00 868.00 0s:   985, 2ms:   152, 4ms:   161, 6ms:  4092 0s, 2ms, 4ms, 6ms
vg_hex-lv_images                             0    0    0.00   0.00 0s: 0, 2ms: 0, 4ms: 0, 6ms: 0                 0s, 2ms, 4ms, 6ms

Name                                      RgID ArID R/s     W/s    Histogram                                     Bounds
vg_hex-lv_home                               0    0    0.00   0.00 0s: 0, 2ms: 0, 4ms: 0, 6ms: 0                 0s, 2ms, 4ms, 6ms
vg_hex-lv_swap                               0    0    0.00   0.00 0s: 0, 2ms: 0, 4ms: 0, 6ms: 0                 0s, 2ms, 4ms, 6ms
vg_hex-lv_root                               0    0    0.00   2.00 0s: 1, 2ms: 0, 4ms: 0, 6ms: 1                 0s, 2ms, 4ms, 6ms
luks-79733921-3f68-4c92-9eb7-d0aca4c6ba3e    0    0    0.00   0.00 0s: 0, 2ms: 0, 4ms: 0, 6ms: 0                 0s, 2ms, 4ms, 6ms
vg_hex-lv_images                             0    0    0.00   0.00 0s: 0, 2ms: 0, 4ms: 0, 6ms: 0                 0s, 2ms, 4ms, 6ms
                                                                                                ^^^^^^^^^^^^^^^^^
This is especially significant for the current histogram fields:
depending on the time since the last clear operation the first
report iteration may contain very large values leading to a very
large minimum field width. Without resetting field widths this
large minimum field width value is used for all subsequent rows.
This commit is contained in:
Bryn M. Reeves 2015-08-24 11:38:17 +01:00
parent a9d954cb3c
commit c4f3732c91

View File

@ -86,7 +86,8 @@ struct field_properties {
struct dm_list list;
uint32_t field_num;
uint32_t sort_posn;
int32_t width;
int32_t initial_width;
int32_t width; /* current width: adjusted by dm_report_object() */
const struct dm_report_object_type *type;
uint32_t flags;
int implicit;
@ -774,7 +775,8 @@ static int _copy_field(struct dm_report *rh, struct field_properties *dest,
: rh->fields;
dest->field_num = field_num;
dest->width = fields[field_num].width;
dest->initial_width = fields[field_num].width;
dest->width = fields[field_num].width; /* adjusted in _do_report_object() */
dest->flags = fields[field_num].flags & DM_REPORT_FIELD_MASK;
dest->implicit = implicit;
@ -4178,6 +4180,13 @@ bad:
return 0;
}
static void _reset_field_props(struct dm_report *rh)
{
struct field_properties *fp;
dm_list_iterate_items(fp, &rh->field_props)
fp->width = fp->initial_width;
}
static void _destroy_rows(struct dm_report *rh)
{
/*
@ -4189,6 +4198,9 @@ static void _destroy_rows(struct dm_report *rh)
dm_pool_free(rh->mem, rh->first_row);
rh->first_row = NULL;
dm_list_init(&rh->rows);
/* Reset field widths to original values. */
_reset_field_props(rh);
}
static int _output_as_rows(struct dm_report *rh)