public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
From: agk@sourceware.org
To: lvm-devel@redhat.com, lvm2-cvs@sourceware.org
Subject: LVM2/lib/metadata mirror.c
Date: Thu, 17 Jan 2008 13:37:00 -0000	[thread overview]
Message-ID: <20080117133752.32597.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2008-01-17 13:37:52

Modified files:
	lib/metadata   : mirror.c 

Log message:
	mirror log stuff

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.60&r2=1.61

--- LVM2/lib/metadata/mirror.c	2008/01/17 13:13:54	1.60
+++ LVM2/lib/metadata/mirror.c	2008/01/17 13:37:51	1.61
@@ -192,9 +192,12 @@
  */
 static int _init_mirror_log(struct cmd_context *cmd,
 			    struct logical_volume *log_lv, int in_sync,
-			    struct list *tags)
+			    struct list *tags, int remove_on_failure)
 {
 	struct str_list *sl;
+	struct lvinfo info;
+	uint32_t orig_status = log_lv->status;
+	int was_active = 0;
 
 	if (!activation() && in_sync) {
 		log_error("Aborting. Unable to create in-sync mirror log "
@@ -202,21 +205,31 @@
 		return 0;
 	}
 
+	/* If the LV is active, deactivate it first. */
+	if (lv_info(cmd, log_lv, &info, 0, 0) && info.exists) {
+		if (!deactivate_lv(cmd, log_lv))
+			return_0;
+		was_active = 1;
+	}
+
+	/* Temporary make it visible for set_lv() */
+	log_lv->status |= VISIBLE_LV;
+
 	/* Temporary tag mirror log for activation */
 	list_iterate_items(sl, tags)
 		if (!str_list_add(cmd->mem, &log_lv->tags, sl->str)) {
 			log_error("Aborting. Unable to tag mirror log.");
-			return 0;
+			goto activate_lv;
 		}
 
 	/* store mirror log on disk(s) */
 	if (!vg_write(log_lv->vg))
-		return_0;
+		goto activate_lv;
 
 	backup(log_lv->vg);
 
 	if (!vg_commit(log_lv->vg))
-		return_0;
+		goto activate_lv;
 
 	if (!activate_lv(cmd, log_lv)) {
 		log_error("Aborting. Failed to activate mirror log.");
@@ -248,6 +261,9 @@
 
 	log_lv->status &= ~VISIBLE_LV;
 
+	if (was_active && !activate_lv(cmd, log_lv))
+		return_0;
+
 	return 1;
 
 deactivate_and_revert_new_lv:
@@ -258,10 +274,27 @@
 	}
 
 revert_new_lv:
-	if (!lv_remove(log_lv) || !vg_write(log_lv->vg) ||
-	    (backup(log_lv->vg), !vg_commit(log_lv->vg)))
+	log_lv->status = orig_status;
+
+	list_iterate_items(sl, tags)
+		if (!str_list_del(&log_lv->tags, sl->str))
+			log_error("Failed to remove tag %s from mirror log.",
+				  sl->str);
+
+	if (remove_on_failure && !lv_remove(log_lv)) {
 		log_error("Manual intervention may be required to remove "
 			  "abandoned log LV before retrying.");
+		return 0;
+	}
+
+	if (!vg_write(log_lv->vg) ||
+	    (backup(log_lv->vg), !vg_commit(log_lv->vg)))
+		log_error("Manual intervention may be required to "
+			  "remove/restore abandoned log LV before retrying.");
+activate_lv:
+	if (was_active && !remove_on_failure && !activate_lv(cmd, log_lv))
+		return_0;
+
 	return 0;
 }
 
@@ -1199,7 +1232,7 @@
 		return NULL;
 	}
 
-	if (!_init_mirror_log(cmd, log_lv, in_sync, &lv->tags)) {
+	if (!_init_mirror_log(cmd, log_lv, in_sync, &lv->tags, 1)) {
 		log_error("Failed to create mirror log.");
 		return NULL;
 	}


             reply	other threads:[~2008-01-17 13:37 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-17 13:37 agk [this message]
  -- strict thread matches above, loose matches on Subject: below --
2012-02-01 15:05 agk
2011-09-19 14:28 jbrassow
2011-09-16 16:41 jbrassow
2011-09-14  9:54 zkabelac
2011-09-14  4:10 jbrassow
2011-09-13 18:11 jbrassow
2011-06-24 23:39 agk
2011-04-12 14:13 zkabelac
2011-03-24 12:28 mornfall
2011-01-11 17:21 jbrassow
2010-07-09 17:57 jbrassow
2010-06-23 13:57 jbrassow
2010-04-20 12:14 agk
2010-04-01 14:54 agk
2010-01-08 10:50 zkabelac
2009-12-17 15:59 mornfall
2009-12-09 19:43 mbroz
2009-11-19 13:42 mornfall
2009-11-19 12:09 mornfall
2009-11-18 18:23 mornfall
2009-10-14 14:55 jbrassow
2009-04-23 16:43 mornfall
2008-09-19  4:30 agk
2008-09-19  0:20 agk
2008-01-16 19:50 agk
2008-01-16 19:38 agk
2008-01-16 19:11 agk
2008-01-16 19:09 agk
2006-11-10 20:15 agk
2004-05-05 18:35 agk

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=20080117133752.32597.qmail@sourceware.org \
    --to=agk@sourceware.org \
    --cc=lvm-devel@redhat.com \
    --cc=lvm2-cvs@sourceware.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).