diff --git a/WHATS_NEW b/WHATS_NEW index 2c47452a0..46e0c1a3d 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.166 - ===================================== + Report 0% as dirty (copy%) for cache without any used block. Fix lvm2api reporting of cache data and metadata percent. Restore reporting of metadata usage for cache volumes (2.02.155). Support raid scrubbing on cache origin LV. diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c index 233a216fd..9fbd68966 100644 --- a/lib/activate/dev_manager.c +++ b/lib/activate/dev_manager.c @@ -1432,8 +1432,9 @@ int dev_manager_cache_status(struct dev_manager *dm, c->total_blocks); (*status)->metadata_usage = dm_make_percent(c->metadata_used_blocks, c->metadata_total_blocks); - (*status)->dirty_usage = dm_make_percent(c->dirty_blocks, - c->used_blocks); + (*status)->dirty_usage = (s->cache->used_blocks) ? + dm_make_percent(c->dirty_blocks, + c->used_blocks) : DM_PERCENT_0; } r = 1; out: diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c index 9ee67b4d2..33129e379 100644 --- a/lib/metadata/lv.c +++ b/lib/metadata/lv.c @@ -366,8 +366,9 @@ dm_percent_t lvseg_percent_with_info_and_seg_status(const struct lv_with_info_an else { switch (type) { case PERCENT_GET_DIRTY: - p = dm_make_percent(s->cache->dirty_blocks, - s->cache->used_blocks); + p = (s->cache->used_blocks) ? + dm_make_percent(s->cache->dirty_blocks, + s->cache->used_blocks) : DM_PERCENT_0; break; case PERCENT_GET_METADATA: p = dm_make_percent(s->cache->metadata_used_blocks, diff --git a/test/shell/lvcreate-cache.sh b/test/shell/lvcreate-cache.sh index 52d36a146..c53d2430f 100644 --- a/test/shell/lvcreate-cache.sh +++ b/test/shell/lvcreate-cache.sh @@ -85,15 +85,15 @@ lvremove -f $vg lvcreate --type cache-pool -L1 $vg/cpool lvcreate -H -L4 -n $lv1 $vg/cpool -check lv_field $vg/$lv1 copy_percent "100.00" +check lv_field $vg/$lv1 copy_percent "0.00" check lv_field $vg/$lv1 data_percent "0.00" check lv_field $vg/$lv1 metadata_percent "0.78" -check lv_field $vg/cpool copy_percent "100.00" +check lv_field $vg/cpool copy_percent "0.00" check lv_field $vg/cpool data_percent "0.00" check lv_field $vg/cpool metadata_percent "0.78" # check we also display percent value for segmented output (-o+devices) lvs -a -o+devices $vg/cpool | tee out -grep "100.00" out +grep "0.00" out lvremove -f $vg