All of lore.kernel.org
 help / color / mirror / Atom feed
From: Milan Broz <mbroz@redhat.com>
To: lvm-devel@redhat.com
Subject: [RFC PATCH] pvmove: do not keep suspended devices behind and try automatically restore previous state
Date: Fri, 15 May 2009 18:17:56 +0200	[thread overview]
Message-ID: <4A0D95B4.1060300@redhat.com> (raw)

If pvmove fails activating mirror volume, try restroe to previous state.

pvmove now keep suspended devices if temporary mirror creation fails.

We can try to restore previous state if it is first attempt to activate 
pvmove (code basically run the same code as --abort automatically).

Signed-off-by: Milan Broz <mbroz@redhat.com>
---
 test/t-pvmove-basic.sh |    5 +++++
 tools/pvmove.c         |   20 ++++++++++++++------
 2 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/test/t-pvmove-basic.sh b/test/t-pvmove-basic.sh
index ab39e4f..cbd5c8c 100755
--- a/test/t-pvmove-basic.sh
+++ b/test/t-pvmove-basic.sh
@@ -370,3 +370,8 @@ vgcreate $vg -s 256k $devs
 lvcreate -l4 -n $lv1 $vg $dev1
 pvmove -i1 $dev1
 
+#COMM "pvmove fails activating mirror, properly restores state before pvmove"
+dmsetup create "$vg-pvmove0" --notable
+not pvmove -i 1 $dev2
+test $(dmsetup info --noheadings -c -o suspended "$vg-$lv1") = "Active"
+dmsetup remove "$vg-pvmove0"
diff --git a/tools/pvmove.c b/tools/pvmove.c
index d760802..3e12ec1 100644
--- a/tools/pvmove.c
+++ b/tools/pvmove.c
@@ -274,6 +274,10 @@ static int _activate_lv(struct cmd_context *cmd, struct logical_volume *lv_mirr,
 	return activate_lv(cmd, lv_mirr);
 }
 
+static int _finish_pvmove(struct cmd_context *cmd, struct volume_group *vg,
+			  struct logical_volume *lv_mirr,
+			  struct dm_list *lvs_changed);
+
 static int _update_metadata(struct cmd_context *cmd, struct volume_group *vg,
 			    struct logical_volume *lv_mirr,
 			    struct dm_list *lvs_changed, unsigned flags)
@@ -315,12 +319,16 @@ static int _update_metadata(struct cmd_context *cmd, struct volume_group *vg,
 	/* FIXME: Add option to use a log */
 	if (first_time) {
 		if (!_activate_lv(cmd, lv_mirr, exclusive)) {
-			if (!test_mode())
-				log_error("ABORTING: Temporary mirror "
-					  "activation failed.  "
-					  "Run pvmove --abort.");
-			/* FIXME Resume using *original* metadata here! */
-			resume_lvs(cmd, lvs_changed);
+			if (test_mode())
+				goto out;
+
+			/*
+			 * Nothing changed yet, try to revert pvmove.
+			 */
+			log_error("Temporary pvmove mirror activation failed.");
+			if (!_finish_pvmove(cmd, vg, lv_mirr, lvs_changed))
+				log_error("ABORTING: Restoring original configuration "
+					  "before pvmove failed. Run pvmove --abort.");
 			goto out;
 		}
 	} else if (!resume_lv(cmd, lv_mirr)) {




             reply	other threads:[~2009-05-15 16:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-15 16:17 Milan Broz [this message]
2009-05-18 20:03 ` [RFC PATCH] pvmove: do not keep suspended devices behind and try automatically restore previous state Alasdair G Kergon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A0D95B4.1060300@redhat.com \
    --to=mbroz@redhat.com \
    --cc=lvm-devel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.