1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

cache: report metadata percentage

Reinstantiate reporting of metadata percent usage for cache volumes.
Also show the same percentage with hidden cache-pool LV.
This regression was caused by optimization for a single-ioctl in
2.02.155.
This commit is contained in:
Zdenek Kabelac 2016-09-09 14:24:49 +02:00
parent a13440d7ca
commit 4b22cd81e6
5 changed files with 32 additions and 1 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.166 -
=====================================
Restore reporting of metadata usage for cache volumes (2.02.155).
Support raid scrubbing on cache origin LV.
Version 2.02.165 - 7th September 2016

View File

@ -153,6 +153,7 @@ struct dev_manager;
#define seg_is_striped_target(seg) segtype_is_striped_target((seg)->segtype)
#define seg_is_cache(seg) segtype_is_cache((seg)->segtype)
#define seg_is_cache_pool(seg) segtype_is_cache_pool((seg)->segtype)
#define seg_is_used_cache_pool(seg) (seg_is_cache_pool(seg) && (!dm_list_empty(&(seg->lv)->segs_using_this_lv)))
#define seg_is_linear(seg) (seg_is_striped(seg) && ((seg)->area_count == 1))
#define seg_is_mirror(seg) segtype_is_mirror((seg)->segtype)
#define seg_is_mirrored(seg) segtype_is_mirrored((seg)->segtype)

View File

@ -2939,6 +2939,7 @@ static int _metadatapercent_disp(struct dm_report *rh,
dm_percent_t percent = DM_PERCENT_INVALID;
if (lv_is_thin_pool(lvdm->lv) ||
lv_is_cache(lvdm->lv) ||
lv_is_used_cache_pool(lvdm->lv))
percent = lvseg_percent_with_info_and_seg_status(lvdm, PERCENT_GET_METADATA);

View File

@ -81,6 +81,22 @@ check lv_field $vg/pool7 segtype "cache-pool"
lvremove -f $vg
# Check the percentage values are reported for both cache and cache-pool
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 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 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
lvremove -f $vg
# Validate ambiguous pool name is detected
invalid lvcreate -l 1 --type cache-pool --cachepool pool1 $vg/pool2
invalid lvcreate -l 1 --type cache-pool --name pool3 --cachepool pool4 $vg

View File

@ -89,6 +89,12 @@ static int _vgs_single(struct cmd_context *cmd __attribute__((unused)),
static void _choose_lv_segment_for_status_report(const struct logical_volume *lv, const struct lv_segment **lv_seg)
{
if (lv_is_used_cache_pool(lv)) {
/* For a used cache pool, choose cache volume segment */
*lv_seg = get_only_segment_using_this_lv(lv);
return;
}
/*
* By default, take the first LV segment to report status for.
* If there's any other specific segment that needs to be
@ -115,8 +121,9 @@ static int _do_info_and_status(struct cmd_context *cmd,
if (do_status) {
if (!(status->seg_status.mem = dm_pool_create("reporter_pool", 1024)))
return_0;
if (!lv_seg)
if (!lv_seg || seg_is_used_cache_pool(lv_seg))
_choose_lv_segment_for_status_report(lv, &lv_seg);
if (do_info) {
/* both info and status */
status->info_ok = lv_info_with_seg_status(cmd, lv, lv_seg, use_layer, status, 1, 1);
@ -124,6 +131,11 @@ static int _do_info_and_status(struct cmd_context *cmd,
if (use_layer && status->info_ok &&
!lv_info(cmd, lv, 0, NULL, 0, 0))
memset(&status->info, 0, sizeof(status->info));
/* for inactive cache reset lvinfo for its struct for cache-pool */
if (lv_is_used_cache_pool(lv) && !status->info_ok) {
memset(&status->info, 0, sizeof(status->info));
status->info_ok = 1;
}
} else
/* status only */
status->info_ok = lv_status(cmd, lv_seg, use_layer, &status->seg_status);