mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-03 05:18:29 +03:00
Add percent_range to copy_percent too.
This commit is contained in:
parent
78ad1549a5
commit
3d32c5f88b
@ -691,7 +691,8 @@ struct logical_volume *find_pvmove_lv_from_pvname(struct cmd_context *cmd,
|
||||
uint32_t lv_type);
|
||||
const char *get_pvmove_pvname_from_lv(struct logical_volume *lv);
|
||||
const char *get_pvmove_pvname_from_lv_mirr(struct logical_volume *lv_mirr);
|
||||
float copy_percent(struct logical_volume *lv_mirr);
|
||||
float copy_percent(struct logical_volume *lv_mirr,
|
||||
percent_range_t *percent_range);
|
||||
struct dm_list *lvs_using_lv(struct cmd_context *cmd, struct volume_group *vg,
|
||||
struct logical_volume *lv);
|
||||
|
||||
|
@ -1114,7 +1114,8 @@ struct dm_list *lvs_using_lv(struct cmd_context *cmd, struct volume_group *vg,
|
||||
return lvs;
|
||||
}
|
||||
|
||||
float copy_percent(struct logical_volume *lv_mirr)
|
||||
float copy_percent(struct logical_volume *lv_mirr,
|
||||
percent_range_t *percent_range)
|
||||
{
|
||||
uint32_t numerator = 0u, denominator = 0u;
|
||||
struct lv_segment *seg;
|
||||
@ -1128,6 +1129,13 @@ float copy_percent(struct logical_volume *lv_mirr)
|
||||
numerator += seg->area_len;
|
||||
}
|
||||
|
||||
if (!denominator || (numerator == denominator))
|
||||
*percent_range = PERCENT_100;
|
||||
else if (numerator == 0)
|
||||
*percent_range = PERCENT_0;
|
||||
else
|
||||
*percent_range = PERCENT_0_TO_100;
|
||||
|
||||
return denominator ? (float) numerator *100 / denominator : 100.0;
|
||||
}
|
||||
|
||||
|
@ -1054,7 +1054,8 @@ static int _snpercent_disp(struct dm_report *rh __attribute((unused)), struct dm
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _copypercent_disp(struct dm_report *rh __attribute((unused)), struct dm_pool *mem,
|
||||
static int _copypercent_disp(struct dm_report *rh __attribute((unused)),
|
||||
struct dm_pool *mem,
|
||||
struct dm_report_field *field,
|
||||
const void *data, void *private __attribute((unused)))
|
||||
{
|
||||
@ -1077,7 +1078,7 @@ static int _copypercent_disp(struct dm_report *rh __attribute((unused)), struct
|
||||
return 1;
|
||||
}
|
||||
|
||||
percent = copy_percent(lv);
|
||||
percent = copy_percent(lv, &percent_range);
|
||||
|
||||
if (!(repstr = dm_pool_zalloc(mem, 8))) {
|
||||
log_error("dm_pool_alloc failed");
|
||||
|
@ -68,7 +68,7 @@ progress_t poll_mirror_progress(struct cmd_context *cmd,
|
||||
struct daemon_parms *parms)
|
||||
{
|
||||
float segment_percent = 0.0, overall_percent = 0.0;
|
||||
percent_range_t percent_range;
|
||||
percent_range_t percent_range, overall_percent_range;
|
||||
uint32_t event_nr = 0;
|
||||
|
||||
if (!lv_mirror_percent(cmd, lv, !parms->interval, &segment_percent,
|
||||
@ -78,7 +78,7 @@ progress_t poll_mirror_progress(struct cmd_context *cmd,
|
||||
return PROGRESS_CHECK_FAILED;
|
||||
}
|
||||
|
||||
overall_percent = copy_percent(lv);
|
||||
overall_percent = copy_percent(lv, &overall_percent_range);
|
||||
if (parms->progress_display)
|
||||
log_print("%s: %s: %.1f%%", name, parms->progress_title,
|
||||
overall_percent);
|
||||
@ -89,7 +89,7 @@ progress_t poll_mirror_progress(struct cmd_context *cmd,
|
||||
if (percent_range != PERCENT_100)
|
||||
return PROGRESS_UNFINISHED;
|
||||
|
||||
if (overall_percent >= 100.0)
|
||||
if (overall_percent_range == PERCENT_100)
|
||||
return PROGRESS_FINISHED_ALL;
|
||||
|
||||
return PROGRESS_FINISHED_SEGMENT;
|
||||
|
Loading…
Reference in New Issue
Block a user