NeilBrown: Grow: fix --layout=preserve to match man page.

Michael Tokarev mjt at alioth.debian.org
Fri May 25 18:01:37 UTC 2012


Module: mdadm
Branch: master
Commit: 385167f364122c9424aa3d56f00b8c0874ce78b8
URL:    http://git.debian.org/?p=pkg-mdadm/mdadm.git;a=commit;h=385167f364122c9424aa3d56f00b8c0874ce78b8

Author: NeilBrown <neilb at suse.de>
Date:   Tue May 15 11:59:40 2012 +1000

Grow: fix --layout=preserve to match man page.

I think there was some confusion about what --layout=preserve
actually means, but in any case it wasn't doing what the man
page says it should.
So add some case analysis and make sure it does the right thing,
or complains if it cannot.

Reported-by: Patrik Horník <patrik at dsl.sk>
Signed-off-by: NeilBrown <neilb at suse.de>

---

 Grow.c |   30 +++++++++++++++++++++++++++++-
 1 files changed, 29 insertions(+), 1 deletions(-)

diff --git a/Grow.c b/Grow.c
index 330e719..9350a07 100644
--- a/Grow.c
+++ b/Grow.c
@@ -1885,9 +1885,37 @@ size_change_error:
 				*h = 0;
 				info.new_layout = map_name(r6layout, l);
 			}
+		} else {
+			fprintf(stderr, Name
+				": %s is only meaningful when reshaping"
+				" a RAID6 array.\n", layout_str);
+			rv = 1;
+			goto release;
 		}
 	} else if (strcmp(layout_str, "preserve") == 0) {
-		info.new_layout = UnSet;
+		/* This means that a non-standard RAID6 layout
+		 * is OK.
+		 * In particular:
+		 * - When reshape a RAID6 (e.g. adding a device)
+		 *   which is in a non-standard layout, it is OK
+		 *   to preserve that layout.
+		 * - When converting a RAID5 to RAID6, leave it in
+		 *   the XXX-6 layout, don't re-layout.
+		 */
+		if (info.array.level == 6 && info.new_level == UnSet)
+			info.new_layout = info.array.layout;
+		else if (info.array.level == 5 && info.new_level == 6) {
+			char l[40];
+			strcpy(l, map_num(r5layout, info.array.layout));
+			strcat(l, "-6");
+			info.new_layout = map_name(r6layout, l);
+		} else {
+			fprintf(stderr, Name
+				": %s in only meaningful when reshaping"
+				" to RAID6\n", layout_str);
+			rv = 1;
+			goto release;
+		}
 	} else {
 		int l = info.new_level;
 		if (l == UnSet)




More information about the pkg-mdadm-commits mailing list