diff options
author | David Teigland <teigland@redhat.com> | 2018-07-24 17:00:06 -0500 |
---|---|---|
committer | David Teigland <teigland@redhat.com> | 2018-07-24 17:00:06 -0500 |
commit | 0791eed33d3fda27ccd84178cd51a5b8d33bd984 (patch) | |
tree | af9f5c7237bb93c8c5a89eca682889ff751bfb95 | |
parent | 19637a8d72cbe55b4c771ea11a54c8745edb15aa (diff) | |
download | lvm2-dev-dct-writecache-17.tar.gz |
report: cachevol field for writecache LVsdev-dct-writecache-17
-rw-r--r-- | lib/config/defaults.h | 2 | ||||
-rw-r--r-- | lib/metadata/lv.c | 31 | ||||
-rw-r--r-- | lib/metadata/lv.h | 3 | ||||
-rw-r--r-- | lib/report/columns.h | 2 | ||||
-rw-r--r-- | lib/report/properties.c | 4 | ||||
-rw-r--r-- | lib/report/report.c | 31 |
6 files changed, 72 insertions, 1 deletions
diff --git a/lib/config/defaults.h b/lib/config/defaults.h index 9928fb19e..8cdfeadf6 100644 --- a/lib/config/defaults.h +++ b/lib/config/defaults.h @@ -264,7 +264,7 @@ #define DEFAULT_DEVTYPES_COLS "devtype_name,devtype_max_partitions,devtype_description" #define DEFAULT_COMMAND_LOG_COLS "log_seq_num,log_type,log_context,log_object_type,log_object_name,log_object_id,log_object_group,log_object_group_id,log_message,log_errno,log_ret_code" -#define DEFAULT_LVS_COLS_VERB "lv_name,vg_name,seg_count,lv_attr,lv_size,lv_major,lv_minor,lv_kernel_major,lv_kernel_minor,pool_lv,origin,data_percent,metadata_percent,move_pv,copy_percent,mirror_log,convert_lv,lv_uuid,lv_profile" +#define DEFAULT_LVS_COLS_VERB "lv_name,vg_name,seg_count,lv_attr,lv_size,lv_major,lv_minor,lv_kernel_major,lv_kernel_minor,cachevol,pool_lv,origin,data_percent,metadata_percent,move_pv,copy_percent,mirror_log,convert_lv,lv_uuid,lv_profile" #define DEFAULT_VGS_COLS_VERB "vg_name,vg_attr,vg_extent_size,pv_count,lv_count,snap_count,vg_size,vg_free,vg_uuid,vg_profile" #define DEFAULT_PVS_COLS_VERB "pv_name,vg_name,pv_fmt,pv_attr,pv_size,pv_free,dev_size,pv_uuid" #define DEFAULT_SEGS_COLS_VERB "lv_name,vg_name,lv_attr,seg_start,seg_size,stripes,segtype,stripesize,chunksize" diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c index c6357ce5b..d71e3aec7 100644 --- a/lib/metadata/lv.c +++ b/lib/metadata/lv.c @@ -701,6 +701,37 @@ char *lv_mirror_log_uuid_dup(struct dm_pool *mem, const struct logical_volume *l return _do_lv_mirror_log_dup(mem, lv, 1); } +struct logical_volume *lv_cachevol_lv(const struct logical_volume *lv) +{ + if (lv_is_writecache(lv)) + return first_seg(lv)->cachevol; + return NULL; +} + +static char *_do_lv_cachevol_dup(struct dm_pool *mem, const struct logical_volume *lv, + int uuid) +{ + struct logical_volume *cachevol_lv = lv_cachevol_lv(lv); + + if (!cachevol_lv) + return NULL; + + if (uuid) + return lv_uuid_dup(mem, cachevol_lv); + + return lv_name_dup(mem, cachevol_lv); +} + +char *lv_cachevol_dup(struct dm_pool *mem, const struct logical_volume *lv) +{ + return _do_lv_cachevol_dup(mem, lv, 0); +} + +char *lv_cachevol_uuid_dup(struct dm_pool *mem, const struct logical_volume *lv) +{ + return _do_lv_cachevol_dup(mem, lv, 1); +} + struct logical_volume *lv_pool_lv(const struct logical_volume *lv) { if (lv_is_thin_volume(lv) || lv_is_cache(lv)) diff --git a/lib/metadata/lv.h b/lib/metadata/lv.h index b1df7479e..a90054e12 100644 --- a/lib/metadata/lv.h +++ b/lib/metadata/lv.h @@ -117,6 +117,7 @@ struct logical_volume *lv_mirror_log(const struct logical_volume *lv); struct logical_volume *lv_data(const struct logical_volume *lv); struct logical_volume *lv_metadata_lv(const struct logical_volume *lv); struct logical_volume *lv_pool_lv(const struct logical_volume *lv); +struct logical_volume *lv_cachevol_lv(const struct logical_volume *lv); /* LV properties */ uint64_t lv_size(const struct logical_volume *lv); @@ -194,6 +195,8 @@ char *lv_profile_dup(struct dm_pool *mem, const struct logical_volume *lv); char *lv_lock_args_dup(struct dm_pool *mem, const struct logical_volume *lv); char *lvseg_kernel_discards_dup_with_info_and_seg_status(struct dm_pool *mem, const struct lv_with_info_and_seg_status *lvdm); char *lv_time_dup(struct dm_pool *mem, const struct logical_volume *lv, int iso_mode); +char *lv_cachevol_dup(struct dm_pool *mem, const struct logical_volume *lv); +char *lv_cachevol_uuid_dup(struct dm_pool *mem, const struct logical_volume *lv); typedef enum { PERCENT_GET_DATA = 0, diff --git a/lib/report/columns.h b/lib/report/columns.h index 827a15720..cef7e5ec8 100644 --- a/lib/report/columns.h +++ b/lib/report/columns.h @@ -104,6 +104,8 @@ FIELD(LVS, lv, TIM, "RTime", lvid, 26, lvtimeremoved, lv_time_removed, "Removal FIELD(LVS, lv, STR, "Host", lvid, 10, lvhost, lv_host, "Creation host of the LV, if known.", 0) FIELD(LVS, lv, STR_LIST, "Modules", lvid, 0, modules, lv_modules, "Kernel device-mapper modules required for this LV.", 0) FIELD(LVS, lv, BIN, "Historical", lvid, 0, lvhistorical, lv_historical, "Set if the LV is historical.", 0) +FIELD(LVS, lv, STR, "Cachevol", lvid, 0, cachevol, cachevol, "An attached cache volume.", 0) +FIELD(LVS, lv, STR, "Cachevol UUID", lvid, 38, cachevoluuid, cachevol_uuid, "The UUID of an attached cache volume.", 0) /* * End of LVS type fields */ diff --git a/lib/report/properties.c b/lib/report/properties.c index 74f13c84c..67cf3b18d 100644 --- a/lib/report/properties.c +++ b/lib/report/properties.c @@ -388,6 +388,10 @@ GET_LV_STR_PROPERTY_FN(lv_profile, lv_profile_dup(lv->vg->vgmem, lv)) #define _lv_profile_set prop_not_implemented_set GET_LV_STR_PROPERTY_FN(lv_lockargs, lv_lock_args_dup(lv->vg->vgmem, lv)) #define _lv_lockargs_set prop_not_implemented_set +GET_LV_STR_PROPERTY_FN(cachevol, lv_cachevol_dup(lv->vg->vgmem, lv)) +#define _cachevol_set prop_not_implemented_set +GET_LV_STR_PROPERTY_FN(cachevol_uuid, lv_cachevol_uuid_dup(lv->vg->vgmem, lv)) +#define _cachevol_uuid_set prop_not_implemented_set /* VG */ GET_VG_STR_PROPERTY_FN(vg_fmt, vg_fmt_dup(vg)) diff --git a/lib/report/report.c b/lib/report/report.c index 369f47c8a..75028d432 100644 --- a/lib/report/report.c +++ b/lib/report/report.c @@ -3765,6 +3765,37 @@ static int _lvhistorical_disp(struct dm_report *rh, struct dm_pool *mem, return _binary_disp(rh, mem, field, lv_is_historical(lv), "historical", private); } +static int _do_cachevol_disp(struct dm_report *rh, struct dm_pool *mem, + struct dm_report_field *field, + const void *data, void *private, + int uuid) +{ + const struct logical_volume *lv = (const struct logical_volume *) data; + struct logical_volume *cachevol_lv = lv_cachevol_lv(lv); + + if (!cachevol_lv) + return _field_set_value(field, "", NULL); + + if (uuid) + return _uuid_disp(rh, mem, field, &cachevol_lv->lvid.id[1], private); + + return _lvname_disp(rh, mem, field, cachevol_lv, private); +} + +static int _cachevol_disp(struct dm_report *rh, struct dm_pool *mem, + struct dm_report_field *field, + const void *data, void *private) +{ + return _do_cachevol_disp(rh, mem, field, data, private, 0); +} + +static int _cachevoluuid_disp(struct dm_report *rh, struct dm_pool *mem, + struct dm_report_field *field, + const void *data, void *private) +{ + return _do_cachevol_disp(rh, mem, field, data, private, 1); +} + /* * Macro to generate '_cache_<cache_status_field_name>_disp' reporting function. * The 'cache_status_field_name' is field name from struct dm_cache_status. |