Move activation of background polling processes to a common function. Copying code is bad practice and there was a bug because of it, vgchange didn't restart lvconvert, only pvmove. Signed-off-by: Mikulas Patocka --- tools/lvchange.c | 33 ++++++++++++++++++++------------- tools/tools.h | 1 + tools/vgchange.c | 10 ++-------- 3 files changed, 23 insertions(+), 21 deletions(-) Index: LVM2.2.02.39/tools/lvchange.c =================================================================== --- LVM2.2.02.39.orig/tools/lvchange.c 2008-07-06 22:13:10.000000000 +0200 +++ LVM2.2.02.39/tools/lvchange.c 2008-07-06 22:13:13.000000000 +0200 @@ -99,11 +99,29 @@ static int lvchange_monitoring(struct cm return 1; } +void lvchange_activate_background_polling(struct cmd_context *cmd, + struct logical_volume *lv) +{ + const char *pvname; + + if ((lv->status & LOCKED) && + (pvname = get_pvmove_pvname_from_lv(lv))) { + log_verbose("Spawning background pvmove process for %s", + pvname); + pvmove_poll(cmd, pvname, 1); + } + + if (lv->status & CONVERTING) { + log_verbose("Spawning background lvconvert process for %s", + lv->name); + lvconvert_poll(cmd, lv, 1); + } +} + static int lvchange_availability(struct cmd_context *cmd, struct logical_volume *lv) { int activate; - const char *pvname; activate = arg_uint_value(cmd, available_ARG, 0); @@ -140,18 +158,7 @@ static int lvchange_availability(struct return_0; } - if ((lv->status & LOCKED) && - (pvname = get_pvmove_pvname_from_lv(lv))) { - log_verbose("Spawning background pvmove process for %s", - pvname); - pvmove_poll(cmd, pvname, 1); - } - - if (lv->status & CONVERTING) { - log_verbose("Spawning background lvconvert process for %s", - lv->name); - lvconvert_poll(cmd, lv, 1); - } + lvchange_activate_background_polling(cmd, lv); } return 1; Index: LVM2.2.02.39/tools/tools.h =================================================================== --- LVM2.2.02.39.orig/tools/tools.h 2008-07-06 22:13:10.000000000 +0200 +++ LVM2.2.02.39/tools/tools.h 2008-07-06 22:13:13.000000000 +0200 @@ -170,5 +170,6 @@ const char *command_name(struct cmd_cont int pvmove_poll(struct cmd_context *cmd, const char *pv, unsigned background); int lvconvert_poll(struct cmd_context *cmd, struct logical_volume *lv, unsigned background); +void lvchange_activate_background_polling(struct cmd_context *cmd, struct logical_volume *lv); #endif Index: LVM2.2.02.39/tools/vgchange.c =================================================================== --- LVM2.2.02.39.orig/tools/vgchange.c 2008-07-06 22:13:10.000000000 +0200 +++ LVM2.2.02.39/tools/vgchange.c 2008-07-06 22:13:13.000000000 +0200 @@ -56,7 +56,6 @@ static int _activate_lvs_in_vg(struct cm { struct lv_list *lvl; struct logical_volume *lv; - const char *pvname; int count = 0; list_iterate_items(lvl, &vg->lvs) { @@ -91,13 +90,8 @@ static int _activate_lvs_in_vg(struct cm } else if (!activate_lv(cmd, lv)) continue; - if ((lv->status & PVMOVE) && - (pvname = get_pvmove_pvname_from_lv_mirr(lv))) { - log_verbose("Spawning background process for %s %s", - lv->name, pvname); - pvmove_poll(cmd, pvname, 1); - continue; - } + if (activate != CHANGE_AN && activate != CHANGE_ALN) + lvchange_activate_background_polling(cmd, lv); count++; }