All of lore.kernel.org
 help / color / mirror / Atom feed
From: mornfall@sourceware.org <mornfall@sourceware.org>
To: lvm-devel@redhat.com
Subject: LVM2/tools lvconvert.c
Date: 2 Aug 2009 21:56:30 -0000	[thread overview]
Message-ID: <20090802215630.11769.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mornfall at sourceware.org	2009-08-02 21:56:29

Modified files:
	tools          : lvconvert.c 

Log message:
	Slightly refactor mirror log conversions in lvconvert.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.89&r2=1.90

--- LVM2/tools/lvconvert.c	2009/07/15 05:47:55	1.89
+++ LVM2/tools/lvconvert.c	2009/08/02 21:56:29	1.90
@@ -496,6 +496,33 @@
 	}
 }
 
+static int _using_corelog(struct logical_volume *lv)
+{
+	return !first_seg(_original_lv(lv))->log_lv;
+}
+
+static int _lv_update_log_type(struct cmd_context *cmd,
+			       struct lvconvert_params *lp,
+			       struct logical_volume *lv,
+			       int corelog)
+{
+	struct logical_volume *original_lv = _original_lv(lv);
+	if (_using_corelog(lv) && !corelog) {
+		if (!add_mirror_log(cmd, original_lv, 1,
+				    adjusted_mirror_region_size(
+					lv->vg->extent_size,
+					lv->le_count,
+					lp->region_size),
+				    lp->pvh, lp->alloc))
+			return_0;
+	} else if (!_using_corelog(lv) && corelog) {
+		if (!remove_mirror_log(cmd, original_lv,
+				       lp->pv_count ? lp->pvh : NULL))
+			return_0;
+	}
+	return 1;
+}
+
 static int _lvconvert_mirrors(struct cmd_context *cmd, struct logical_volume *lv,
 			      struct lvconvert_params *lp)
 {
@@ -503,7 +530,6 @@
 	uint32_t existing_mirrors;
 	const char *mirrorlog;
 	unsigned corelog = 0;
-	struct logical_volume *original_lv;
 	int r = 0;
 	struct logical_volume *log_lv;
 	int failed_mirrors = 0, failed_log = 0;
@@ -688,20 +714,8 @@
 		 * insertion to make the end result consistent with
 		 * linear-to-mirror conversion.
 		 */
-		original_lv = _original_lv(lv);
-		if (!first_seg(original_lv)->log_lv && !corelog) {
-			if (!add_mirror_log(cmd, original_lv, 1,
-					    adjusted_mirror_region_size(
-							lv->vg->extent_size,
-							lv->le_count,
-							lp->region_size),
-					    lp->pvh, lp->alloc))
-				return_0;
-		} else if (first_seg(original_lv)->log_lv && corelog) {
-			if (!remove_mirror_log(cmd, original_lv,
-					       lp->pv_count ? lp->pvh : NULL))
-				return_0;
-		}
+		if (!_lv_update_log_type(cmd, lp, lv, corelog))
+			return_0;
 		/* Insert a temporary layer for syncing,
 		 * only if the original lv is using disk log. */
 		if (seg->log_lv && !_insert_lvconvert_layer(cmd, lv)) {
@@ -722,24 +736,10 @@
 	}
 
 	if (lp->mirrors == existing_mirrors) {
-		/*
-		 * Convert Mirror log type
-		 */
-		original_lv = _original_lv(lv);
-		if (!first_seg(original_lv)->log_lv && !corelog) {
-			if (!add_mirror_log(cmd, original_lv, 1,
-					    adjusted_mirror_region_size(
-							lv->vg->extent_size,
-							lv->le_count,
-							lp->region_size),
-					    lp->pvh, lp->alloc))
-				return_0;
-		} else if (first_seg(original_lv)->log_lv && corelog) {
-			if (!remove_mirror_log(cmd, original_lv,
-					       lp->pv_count ? lp->pvh : NULL))
+		if (_using_corelog(lv) != corelog) {
+			if (!_lv_update_log_type(cmd, lp, lv, corelog))
 				return_0;
 		} else {
-			/* No change */
 			log_error("Logical volume %s already has %"
 				  PRIu32 " mirror(s).", lv->name,
 				  lp->mirrors - 1);



             reply	other threads:[~2009-08-02 21:56 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-02 21:56 mornfall [this message]
  -- strict thread matches above, loose matches on Subject: below --
2012-04-19 21:50 LVM2/tools lvconvert.c jbrassow
2012-02-23 22:36 zkabelac
2012-02-22 16:03 jbrassow
2012-02-22 15:20 jbrassow
2012-02-13 18:38 jbrassow
2012-02-13 18:36 jbrassow
2012-01-25 22:38 zkabelac
2011-12-08 18:00 agk
2011-06-29  2:06 jbrassow
2011-06-28 21:28 jbrassow
2011-01-19 19:24 jbrassow
2010-11-28 18:37 snitzer
2010-07-13 22:04 jbrassow
2010-07-13 21:53 jbrassow
2010-07-01 10:10 mornfall
2010-06-23 20:32 jbrassow
2010-06-23 20:49 ` Alasdair G Kergon
2010-06-23 20:56   ` Jonathan Brassow
2010-04-28 17:41 jbrassow
2010-04-26 18:12 agk
2010-04-20 12:18 agk
2010-03-31 20:39 agk
2010-02-05 22:47 snitzer
2010-01-13  1:49 snitzer
2010-01-13  1:47 snitzer
2010-01-11 17:13 jbrassow
2010-01-07 20:42 jbrassow
2009-10-21 22:19 jbrassow
2009-06-26 11:29 wysochanski
2009-06-10 15:27 mornfall
2009-05-19 10:27 mbroz
2009-05-19 17:15 ` Alasdair G Kergon
2009-05-19 10:12 mbroz
2008-01-16 22:54 agk
2008-01-16 19:40 agk
2008-01-16 19:16 agk
2007-12-21  1:08 agk
2007-08-01 20:54 jbrassow

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=20090802215630.11769.qmail@sourceware.org \
    --to=mornfall@sourceware.org \
    --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.