From e4fdfa9d314eeb02b6e4eb0e4bf053415b6b825e Mon Sep 17 00:00:00 2001 From: Alasdair G Kergon Date: Tue, 7 Aug 2012 18:48:34 +0100 Subject: report: provide discard field value in full I think it's better not to abbreviate human-readable fields like 'discard' to a single character. Users can truncate it to the first character themselves if they wish. It's confusing to use the variable name discard for different things in different places - use discard_str when it's a string not the enum. --- lib/report/columns.h | 2 +- lib/report/report.c | 21 +++++---------------- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/lib/report/columns.h b/lib/report/columns.h index 7bcaaabe..c869d145 100644 --- a/lib/report/columns.h +++ b/lib/report/columns.h @@ -140,7 +140,7 @@ FIELD(SEGS, seg, NUM, "Region", region_size, 6, size32, region_size, "For mirror FIELD(SEGS, seg, NUM, "Chunk", list, 5, chunksize, chunksize, "For snapshots, the unit of data used when tracking changes.", 0) FIELD(SEGS, seg, NUM, "Chunk", list, 5, chunksize, chunk_size, "For snapshots, the unit of data used when tracking changes.", 0) FIELD(SEGS, seg, NUM, "#Thins", list, 4, thincount, thin_count, "For thin pools, the number of thin volumes in this pool.", 0) -FIELD(SEGS, seg, NUM, "Dis", list, 3, discard, discard, "For thin pools, discard handling (i)ignore, (n)o_passdown, (p)assdown.", 0) +FIELD(SEGS, seg, NUM, "Discard", list, 7, discard, discard, "For thin pools, how discards are handled.", 0) FIELD(SEGS, seg, NUM, "Zero", list, 4, thinzero, zero, "For thin pools, if zeroing is enabled.", 0) FIELD(SEGS, seg, NUM, "TransId", list, 4, transactionid, transaction_id, "For thin pools, the transaction id.", 0) FIELD(SEGS, seg, NUM, "Start", list, 5, segstart, seg_start, "Offset within the LV to the start of the segment in current units.", 0) diff --git a/lib/report/report.c b/lib/report/report.c index 3121db3f..b66be4f1 100644 --- a/lib/report/report.c +++ b/lib/report/report.c @@ -568,29 +568,18 @@ static int _discard_disp(struct dm_report *rh, struct dm_pool *mem, struct dm_report_field *field, const void *data, void *private) { - static const struct { - const char c[2]; - unsigned val; - thin_discard_t discard; - } const arr[] = { - { "p", 0, THIN_DISCARD_PASSDOWN }, - { "n", 1, THIN_DISCARD_NO_PASSDOWN }, - { "i", 2, THIN_DISCARD_IGNORE }, - { "" } - }; const struct lv_segment *seg = (const struct lv_segment *) data; - unsigned i = 0; + const char *discard_str; if (seg_is_thin_volume(seg)) seg = first_seg(seg->pool_lv); if (seg_is_thin_pool(seg)) { - while (arr[i].c[0] && seg->discard != arr[i].discard) - i++; + discard_str = get_pool_discard_name(seg->discard); + return dm_report_field_string(rh, field, &discard_str); + } - dm_report_field_set_value(field, arr[i].c, &arr[i].val); - } else - dm_report_field_set_value(field, "", NULL); + dm_report_field_set_value(field, "", NULL); return 1; } -- cgit