]> sourceware.org Git - lvm2.git/commitdiff
report: provide discard field value in full
authorAlasdair G Kergon <agk@redhat.com>
Tue, 7 Aug 2012 17:48:34 +0000 (18:48 +0100)
committerAlasdair G Kergon <agk@redhat.com>
Tue, 7 Aug 2012 17:48:34 +0000 (18:48 +0100)
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
lib/report/report.c

index 7bcaaabee1477585c679331a7faab29c17e5f155..c869d145f86c65c4056da79e1f4217658e888b89 100644 (file)
@@ -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)
index 3121db3f2a71ee77b7b8b30032b229b40b0010b4..b66be4f197af6a79a9dadba748b94b10d76977e9 100644 (file)
@@ -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;
 }
This page took 0.042244 seconds and 5 git commands to generate.