diff --git a/WHATS_NEW b/WHATS_NEW index 65f845f1e..04994690f 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.141 - ==================================== + Add kernel_cache_settings report field for cache LV settings used in kernel. Version 2.02.140 - 16th January 2016 ==================================== diff --git a/lib/report/columns.h b/lib/report/columns.h index e097fece8..9bd9fd46e 100644 --- a/lib/report/columns.h +++ b/lib/report/columns.h @@ -112,6 +112,7 @@ FIELD(LVSSTATUS, lv, NUM, "CacheReadHits", lvid, 16, cache_read_hits, cache_read FIELD(LVSSTATUS, lv, NUM, "CacheReadMisses", lvid, 16, cache_read_misses, cache_read_misses, "Cache read misses.", 0) FIELD(LVSSTATUS, lv, NUM, "CacheWriteHits", lvid, 16, cache_write_hits, cache_write_hits, "Cache write hits.", 0) FIELD(LVSSTATUS, lv, NUM, "CacheWriteMisses", lvid, 16, cache_write_misses, cache_write_misses, "Cache write misses.", 0) +FIELD(LVSSTATUS, lv, STR_LIST, "KCache Settings", lvid, 18, kernel_cache_settings, kernel_cache_settings, "Cache settings/parameters as set in kernel, including default values (cached segments only).", 0) FIELD(LVSSTATUS, lv, STR, "Health", lvid, 15, lvhealthstatus, lv_health_status, "LV health status.", 0) FIELD(LVSSTATUS, lv, STR, "KDiscards", lvid, 8, kdiscards, kernel_discards, "For thin pools, how discards are handled in kernel.", 0) diff --git a/lib/report/properties.c b/lib/report/properties.c index 705a9b967..621883556 100644 --- a/lib/report/properties.c +++ b/lib/report/properties.c @@ -481,6 +481,8 @@ GET_LVSEG_STR_PROPERTY_FN(seg_monitor, lvseg_monitor_dup(lvseg->lv->vg->vgmem, l #define _cache_policy_set prop_not_implemented_set #define _cache_settings_get prop_not_implemented_get #define _cache_settings_set prop_not_implemented_set +#define _kernel_cache_settings_get prop_not_implemented_get +#define _kernel_cache_settings_set prop_not_implemented_set /* PVSEG */ GET_PVSEG_NUM_PROPERTY_FN(pvseg_start, pvseg->pe) diff --git a/lib/report/report.c b/lib/report/report.c index 53ff753b3..c03469ac9 100644 --- a/lib/report/report.c +++ b/lib/report/report.c @@ -1412,6 +1412,74 @@ static int _cache_settings_disp(struct dm_report *rh, struct dm_pool *mem, return _field_set_string_list(rh, field, result, private, 0); } +static int _do_get_kernel_cache_settings_list(struct dm_pool *mem, + int cache_argc, char **cache_argv, + struct dm_list *result) +{ + const char *key, *value; + char *buf; + size_t buf_len; + int i; + + for (i = 0; i+1 < cache_argc; i += 2) { + key = cache_argv[i]; + value = cache_argv[i+1]; + /* +1 for "=" char and +1 for trailing zero */ + buf_len = strlen(key) + strlen(value) + 2; + if (!(buf = dm_pool_alloc(mem, buf_len))) + return_0; + dm_snprintf(buf, buf_len, "%s=%s", key, value); + if (!str_list_add_no_dup_check(mem, result, buf)) + return_0; + } + + return 1; +} + +static int _get_kernel_cache_settings_list(struct dm_pool *mem, + struct dm_status_cache *cache_status, + struct dm_list **result) +{ + if (!(*result = str_list_create(mem))) + return_0; + + if (!_do_get_kernel_cache_settings_list(mem, cache_status->core_argc, + cache_status->core_argv, *result)) + return_0; + + if (!_do_get_kernel_cache_settings_list(mem, cache_status->policy_argc, + cache_status->policy_argv, *result)) + return_0; + + return 1; +} + +static int _kernel_cache_settings_disp(struct dm_report *rh, struct dm_pool *mem, + struct dm_report_field *field, + const void *data, void *private) +{ + const struct lv_with_info_and_seg_status *lvdm = (const struct lv_with_info_and_seg_status *) data; + struct dm_list dummy_list; /* dummy list to display "nothing" */ + struct dm_list *result; + int r = 0; + + if (lvdm->seg_status.type != SEG_STATUS_CACHE) { + dm_list_init(&dummy_list); + return _field_set_string_list(rh, field, &dummy_list, private, 0); + } + + if (!(mem = dm_pool_create("reporter_pool", 1024))) + return_0; + + if (!_get_kernel_cache_settings_list(mem, lvdm->seg_status.cache, &result)) + goto_out; + + r = _field_set_string_list(rh, field, result, private, 0); +out: + dm_pool_destroy(mem); + return r; +} + static int _cache_policy_disp(struct dm_report *rh, struct dm_pool *mem, struct dm_report_field *field, const void *data, void *private)