mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-25 10:04:17 +03:00
Generalise polldaemon code by changing mirror-specific variable names.
This commit is contained in:
parent
9cfc9b3ee2
commit
e3730ecfc3
@ -1,5 +1,6 @@
|
|||||||
Version 2.02.54 -
|
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.
|
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.
|
Return fail if lv_deactivate fails to remove device from kernel.
|
||||||
Provide alternative implementation of obsolete siginterrupt().
|
Provide alternative implementation of obsolete siginterrupt().
|
||||||
|
@ -63,11 +63,11 @@ static int _become_daemon(struct cmd_context *cmd)
|
|||||||
return 1;
|
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 volume_group *vg,
|
||||||
struct logical_volume *lv_mirr,
|
struct logical_volume *lv,
|
||||||
const char *name, struct daemon_parms *parms,
|
const char *name, struct daemon_parms *parms,
|
||||||
int *finished)
|
int *finished)
|
||||||
{
|
{
|
||||||
struct dm_list *lvs_changed;
|
struct dm_list *lvs_changed;
|
||||||
float segment_percent = 0.0, overall_percent = 0.0;
|
float segment_percent = 0.0, overall_percent = 0.0;
|
||||||
@ -77,22 +77,22 @@ static int _check_mirror_status(struct cmd_context *cmd,
|
|||||||
*finished = 1;
|
*finished = 1;
|
||||||
|
|
||||||
if (parms->aborting) {
|
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: "
|
log_error("Failed to generate list of copied LVs: "
|
||||||
"can't abort.");
|
"can't abort.");
|
||||||
return 0;
|
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;
|
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)) {
|
&event_nr)) {
|
||||||
log_error("ABORTING: Mirror percentage check failed.");
|
log_error("ABORTING: Mirror percentage check failed.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
overall_percent = copy_percent(lv_mirr);
|
overall_percent = copy_percent(lv);
|
||||||
if (parms->progress_display)
|
if (parms->progress_display)
|
||||||
log_print("%s: %s: %.1f%%", name, parms->progress_title,
|
log_print("%s: %s: %.1f%%", name, parms->progress_title,
|
||||||
overall_percent);
|
overall_percent);
|
||||||
@ -106,22 +106,20 @@ static int _check_mirror_status(struct cmd_context *cmd,
|
|||||||
return 1;
|
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");
|
log_error("ABORTING: Failed to generate list of copied LVs");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Finished? Or progress to next segment? */
|
/* Finished? Or progress to next segment? */
|
||||||
if (overall_percent >= 100.0) {
|
if (overall_percent >= 100.0) {
|
||||||
if (!parms->poll_fns->finish_copy(cmd, vg, lv_mirr,
|
if (!parms->poll_fns->finish_copy(cmd, vg, lv, lvs_changed))
|
||||||
lvs_changed))
|
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
if (!parms->poll_fns->update_metadata(cmd, vg, lv_mirr,
|
if (!parms->poll_fns->update_metadata(cmd, vg, lv, lvs_changed,
|
||||||
lvs_changed, 0)) {
|
0)) {
|
||||||
log_error("ABORTING: Segment progression failed.");
|
log_error("ABORTING: Segment progression failed.");
|
||||||
parms->poll_fns->finish_copy(cmd, vg, lv_mirr,
|
parms->poll_fns->finish_copy(cmd, vg, lv, lvs_changed);
|
||||||
lvs_changed);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
*finished = 0; /* Another segment */
|
*finished = 0; /* Another segment */
|
||||||
@ -130,14 +128,14 @@ static int _check_mirror_status(struct cmd_context *cmd,
|
|||||||
return 1;
|
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 daemon_parms *parms)
|
||||||
{
|
{
|
||||||
struct volume_group *vg;
|
struct volume_group *vg;
|
||||||
struct logical_volume *lv_mirr;
|
struct logical_volume *lv;
|
||||||
int finished = 0;
|
int finished = 0;
|
||||||
|
|
||||||
/* Poll for mirror completion */
|
/* Poll for completion */
|
||||||
while (!finished) {
|
while (!finished) {
|
||||||
/* FIXME Also needed in vg/lvchange -ay? */
|
/* FIXME Also needed in vg/lvchange -ay? */
|
||||||
/* FIXME Use alarm for regular intervals instead */
|
/* FIXME Use alarm for regular intervals instead */
|
||||||
@ -156,16 +154,15 @@ static int _wait_for_single_mirror(struct cmd_context *cmd, const char *name, co
|
|||||||
return 0;
|
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))) {
|
parms->lv_type))) {
|
||||||
log_error("ABORTING: Can't find mirror LV in %s for %s",
|
log_error("ABORTING: Can't find mirror LV in %s for %s",
|
||||||
vg->name, name);
|
vg->name, name);
|
||||||
unlock_and_release_vg(cmd, vg, vg->name);
|
unlock_and_release_vg(cmd, vg, vg->name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_check_mirror_status(cmd, vg, lv_mirr, name, parms,
|
if (!_check_lv_status(cmd, vg, lv, name, parms, &finished)) {
|
||||||
&finished)) {
|
|
||||||
unlock_and_release_vg(cmd, vg, vg->name);
|
unlock_and_release_vg(cmd, vg, vg->name);
|
||||||
return 0;
|
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 daemon_parms *parms = (struct daemon_parms *) handle;
|
||||||
struct lv_list *lvl;
|
struct lv_list *lvl;
|
||||||
struct logical_volume *lv_mirr;
|
struct logical_volume *lv;
|
||||||
const char *name;
|
const char *name;
|
||||||
int finished;
|
int finished;
|
||||||
|
|
||||||
dm_list_iterate_items(lvl, &vg->lvs) {
|
dm_list_iterate_items(lvl, &vg->lvs) {
|
||||||
lv_mirr = lvl->lv;
|
lv = lvl->lv;
|
||||||
if (!(lv_mirr->status & parms->lv_type))
|
if (!(lv->status & parms->lv_type))
|
||||||
continue;
|
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;
|
continue;
|
||||||
/* FIXME Need to do the activation from _set_up_pvmove here
|
/* FIXME Need to do the activation from _set_up_pvmove here
|
||||||
* if it's not running and we're not aborting */
|
* if it's not running and we're not aborting */
|
||||||
if (_check_mirror_status(cmd, vg, lv_mirr, name,
|
if (_check_lv_status(cmd, vg, lv, name, parms, &finished) &&
|
||||||
parms, &finished) && !finished)
|
!finished)
|
||||||
parms->outstanding_count++;
|
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? */
|
/* fork one daemon per copy? */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Process one specific task or all incomplete tasks?
|
||||||
|
*/
|
||||||
if (name) {
|
if (name) {
|
||||||
if (!_wait_for_single_mirror(cmd, name, uuid, &parms)) {
|
if (!_wait_for_single_lv(cmd, name, uuid, &parms)) {
|
||||||
stack;
|
stack;
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#include "metadata-exported.h"
|
#include "metadata-exported.h"
|
||||||
|
|
||||||
struct poll_functions {
|
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,
|
struct volume_group *(*get_copy_vg) (struct cmd_context *cmd,
|
||||||
const char *name,
|
const char *name,
|
||||||
const char *uuid);
|
const char *uuid);
|
||||||
@ -30,11 +30,11 @@ struct poll_functions {
|
|||||||
uint32_t lv_type);
|
uint32_t lv_type);
|
||||||
int (*update_metadata) (struct cmd_context *cmd,
|
int (*update_metadata) (struct cmd_context *cmd,
|
||||||
struct volume_group *vg,
|
struct volume_group *vg,
|
||||||
struct logical_volume *lv_mirr,
|
struct logical_volume *lv,
|
||||||
struct dm_list *lvs_changed, unsigned flags);
|
struct dm_list *lvs_changed, unsigned flags);
|
||||||
int (*finish_copy) (struct cmd_context *cmd,
|
int (*finish_copy) (struct cmd_context *cmd,
|
||||||
struct volume_group *vg,
|
struct volume_group *vg,
|
||||||
struct logical_volume *lv_mirr,
|
struct logical_volume *lv,
|
||||||
struct dm_list *lvs_changed);
|
struct dm_list *lvs_changed);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user