All of lore.kernel.org
 help / color / mirror / Atom feed
From: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
To: neilb@suse.de
Cc: linux-raid@vger.kernel.org, wojciech.neubauer@intel.com,
	adam.kwolek@intel.com, dan.j.williams@intel.com,
	ed.ciechanowski@intel.com
Subject: [PATCH 2/5] Add raid1->raid0 takeover support
Date: Mon, 24 Jan 2011 15:17:12 +0100	[thread overview]
Message-ID: <20110124141712.16405.50338.stgit@gklab-128-111.igk.intel.com> (raw)
In-Reply-To: <20110124141704.16405.6081.stgit@gklab-128-111.igk.intel.com>

Add support for raid1 to raid0 takeover operation in user space.
This patch includes support for native and imsm metadata.

Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
---
 Grow.c        |   39 ++++++++++++++++++++++++++++-----------
 super-intel.c |    6 ++++++
 2 files changed, 34 insertions(+), 11 deletions(-)

diff --git a/Grow.c b/Grow.c
index 7c5edae..a8da20a 100644
--- a/Grow.c
+++ b/Grow.c
@@ -650,15 +650,20 @@ void abort_reshape(struct mdinfo *sra)
 	sysfs_set_str(sra, NULL, "sync_max", "max");
 }
 
-int remove_disks_on_raid10_to_raid0_takeover(struct supertype *st,
-					     struct mdinfo *sra,
-					     int layout)
+int remove_disks_for_takeover(struct supertype *st,
+			     struct mdinfo *sra,
+			     int layout)
 {
 	int nr_of_copies;
 	struct mdinfo *remaining;
 	int slot;
 
-	nr_of_copies = layout & 0xff;
+	if (sra->array.level == 10)
+		nr_of_copies = layout & 0xff;
+	else if (sra->array/level == 1)
+		nr_of_copies = sra->array.raid_disks;
+	else
+		return 1;
 
 	remaining = sra->devs;
 	sra->devs = NULL;
@@ -911,8 +916,18 @@ char *analyse_change(struct mdinfo *info, struct reshape *re)
 	switch (info->array.level) {
 	case 1:
 		/* RAID1 can convert to RAID1 with different disks, or
-		 * raid5 with 2 disks
+		 * raid5 with 2 disks, or
+		 * raid0 with 1 disk
 		 */
+		if (info->new_level == 0) {
+			re->level = 0;
+			re->before.data_disks = info->array.raid_disks / 2;
+			re->after.data_disks = re->before.data_disks;
+			re->before.layout = 0;
+			re->backup_blocks = 0;
+			re->parity = 0;
+			return NULL;
+		}
 		if (info->new_level == 1) {
 			if (info->delta_disks == UnSet)
 				/* Don't know what to do */
@@ -1449,15 +1464,17 @@ int Grow_reshape(char *devname, int fd, int quiet, char *backup_file,
 			size = array.size;
 	}
 
-	/* ========= check for Raid10 -> Raid0 conversion ===============
+	/* ========= check for Raid10/Raid1 -> Raid0 conversion ===============
 	 * current implementation assumes that following conditions must be met:
-	 * - far_copies == 1
-	 * - near_copies == 2
+	 * - RAID10:
+	 * 	- far_copies == 1
+	 * 	- near_copies == 2
 	 */
-	if (level == 0 && array.level == 10 && sra &&
-	    array.layout == ((1 << 8) + 2) && !(array.raid_disks & 1)) {
+	if ((level == 0 && array.level == 10 && sra &&
+	    array.layout == ((1 << 8) + 2) && !(array.raid_disks & 1)) ||
+	    (level == 0 && array.level == 1 && sra)) {
 		int err;
-		err = remove_disks_on_raid10_to_raid0_takeover(st, sra, array.layout);
+		err = remove_disks_for_takeover(st, sra, array.layout);
 		if (err) {
 			dprintf(Name": Array cannot be reshaped\n");
 			if (cfd > -1)
diff --git a/super-intel.c b/super-intel.c
index b25d4fb..461fb0c 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -6785,6 +6785,12 @@ enum imsm_reshape_type imsm_analyze_change(struct supertype *st,
 				check_devs = 1;
 			}
 			break;
+		case 1:
+			if (geo->level == 0) {
+				change = CH_TAKEOVER;
+				check_devs = 1;
+			}
+			break;
 		case 5:
 			if (geo->level != 0)
 				change = CH_LEVEL_MIGRATION;


  reply	other threads:[~2011-01-24 14:17 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-24 14:17 [PATCH 1/5] FIX: Unfreeze array if reshape_array wasn't succeded Krzysztof Wojcik
2011-01-24 14:17 ` Krzysztof Wojcik [this message]
2011-01-27  3:12   ` [PATCH 2/5] Add raid1->raid0 takeover support Neil Brown
2011-01-24 14:17 ` [PATCH 3/5] Mistake in raid1->raid5 migration Krzysztof Wojcik
2011-01-27  3:13   ` Neil Brown
2011-01-24 14:17 ` [PATCH 4/5] FIX: Validate input in ping_monitor function Krzysztof Wojcik
2011-01-27  3:14   ` Neil Brown
2011-01-24 14:17 ` [PATCH 5/5] FIX: Validate input in ping_manager function Krzysztof Wojcik
2011-01-27  3:10 ` [PATCH 1/5] FIX: Unfreeze array if reshape_array wasn't succeded Neil Brown

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=20110124141712.16405.50338.stgit@gklab-128-111.igk.intel.com \
    --to=krzysztof.wojcik@intel.com \
    --cc=adam.kwolek@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=ed.ciechanowski@intel.com \
    --cc=linux-raid@vger.kernel.org \
    --cc=neilb@suse.de \
    --cc=wojciech.neubauer@intel.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.