diff --git a/WHATS_NEW b/WHATS_NEW index bb8cd8d75..d824289ad 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.112 - ===================================== + Report some basic percentage info for cache pools. Introduce size_mb_arg_with_percent() for advanced size arg reading. Add extra support for '.' as decimal point in size args. Configurable support for creation of sparse volumes with thin-pools. diff --git a/lib/report/properties.c b/lib/report/properties.c index 8f4f47250..3389087a4 100644 --- a/lib/report/properties.c +++ b/lib/report/properties.c @@ -104,10 +104,21 @@ static dm_percent_t _snap_percent(const struct logical_volume *lv) static dm_percent_t _data_percent(const struct logical_volume *lv) { dm_percent_t percent; + struct lv_status_cache *status; if (lv_is_cow(lv)) return _snap_percent(lv); + if (lv_is_cache(lv) || lv_is_cache_pool(lv)) { + if (!lv_cache_status(lv, &status)) { + stack; + return DM_PERCENT_INVALID; + } + percent = status->dirty_usage; + dm_pool_destroy(status->mem); + return percent; + } + if (lv_is_thin_volume(lv)) return lv_thin_percent(lv, 0, &percent) ? percent : DM_PERCENT_INVALID; @@ -117,8 +128,22 @@ static dm_percent_t _data_percent(const struct logical_volume *lv) static dm_percent_t _metadata_percent(const struct logical_volume *lv) { dm_percent_t percent; + struct lv_status_cache *status; - return lv_thin_pool_percent(lv, 1, &percent) ? percent : DM_PERCENT_INVALID; + if (lv_is_cache(lv) || lv_is_cache_pool(lv)) { + if (!lv_cache_status(lv, &status)) { + stack; + return DM_PERCENT_INVALID; + } + percent = status->dirty_usage; + dm_pool_destroy(status->mem); + return percent; + } + + if (lv_is_thin_pool(lv)) + return lv_thin_pool_percent(lv, 1, &percent) ? percent : DM_PERCENT_INVALID; + + return DM_PERCENT_INVALID; } /* PV */ diff --git a/lib/report/report.c b/lib/report/report.c index f2ed0ae8d..c74bbfa28 100644 --- a/lib/report/report.c +++ b/lib/report/report.c @@ -1,6 +1,6 @@ /* * Copyright (C) 2002-2004 Sistina Software, Inc. All rights reserved. - * Copyright (C) 2004-2013 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2014 Red Hat, Inc. All rights reserved. * * This file is part of LVM2. * @@ -1057,13 +1057,18 @@ static int _copypercent_disp(struct dm_report *rh, const void *data, void *private __attribute__((unused))) { const struct logical_volume *lv = (const struct logical_volume *) data; + struct lv_status_cache *status; dm_percent_t percent = DM_PERCENT_INVALID; if (((lv_is_raid(lv) && lv_raid_percent(lv, &percent)) || (lv_is_mirror(lv) && lv_mirror_percent(lv->vg->cmd, lv, 0, &percent, NULL))) && (percent != DM_PERCENT_INVALID)) { percent = copy_percent(lv); - return dm_report_field_percent(rh, field, &percent); + } else if (lv_is_cache(lv) || lv_is_cache_pool(lv)) { + if (lv_cache_status(lv, &status)) { + percent = status->dirty_usage; + dm_pool_destroy(status->mem); + } } return dm_report_field_percent(rh, field, &percent); @@ -1149,6 +1154,7 @@ static int _datapercent_disp(struct dm_report *rh, struct dm_pool *mem, { const struct logical_volume *lv = (const struct logical_volume *) data; dm_percent_t percent = DM_PERCENT_INVALID; + struct lv_status_cache *status; if (lv_is_cow(lv)) return _snpercent_disp(rh, mem, field, data, private); @@ -1156,6 +1162,12 @@ static int _datapercent_disp(struct dm_report *rh, struct dm_pool *mem, (void) lv_thin_pool_percent(lv, 0, &percent); else if (lv_is_thin_volume(lv)) (void) lv_thin_percent(lv, 0, &percent); + else if (lv_is_cache(lv) || lv_is_cache_pool(lv)) { + if (lv_cache_status(lv, &status)) { + percent = status->data_usage; + dm_pool_destroy(status->mem); + } + } return dm_report_field_percent(rh, field, &percent); } @@ -1167,11 +1179,18 @@ static int _metadatapercent_disp(struct dm_report *rh, { const struct logical_volume *lv = (const struct logical_volume *) data; dm_percent_t percent = DM_PERCENT_INVALID; + struct lv_status_cache *status; if (lv_is_thin_pool(lv)) (void) lv_thin_pool_percent(lv, 1, &percent); else if (lv_is_thin_volume(lv)) (void) lv_thin_percent(lv, 1, &percent); + else if (lv_is_cache(lv) || lv_is_cache_pool(lv)) { + if (lv_cache_status(lv, &status)) { + percent = status->metadata_usage; + dm_pool_destroy(status->mem); + } + } return dm_report_field_percent(rh, field, &percent); }