report: display cache mode of a cache pool
PATCH 1/1 report: display cache mode of a cache pool
--- lib/metadata/cache_manip.c | 12 ++++++++++++ lib/metadata/lv.c | 5 +++++ lib/metadata/lv.h | 1 + lib/metadata/metadata-exported.h | 1 + lib/report/columns.h | 1 + lib/report/properties.c | 2 ++ lib/report/report.c | 19 +++++++++++++++++++ 7 files changed, 41 insertions(+)
lib/metadata/cache_manip.c +12 -0
@@ -22,6 +22,18 @@#include "activate.h" #include "defaults.h" +const char *get_cachepool_cachemode_name (uint32_t feature_flags) +{ +if (feature_flags &DM_CACHE_FEATURE_WRITEBACK ) +return "writeback" ; +else if (feature_flags &DM_CACHE_FEATURE_WRITETHROUGH ) +return "writethrough" ; +else +log_error (INTERNAL_ERROR "Unknown cachemode encountered." ); + +return "unknown" ; +} + int update_cache_pool_params(struct volume_group *vg, unsigned attr, int passed_args, uint32_t data_extents, uint64_t *pool_metadata_size,
lib/metadata/lv.c +5 -0
@@ -128,6 +128,11 @@ char *lvseg_discards_dup(struct dm_pool *mem, const struct lv_segment *seg)return dm_pool_strdup (mem,get_pool_discards_name (seg->discards)); } +char *lvseg_cachemode_dup (struct dm_pool *mem,const struct lv_segment *seg) +{ +return dm_pool_strdup (mem,get_cachepool_cachemode_name (seg->feature_flags)); +} +#ifdef DMEVENTD # include "libdevmapper-event.h" #endif
lib/metadata/lv.h +1 -0
@@ -82,6 +82,7 @@ uint64_t lvseg_size(const struct lv_segment *seg);uint64_t lvseg_chunksize (const struct lv_segment *seg);char *lvseg_segtype_dup (struct dm_pool *mem,const struct lv_segment *seg);char *lvseg_discards_dup (struct dm_pool *mem,const struct lv_segment *seg); +char *lvseg_cachemode_dup (struct dm_pool *mem,const struct lv_segment *seg);char *lvseg_monitor_dup (struct dm_pool *mem,const struct lv_segment *seg);char *lvseg_tags_dup (const struct lv_segment *seg);char *lvseg_devices (struct dm_pool *mem,const struct lv_segment *seg);
lib/metadata/metadata-exported.h +1 -0
@@ -1074,6 +1074,7 @@ int partial_raid_lv_supports_degraded_activation(struct logical_volume *lv);/* -- metadata/raid_manip.c */ /* ++ metadata/cache_manip.c */ +const char *get_cachepool_cachemode_name (uint32_t feature_flags); int update_cache_pool_params(struct volume_group *vg, unsigned attr, int passed_args, uint32_t data_extents, uint64_t *pool_metadata_size,
lib/report/columns.h +1 -0
@@ -158,6 +158,7 @@ FIELD(SEGS, seg, SIZ, "Chunk", list, 5, chunksize, chunksize, "For snapshots, th FIELD(SEGS, seg, SIZ, "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, STR, "Discards", list, 8, discards, discards, "For thin pools, how discards are handled.", 0) +FIELD(SEGS, seg, STR, "Cachemode", list, 9, cachemode, cachemode, "For cache pools, how writes are cached.", 0) FIELD(SEGS, seg, BIN, "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 ,"ThId" , list,4 , thinid, thin_id,"For thin volume, the thin device id." ,0 )
lib/report/properties.c +2 -0
@@ -380,6 +380,8 @@ GET_LVSEG_NUM_PROPERTY_FN(thin_id, lvseg->device_id)#define _thin_id_set prop_not_implemented_set GET_LVSEG_STR_PROPERTY_FN(discards, lvseg_discards_dup(lvseg->lv->vg->vgmem, lvseg))#define _discards_set prop_not_implemented_set +GET_LVSEG_STR_PROPERTY_FN(cachemode, lvseg_cachemode_dup(lvseg->lv->vg->vgmem, lvseg)) +#define _cachemode_set prop_not_implemented_set GET_LVSEG_NUM_PROPERTY_FN(seg_start, (SECTOR_SIZE * lvseg_start(lvseg)))#define _seg_start_set prop_not_implemented_setGET_LVSEG_NUM_PROPERTY_FN (seg_start_pe, lvseg->le)
lib/report/report.c +19 -0
@@ -803,6 +803,25 @@ static int _discards_disp(struct dm_report *rh, struct dm_pool *mem,return _field_set_value (field,"" ,NULL ); } +static int _cachemode_disp (struct dm_report *rh,struct dm_pool *mem, +struct dm_report_field *field, +const void *data,void *private) +{ +const struct lv_segment *seg = (const struct lv_segment *) data; + +if (seg_is_cache (seg)) + seg =first_seg (seg->pool_lv); + +if (seg_is_cache_pool (seg)) { +if (seg->feature_flags &DM_CACHE_FEATURE_WRITEBACK ) +return _field_set_value (field,"writeback" , &RESERVED (number_undef_64)); +else +return _field_set_value (field,"writethrough" , &RESERVED (number_undef_64)); + } + +return _field_set_value (field,"" ,NULL ); +} +static int _originsize_disp (struct dm_report *rh,struct dm_pool *mem,struct dm_report_field *field,const void *data,void *private)
Signature · 1 line
1.8.3.1