From a25f9b210692fe5cd164441b76a78b11fb4ee4e5 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Tue, 14 Nov 2017 20:53:55 +0100 Subject: [PATCH] pvmove: change locking on finish --- WHATS_NEW | 1 + tools/pvmove_poll.c | 55 +++++++++++++++------------------------------ 2 files changed, 19 insertions(+), 37 deletions(-) diff --git a/WHATS_NEW b/WHATS_NEW index 728cc4f41..b1454a3e0 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.177 - ==================================== + Ehnance pvmove locking. Deactivate activated LVs on error path when pvmove activation fails. Add "io" to log/debug_classes for logging low-level I/O. Eliminate redundant nested VG metadata in VG struct. diff --git a/tools/pvmove_poll.c b/tools/pvmove_poll.c index 5bddee474..36c2d0c5f 100644 --- a/tools/pvmove_poll.c +++ b/tools/pvmove_poll.c @@ -92,6 +92,8 @@ int pvmove_update_metadata(struct cmd_context *cmd, struct volume_group *vg, int pvmove_finish(struct cmd_context *cmd, struct volume_group *vg, struct logical_volume *lv_mirr, struct dm_list *lvs_changed) { + struct lv_list *lvl; + struct logical_volume *holder; int r = 1; if (!dm_list_empty(lvs_changed) && @@ -101,48 +103,27 @@ int pvmove_finish(struct cmd_context *cmd, struct volume_group *vg, return 0; } - /* Store metadata without dependencies on mirror segments */ - if (!vg_write(vg)) { - log_error("ABORTING: Failed to write new data locations " - "to disk."); + if (!lv_update_and_reload(lv_mirr)) + return_0; + + /* Takes locks and resumed volumes (should be still suspended, but preloaded) */ + dm_list_iterate_items(lvl, lvs_changed) { + holder = (struct logical_volume *) lv_lock_holder(lvl->lv); + if (!resume_lv(cmd, holder)) { + log_error("Failed to reactivate logical volume %s.", + display_lvname(holder)); + r = 0; /* But try to resume as much as we can */ + } + } + + if (!r) return 0; - } - - /* Suspend LVs changed (implicitly suspends lv_mirr) */ - if (!suspend_lvs(cmd, lvs_changed, vg)) { - log_error("ABORTING: Locking LVs to remove temporary mirror failed"); - if (!revert_lv(cmd, lv_mirr)) - stack; - return 0; - } - - /* Store metadata without dependencies on mirror segments */ - if (!vg_commit(vg)) { - log_error("ABORTING: Failed to write new data locations " - "to disk."); - if (!revert_lv(cmd, lv_mirr)) - stack; - if (!revert_lvs(cmd, lvs_changed)) - stack; - return 0; - } - - /* Unsuspend LVs */ - if (!resume_lvs(cmd, lvs_changed)) - stack; - - /* Release mirror LV. (No pending I/O because it's been suspended.) */ - if (!activate_lv_excl_local(cmd, lv_mirr)) { - log_error("Unable to reactivate logical volume \"%s\"", - lv_mirr->name); - r = 0; - } /* Deactivate mirror LV */ if (!deactivate_lv(cmd, lv_mirr)) { log_error("ABORTING: Unable to deactivate temporary logical " "volume %s.", display_lvname(lv_mirr)); - r = 0; + return 0; } log_verbose("Removing temporary pvmove LV"); @@ -162,5 +143,5 @@ int pvmove_finish(struct cmd_context *cmd, struct volume_group *vg, /* FIXME backup positioning */ backup(vg); - return r; + return 1; }