diff options
author | Zdenek Kabelac <zkabelac@redhat.com> | 2017-03-02 00:15:11 +0100 |
---|---|---|
committer | Zdenek Kabelac <zkabelac@redhat.com> | 2017-03-10 19:33:01 +0100 |
commit | 52935b5834b6592acab1e68df18b9779de54033f (patch) | |
tree | c188c7ca57233ff6ce97f1f433c99fb0db6eb2fe /lib/cache_segtype | |
parent | 4d2b1a06603d09e815af5bf8687972a000683841 (diff) | |
download | lvm2-52935b5834b6592acab1e68df18b9779de54033f.tar.gz |
cache: enhance lvdisplay for cache volumes
Better support for lvdisplay.
By default info about running (in kernel) cache status is printed.
To get 'segtype' info, user runs: 'lvdisplay -m', example:
--- Logical volume ---
LV Path /dev/vg/lvol0
LV Name lvol0
VG Name vg
LV UUID Y4uWuN-TBGk-duer-aPWl-yBWn-iFFR-RU1gg1
LV Write Access read/write
LV Creation host, time linux, 2017-03-01 20:52:39 +0100
LV Cache pool name lvol2
LV Cache origin name lvol0_corig
LV Status available
# open 0
LV Size 12,00 MiB
Cache used blocks 10,42%
Cache metadata blocks 0,49%
Cache dirty blocks 0,00%
Cache read hits/misses 112 / 34
Cache wrt hits/misses 133 / 0
Cache demotions 0
Cache promotions 20
Current LE 3
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Segments ---
Logical extents 0 to 2:
Type cache
Chunk size 64,00 KiB
Metadata format 1
Mode writethrough
Policy smq
Setting migration_threshold=100000
Diffstat (limited to 'lib/cache_segtype')
-rw-r--r-- | lib/cache_segtype/cache.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/cache_segtype/cache.c b/lib/cache_segtype/cache.c index 312978367..55b4c6e7e 100644 --- a/lib/cache_segtype/cache.c +++ b/lib/cache_segtype/cache.c @@ -36,6 +36,31 @@ static unsigned _feature_mask; log_error(t " segment %s of logical volume %s.", ## p, \ dm_config_parent_name(sn), seg->lv->name), 0; +static int _cache_out_line(const char *line, void *_f) +{ + log_print(" Setting\t\t%s", line); + + return 1; +} + +static void _cache_display(const struct lv_segment *seg) +{ + const struct dm_config_node *n; + const struct lv_segment *pool_seg = + seg_is_cache_pool(seg) ? seg : first_seg(seg->pool_lv); + + log_print(" Chunk size\t\t%s", + display_size(seg->lv->vg->cmd, pool_seg->chunk_size)); + log_print(" Metadata format\t%u", pool_seg->cache_metadata_format); + log_print(" Mode\t\t%s", get_cache_mode_name(pool_seg)); + log_print(" Policy\t\t%s", pool_seg->policy_name); + + if ((n = pool_seg->policy_settings->child)) + dm_config_write_node(n, _cache_out_line, NULL); + + log_print(" "); +} + /* * When older metadata are loaded without newer settings, * set then to default settings (the one that could have been @@ -356,6 +381,7 @@ static int _modules_needed(struct dm_pool *mem, #endif /* DEVMAPPER_SUPPORT */ static struct segtype_handler _cache_pool_ops = { + .display = _cache_display, .text_import = _cache_pool_text_import, .text_import_area_count = _cache_pool_text_import_area_count, .text_export = _cache_pool_text_export, @@ -519,6 +545,7 @@ static int _cache_add_target_line(struct dev_manager *dm, #endif /* DEVMAPPER_SUPPORT */ static struct segtype_handler _cache_ops = { + .display = _cache_display, .text_import = _cache_text_import, .text_import_area_count = _cache_text_import_area_count, .text_export = _cache_text_export, |