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

Generalise polldaemon code by changing mirror-specific variable names.

This commit is contained in:
Alasdair Kergon 2009-09-29 19:35:26 +00:00
parent 64a950108c
commit 724de2791e
3 changed files with 34 additions and 33 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.54 -
=====================================
Generalise polldaemon code by changing mirror-specific variable names.
Don't attempt to deactivate an LV if any of its snapshots are in use.
Return fail if lv_deactivate fails to remove device from kernel.
Provide alternative implementation of obsolete siginterrupt().

View File

@ -63,9 +63,9 @@ static int _become_daemon(struct cmd_context *cmd)
return 1;
}
static int _check_mirror_status(struct cmd_context *cmd,
static int _check_lv_status(struct cmd_context *cmd,
struct volume_group *vg,
struct logical_volume *lv_mirr,
struct logical_volume *lv,
const char *name, struct daemon_parms *parms,
int *finished)
{
@ -77,22 +77,22 @@ static int _check_mirror_status(struct cmd_context *cmd,
*finished = 1;
if (parms->aborting) {
if (!(lvs_changed = lvs_using_lv(cmd, vg, lv_mirr))) {
if (!(lvs_changed = lvs_using_lv(cmd, vg, lv))) {
log_error("Failed to generate list of copied LVs: "
"can't abort.");
return 0;
}
parms->poll_fns->finish_copy(cmd, vg, lv_mirr, lvs_changed);
parms->poll_fns->finish_copy(cmd, vg, lv, lvs_changed);
return 0;
}
if (!lv_mirror_percent(cmd, lv_mirr, !parms->interval, &segment_percent,
if (!lv_mirror_percent(cmd, lv, !parms->interval, &segment_percent,
&event_nr)) {
log_error("ABORTING: Mirror percentage check failed.");
return 0;
}
overall_percent = copy_percent(lv_mirr);
overall_percent = copy_percent(lv);
if (parms->progress_display)
log_print("%s: %s: %.1f%%", name, parms->progress_title,
overall_percent);
@ -106,22 +106,20 @@ static int _check_mirror_status(struct cmd_context *cmd,
return 1;
}
if (!(lvs_changed = lvs_using_lv(cmd, vg, lv_mirr))) {
if (!(lvs_changed = lvs_using_lv(cmd, vg, lv))) {
log_error("ABORTING: Failed to generate list of copied LVs");
return 0;
}
/* Finished? Or progress to next segment? */
if (overall_percent >= 100.0) {
if (!parms->poll_fns->finish_copy(cmd, vg, lv_mirr,
lvs_changed))
if (!parms->poll_fns->finish_copy(cmd, vg, lv, lvs_changed))
return 0;
} else {
if (!parms->poll_fns->update_metadata(cmd, vg, lv_mirr,
lvs_changed, 0)) {
if (!parms->poll_fns->update_metadata(cmd, vg, lv, lvs_changed,
0)) {
log_error("ABORTING: Segment progression failed.");
parms->poll_fns->finish_copy(cmd, vg, lv_mirr,
lvs_changed);
parms->poll_fns->finish_copy(cmd, vg, lv, lvs_changed);
return 0;
}
*finished = 0; /* Another segment */
@ -130,14 +128,14 @@ static int _check_mirror_status(struct cmd_context *cmd,
return 1;
}
static int _wait_for_single_mirror(struct cmd_context *cmd, const char *name, const char *uuid,
static int _wait_for_single_lv(struct cmd_context *cmd, const char *name, const char *uuid,
struct daemon_parms *parms)
{
struct volume_group *vg;
struct logical_volume *lv_mirr;
struct logical_volume *lv;
int finished = 0;
/* Poll for mirror completion */
/* Poll for completion */
while (!finished) {
/* FIXME Also needed in vg/lvchange -ay? */
/* FIXME Use alarm for regular intervals instead */
@ -156,7 +154,7 @@ static int _wait_for_single_mirror(struct cmd_context *cmd, const char *name, co
return 0;
}
if (!(lv_mirr = parms->poll_fns->get_copy_lv(cmd, vg, name, uuid,
if (!(lv = parms->poll_fns->get_copy_lv(cmd, vg, name, uuid,
parms->lv_type))) {
log_error("ABORTING: Can't find mirror LV in %s for %s",
vg->name, name);
@ -164,8 +162,7 @@ static int _wait_for_single_mirror(struct cmd_context *cmd, const char *name, co
return 0;
}
if (!_check_mirror_status(cmd, vg, lv_mirr, name, parms,
&finished)) {
if (!_check_lv_status(cmd, vg, lv, name, parms, &finished)) {
unlock_and_release_vg(cmd, vg, vg->name);
return 0;
}
@ -181,20 +178,20 @@ static int _poll_vg(struct cmd_context *cmd, const char *vgname,
{
struct daemon_parms *parms = (struct daemon_parms *) handle;
struct lv_list *lvl;
struct logical_volume *lv_mirr;
struct logical_volume *lv;
const char *name;
int finished;
dm_list_iterate_items(lvl, &vg->lvs) {
lv_mirr = lvl->lv;
if (!(lv_mirr->status & parms->lv_type))
lv = lvl->lv;
if (!(lv->status & parms->lv_type))
continue;
if (!(name = parms->poll_fns->get_copy_name_from_lv(lv_mirr)))
if (!(name = parms->poll_fns->get_copy_name_from_lv(lv)))
continue;
/* FIXME Need to do the activation from _set_up_pvmove here
* if it's not running and we're not aborting */
if (_check_mirror_status(cmd, vg, lv_mirr, name,
parms, &finished) && !finished)
if (_check_lv_status(cmd, vg, lv, name, parms, &finished) &&
!finished)
parms->outstanding_count++;
}
@ -249,8 +246,11 @@ int poll_daemon(struct cmd_context *cmd, const char *name, const char *uuid,
/* fork one daemon per copy? */
}
/*
* Process one specific task or all incomplete tasks?
*/
if (name) {
if (!_wait_for_single_mirror(cmd, name, uuid, &parms)) {
if (!_wait_for_single_lv(cmd, name, uuid, &parms)) {
stack;
return ECMD_FAILED;
}

View File

@ -19,7 +19,7 @@
#include "metadata-exported.h"
struct poll_functions {
const char *(*get_copy_name_from_lv) (struct logical_volume *lv_mirr);
const char *(*get_copy_name_from_lv) (struct logical_volume *lv);
struct volume_group *(*get_copy_vg) (struct cmd_context *cmd,
const char *name,
const char *uuid);
@ -30,11 +30,11 @@ struct poll_functions {
uint32_t lv_type);
int (*update_metadata) (struct cmd_context *cmd,
struct volume_group *vg,
struct logical_volume *lv_mirr,
struct logical_volume *lv,
struct dm_list *lvs_changed, unsigned flags);
int (*finish_copy) (struct cmd_context *cmd,
struct volume_group *vg,
struct logical_volume *lv_mirr,
struct logical_volume *lv,
struct dm_list *lvs_changed);
};