From 46b9cc1248941cc43f953e1a6b285ebe64a62077 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Mon, 9 Jul 2012 16:48:28 +0200 Subject: [PATCH] thin: add reporting of discard for thin pool New field "discard" is added for lvs reporting of lv segment. Reported as one character: (i)gnore (n)opassdown (p)assdown lvs -o+discard --- WHATS_NEW | 1 + lib/report/columns.h | 1 + lib/report/properties.c | 2 ++ lib/report/report.c | 30 ++++++++++++++++++++++++++++++ man/lvs.8.in | 1 + 5 files changed, 35 insertions(+) diff --git a/WHATS_NEW b/WHATS_NEW index 41b52be8c..7811b6d6e 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.97 - =============================== + Report used discard for thin pool and volume. Add support for controlling discard behavior of thin pool. Detect features for new 1.1 thin pool target. Count percentage of completeness upwards when merging a snapshot volume. diff --git a/lib/report/columns.h b/lib/report/columns.h index 579f029c3..7bcaaabee 100644 --- a/lib/report/columns.h +++ b/lib/report/columns.h @@ -140,6 +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, "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/properties.c b/lib/report/properties.c index 0855f955e..d78ad64d8 100644 --- a/lib/report/properties.c +++ b/lib/report/properties.c @@ -277,6 +277,8 @@ GET_LVSEG_NUM_PROPERTY_FN(zero, lvseg->zero_new_blocks) #define _zero_set _not_implemented_set GET_LVSEG_NUM_PROPERTY_FN(transaction_id, lvseg->transaction_id) #define _transaction_id_set _not_implemented_set +GET_LVSEG_NUM_PROPERTY_FN(discard, lvseg->discard) +#define _discard_set _not_implemented_set GET_LVSEG_NUM_PROPERTY_FN(seg_start, lvseg_start(lvseg)) #define _seg_start_set _not_implemented_set GET_LVSEG_NUM_PROPERTY_FN(seg_start_pe, lvseg->le) diff --git a/lib/report/report.c b/lib/report/report.c index 97e75b653..3121db3f2 100644 --- a/lib/report/report.c +++ b/lib/report/report.c @@ -564,6 +564,36 @@ static int _transactionid_disp(struct dm_report *rh, struct dm_pool *mem, return dm_report_field_uint64(rh, field, &seg->transaction_id); } +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; + + 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++; + + dm_report_field_set_value(field, arr[i].c, &arr[i].val); + } else + dm_report_field_set_value(field, "", NULL); + + return 1; +} static int _originsize_disp(struct dm_report *rh, struct dm_pool *mem, struct dm_report_field *field, diff --git a/man/lvs.8.in b/man/lvs.8.in index 9a4bb4dfb..f49283511 100644 --- a/man/lvs.8.in +++ b/man/lvs.8.in @@ -80,6 +80,7 @@ convert_lv, copy_percent, data_lv, devices, +discard, lv_attr, lv_host, lv_kernel_major, -- 2.43.5