1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-03 05:18:29 +03:00

cleanup: use display_percent

Replace occurence of %.2f with call of display_percent function.
This commit is contained in:
Zdenek Kabelac 2017-06-24 16:22:36 +02:00
parent 07eec06f5d
commit 1bd4b0059b
6 changed files with 39 additions and 37 deletions

View File

@ -1037,7 +1037,8 @@ static int _percent_run(struct dev_manager *dm, const char *name,
goto_out; goto_out;
} }
log_debug_activation("LV percent: %.2f", dm_percent_to_float(*overall_percent)); log_debug_activation("LV percent: %s",
display_percent(dm->cmd, *overall_percent));
r = 1; r = 1;
out: out:

View File

@ -549,12 +549,12 @@ int lvdisplay_full(struct cmd_context *cmd,
snap_seg ? snap_seg->origin->size : lv->size)); snap_seg ? snap_seg->origin->size : lv->size));
if (cache_status) { if (cache_status) {
log_print("Cache used blocks %.2f%%", log_print("Cache used blocks %s%%",
dm_percent_to_float(cache_status->data_usage)); display_percent(cmd, cache_status->data_usage));
log_print("Cache metadata blocks %.2f%%", log_print("Cache metadata blocks %s%%",
dm_percent_to_float(cache_status->metadata_usage)); display_percent(cmd, cache_status->metadata_usage));
log_print("Cache dirty blocks %.2f%%", log_print("Cache dirty blocks %s%%",
dm_percent_to_float(cache_status->dirty_usage)); display_percent(cmd, cache_status->dirty_usage));
log_print("Cache read hits/misses " FMTu64 " / " FMTu64, log_print("Cache read hits/misses " FMTu64 " / " FMTu64,
cache_status->cache->read_hits, cache_status->cache->read_hits,
cache_status->cache->read_misses); cache_status->cache->read_misses);
@ -570,16 +570,16 @@ int lvdisplay_full(struct cmd_context *cmd,
} }
if (thin_data_active) if (thin_data_active)
log_print("Allocated pool data %.2f%%", log_print("Allocated pool data %s%%",
dm_percent_to_float(thin_data_percent)); display_percent(cmd, thin_data_percent));
if (thin_metadata_active) if (thin_metadata_active)
log_print("Allocated metadata %.2f%%", log_print("Allocated metadata %s%%",
dm_percent_to_float(thin_metadata_percent)); display_percent(cmd, thin_metadata_percent));
if (thin_active) if (thin_active)
log_print("Mapped size %.2f%%", log_print("Mapped size %s%%",
dm_percent_to_float(thin_percent)); display_percent(cmd, thin_percent));
log_print("Current LE %u", log_print("Current LE %u",
snap_seg ? snap_seg->origin->le_count : lv->le_count); snap_seg ? snap_seg->origin->le_count : lv->le_count);
@ -590,8 +590,8 @@ int lvdisplay_full(struct cmd_context *cmd,
log_print("COW-table LE %u", lv->le_count); log_print("COW-table LE %u", lv->le_count);
if (snap_active) if (snap_active)
log_print("Allocated to snapshot %.2f%%", log_print("Allocated to snapshot %s%%",
dm_percent_to_float(snap_percent)); display_percent(cmd, snap_percent));
log_print("Snapshot chunk size %s", log_print("Snapshot chunk size %s",
display_size(cmd, (uint64_t) snap_seg->chunk_size)); display_size(cmd, (uint64_t) snap_seg->chunk_size));

View File

@ -1273,11 +1273,11 @@ uint32_t extents_from_percent_size(struct volume_group *vg, const struct dm_list
} }
if (!(count = percent_of_extents(size, extents, roundup))) if (!(count = percent_of_extents(size, extents, roundup)))
log_error("Converted %.2f%%%s into 0 extents.", log_error("Converted %s%%%s into 0 extents.",
(double) size / DM_PERCENT_1, get_percent_string(percent)); display_percent(vg->cmd, size), get_percent_string(percent));
else else
log_verbose("Converted %.2f%%%s into %" PRIu32 " extents.", log_verbose("Converted %s%%%s into %" PRIu32 " extents.",
(double) size / DM_PERCENT_1, get_percent_string(percent), count); display_percent(vg->cmd, size), get_percent_string(percent), count);
return count; return count;
} }

View File

