summaryrefslogtreecommitdiffstats
path: root/lib/locking
diff options
context:
space:
mode:
authorAlasdair Kergon <agk@redhat.com>2011-09-27 17:09:42 +0000
committerAlasdair Kergon <agk@redhat.com>2011-09-27 17:09:42 +0000
commit1c26860d825bd9293b146739b37a7461864ed68b (patch)
tree36bf3eb1afbc983f0f9cd87bdf2ba161db5e476d /lib/locking
parent0ed2af7fb1fe458c545d775a5a13d779f2e69361 (diff)
downloadlvm2-1c26860d825bd9293b146739b37a7461864ed68b.tar.gz
lvm2-1c26860d825bd9293b146739b37a7461864ed68b.tar.xz
lvm2-1c26860d825bd9293b146739b37a7461864ed68b.zip
Abort if _finish_pvmove suspend_lvs fails instead of cleaning up incompletely.
Change suspend_lvs to call vg_revert internally. Change vg_revert to void and remove superfluous calls after failed vg_commit.
Diffstat (limited to 'lib/locking')
-rw-r--r--lib/locking/locking.c11
-rw-r--r--lib/locking/locking.h4
2 files changed, 12 insertions, 3 deletions
diff --git a/lib/locking/locking.c b/lib/locking/locking.c
index ec8c0838..17fa3a8c 100644
--- a/lib/locking/locking.c
+++ b/lib/locking/locking.c
@@ -493,8 +493,13 @@ int resume_lvs(struct cmd_context *cmd, struct dm_list *lvs)
return r;
}
-/* Lock a list of LVs */
-int suspend_lvs(struct cmd_context *cmd, struct dm_list *lvs)
+/*
+ * Lock a list of LVs.
+ * On failure to lock any LV, calls vg_revert() if vg_to_revert is set and
+ * then unlocks any LVs on the list already successfully locked.
+ */
+int suspend_lvs(struct cmd_context *cmd, struct dm_list *lvs,
+ struct volume_group *vg_to_revert)
{
struct dm_list *lvh;
struct lv_list *lvl;
@@ -502,6 +507,8 @@ int suspend_lvs(struct cmd_context *cmd, struct dm_list *lvs)
dm_list_iterate_items(lvl, lvs) {
if (!suspend_lv(cmd, lvl->lv)) {
log_error("Failed to suspend %s", lvl->lv->name);
+ if (vg_to_revert)
+ vg_revert(vg_to_revert);
dm_list_uniterate(lvh, lvs, &lvl->list) {
lvl = dm_list_item(lvh, struct lv_list);
if (!resume_lv(cmd, lvl->lv))
diff --git a/lib/locking/locking.h b/lib/locking/locking.h
index f8a2c251..69b31ee0 100644
--- a/lib/locking/locking.h
+++ b/lib/locking/locking.h
@@ -187,7 +187,9 @@ int sync_local_dev_names(struct cmd_context* cmd);
int sync_dev_names(struct cmd_context* cmd);
/* Process list of LVs */
-int suspend_lvs(struct cmd_context *cmd, struct dm_list *lvs);
+struct volume_group;
+int suspend_lvs(struct cmd_context *cmd, struct dm_list *lvs,
+ struct volume_group *vg_to_revert);
int resume_lvs(struct cmd_context *cmd, struct dm_list *lvs);
int activate_lvs(struct cmd_context *cmd, struct dm_list *lvs, unsigned exclusive);