1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-03-11 20:58:50 +03:00

polldaemon: read progress info from lvmpolld answer

This commit is contained in:
Ondrej Kozina 2016-03-10 16:38:28 +01:00
parent 3ec31733dc
commit 181325c108
2 changed files with 20 additions and 75 deletions

View File

@ -27,6 +27,7 @@ struct progress_info {
unsigned finished:1;
int cmd_signal;
int cmd_retcode;
dm_percent_t percents;
};
static int _lvmpolld_use;
@ -167,9 +168,11 @@ static struct progress_info _request_progress_info(const char *uuid, unsigned ab
}
if (!strcmp(daemon_reply_str(rep, "response", ""), LVMPD_RESP_IN_PROGRESS)) {
ret.percents = (dm_percent_t) daemon_reply_int(rep, LVMPD_PARM_DATA, -1);
ret.finished = 0;
ret.error = 0;
} else if (!strcmp(daemon_reply_str(rep, "response", ""), LVMPD_RESP_FINISHED)) {
ret.percents = (dm_percent_t) daemon_reply_int(rep, LVMPD_PARM_DATA, -1);
if (!strcmp(daemon_reply_str(rep, "reason", ""), LVMPD_REAS_SIGNAL))
ret.cmd_signal = daemon_reply_int(rep, LVMPD_PARM_VALUE, 0);
else
@ -339,6 +342,22 @@ int lvmpolld_request_info(const struct poll_operation_id *id, const struct daemo
if (info.error)
return_0;
/*
* not interested in progress info for pvmoves in abort
* or while merging thin snapshot
*/
if (!parms->aborting && !(parms->lv_type & THIN_VOLUME)) {
if (parms->progress_display)
log_print_unless_silent("%s: %s: %.1f%%",
id->display_name,
parms->progress_title,
dm_percent_to_float(info.percents));
else
log_verbose("%s: %s: %.1f%%", id->display_name,
parms->progress_title,
dm_percent_to_float(info.percents));
}
if (info.finished) {
if (info.cmd_signal)
log_error("Command executed by lvmpolld got terminated by signal (%d).",

View File

@ -379,77 +379,6 @@ typedef struct {
struct dm_list idls;
} lvmpolld_parms_t;
static int report_progress(struct cmd_context *cmd, struct poll_operation_id *id,
struct daemon_parms *parms)
{
struct volume_group *vg;
struct logical_volume *lv;
uint32_t lockd_state = 0;
int ret;
/*
* It's reasonable to expect a lockd_vg("sh") here, but it should
* not actually be needed, because we only report the progress on
* the same host where the pvmove/lvconvert is happening. This means
* that the local pvmove/lvconvert/lvpoll commands are updating the
* local lvmetad with the latest info they have, and we just need to
* read the latest info that they have put into lvmetad about their
* progress. No VG lock is needed to protect anything here (we're
* just reading the VG), and no VG lock is needed to force a VG read
* from disk to get changes from other hosts, because the only change
* to the VG we're interested in is the change done locally.
*/
vg = vg_read(cmd, id->vg_name, NULL, 0, lockd_state);
if (vg_read_error(vg)) {
release_vg(vg);
log_error("Can't reread VG for %s", id->display_name);
ret = 0;
goto out_ret;
}
lv = find_lv(vg, id->lv_name);
if (lv && id->uuid && strcmp(id->uuid, (char *)&lv->lvid))
lv = NULL;
/*
* CONVERTING is set only during mirror upconversion but we may need to
* read LV's progress info even when it's not converting (linear->mirror)
*/
if (lv && (parms->lv_type ^ CONVERTING) && !(lv->status & parms->lv_type))
lv = NULL;
if (!lv) {
if (parms->lv_type == PVMOVE)
log_verbose("%s: No pvmove in progress - already finished or aborted.",
id->display_name);
else
log_verbose("Can't find LV in %s for %s. Already finished or removed.",
vg->name, id->display_name);
ret = 1;
goto out;
}
if (!lv_is_active_locally(lv)) {
log_verbose("%s: Interrupted: No longer active.", id->display_name);
ret = 1;
goto out;
}
if (parms->poll_fns->poll_progress(cmd, lv, id->display_name, parms) == PROGRESS_CHECK_FAILED) {
ret = 0;
goto out;
}
ret = 1;
out:
unlock_and_release_vg(cmd, vg, vg->name);
out_ret:
return ret;
}
static int _lvmpolld_init_poll_vg(struct cmd_context *cmd, const char *vgname,
struct volume_group *vg, struct processing_handle *handle)
{
@ -518,8 +447,6 @@ static void _lvmpolld_poll_for_all_vgs(struct cmd_context *cmd,
&finished);
if (!r || finished)
dm_list_del(&idl->list);
else if (!parms->aborting)
report_progress(cmd, idl->id, lpdp.parms);
}
if (lpdp.parms->interval)
@ -547,8 +474,7 @@ static int _lvmpoll_daemon(struct cmd_context *cmd, struct poll_operation_id *id
if (r && !parms->background) {
while (1) {
if (!(r = lvmpolld_request_info(id, parms, &finished)) ||
finished ||
(!parms->aborting && !(r = report_progress(cmd, id, parms))))
finished)
break;
if (parms->interval)