@ -241,10 +241,11 @@ int pool_metadata_min_threshold(const struct lv_segment *pool_seg)
int pool_below_threshold(const struct lv_segment *pool_seg) int pool_below_threshold(const struct lv_segment *pool_seg)
{ {
struct cmd_context *cmd = pool_seg->lv->vg->cmd;
dm_percent_t percent; dm_percent_t percent;
dm_percent_t min_threshold = pool_metadata_min_threshold(pool_seg); dm_percent_t min_threshold = pool_metadata_min_threshold(pool_seg);
dm_percent_t threshold = DM_PERCENT_1 * dm_percent_t threshold = DM_PERCENT_1 *
find_config_tree_int(pool_seg->lv->vg->cmd, activation_thin_pool_autoextend_threshold_CFG, find_config_tree_int(cmd, activation_thin_pool_autoextend_threshold_CFG,
lv_config_profile(pool_seg->lv)); lv_config_profile(pool_seg->lv));
/* Data */ /* Data */
@ -253,10 +254,10 @@ int pool_below_threshold(const struct lv_segment *pool_seg)
if (percent > threshold || percent >= DM_PERCENT_100) { if (percent > threshold || percent >= DM_PERCENT_100) {
log_debug("Threshold configured for free data space in " log_debug("Threshold configured for free data space in "
"thin pool %s has been reached (%.2f%% >= %.2f%%).", "thin pool %s has been reached (%s%% >= %s%%).",
display_lvname(pool_seg->lv), display_lvname(pool_seg->lv),
dm_percent_to_float(percent), display_percent(cmd, percent),
dm_percent_to_float(threshold)); display_percent(cmd, threshold));
return 0; return 0;
} }
@ -267,21 +268,21 @@ int pool_below_threshold(const struct lv_segment *pool_seg)
if (percent >= min_threshold) { if (percent >= min_threshold) {
log_warn("WARNING: Remaining free space in metadata of thin pool %s " log_warn("WARNING: Remaining free space in metadata of thin pool %s "
"is too low (%.2f%% >= %.2f%%). " "is too low (%s%% >= %s%%). "
"Resize is recommended.", "Resize is recommended.",
display_lvname(pool_seg->lv), display_lvname(pool_seg->lv),
dm_percent_to_float(percent), display_percent(cmd, percent),
dm_percent_to_float(min_threshold)); display_percent(cmd, min_threshold));
return 0; return 0;
} }
if (percent > threshold) { if (percent > threshold) {
log_debug("Threshold configured for free metadata space in " log_debug("Threshold configured for free metadata space in "
"thin pool %s has been reached (%.2f%% > %.2f%%).", "thin pool %s has been reached (%s%% > %s%%).",
display_lvname(pool_seg->lv), display_lvname(pool_seg->lv),
dm_percent_to_float(percent), display_percent(cmd, percent),
dm_percent_to_float(threshold)); display_percent(cmd, threshold));
return 0; return 0;
} }

View File

@ -152,11 +152,11 @@ progress_t poll_merge_progress(struct cmd_context *cmd,
} }
if (parms->progress_display) if (parms->progress_display)
log_print_unless_silent("%s: %s: %.2f%%", lv->name, parms->progress_title, log_print_unless_silent("%s: %s: %s%%", lv->name, parms->progress_title,
dm_percent_to_float(DM_PERCENT_100 - percent)); display_percent(cmd, DM_PERCENT_100 - percent));
else else
log_verbose("%s: %s: %.2f%%", lv->name, parms->progress_title, log_verbose("%s: %s: %s%%", lv->name, parms->progress_title,
dm_percent_to_float(DM_PERCENT_100 - percent)); display_percent(cmd, DM_PERCENT_100 - percent));
if (percent == DM_PERCENT_0) if (percent == DM_PERCENT_0)
return PROGRESS_FINISHED_ALL; return PROGRESS_FINISHED_ALL;

View File

@ -40,11 +40,11 @@ progress_t poll_mirror_progress(struct cmd_context *cmd,
overall_percent = copy_percent(lv); overall_percent = copy_percent(lv);
if (parms->progress_display) if (parms->progress_display)
log_print_unless_silent("%s: %s: %.2f%%", name, parms->progress_title, log_print_unless_silent("%s: %s: %s%%", name, parms->progress_title,
dm_percent_to_float(overall_percent)); display_percent(cmd, overall_percent));
else else
log_verbose("%s: %s: %.2f%%", name, parms->progress_title, log_verbose("%s: %s: %s%%", name, parms->progress_title,
dm_percent_to_float(overall_percent)); display_percent(cmd, overall_percent));
if (segment_percent != DM_PERCENT_100) if (segment_percent != DM_PERCENT_100)
return PROGRESS_UNFINISHED; return PROGRESS_UNFINISHED;