Re: mdadm segfaults on --grow

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 19 Feb 2012 07:35:08 +0400 eeeee <tw@xxxxxxxxxxx> wrote:

> i'm doing
> mdadm --grow /dev/md127 -l raid5 -n 6
> and it segfaults!
> 
> mdadm-3.2.3

Thanks for the report.

Can you please check if this fixes the problem?

NeilBrown


diff --git a/Grow.c b/Grow.c
index 53a7cad..8198ac3 100644
--- a/Grow.c
+++ b/Grow.c
@@ -1275,7 +1275,7 @@ char *analyse_change(struct mdinfo *info, struct reshape *re)
 		break;
 
 	case 5:
-		/* We get to RAID5 for RAID5 or RAID6 */
+		/* We get to RAID5 from RAID5 or RAID6 */
 		if (re->level != 5 && re->level != 6)
 			return "Cannot convert to RAID5 from this level";
 
@@ -1297,11 +1297,27 @@ char *analyse_change(struct mdinfo *info, struct reshape *re)
 				char layout[40];
 				char *ls = map_num(r5layout, info->new_layout);
 				int l;
-				strcat(strcpy(layout, ls), "-6");
-				l = map_name(r6layout, layout);
-				if (l == UnSet)
-					return "Cannot find RAID6 layout"
-						" to convert to";
+				if (ls) {
+					/* Current RAID6 layout has a RAID5
+					 * equivalent - good
+					 */
+					strcat(strcpy(layout, ls), "-6");
+					l = map_name(r6layout, layout);
+					if (l == UnSet)
+						return "Cannot find RAID6 layout"
+							" to convert to";
+				} else {
+					/* Current RAID6 has no equivalent.
+					 * If it is already a '-6' layout we
+					 * can leave it unchanged, else we must
+					 * fail
+					 */
+					ls = map_num(r6layout, info->new_layout);
+					if (!ls ||
+					    strcmp(ls+strlen(ls)-2, "-6") != 0)
+						return "Please specify new layout";
+					l = info->new_layout;
+				}
 				re->after.layout = l;
 			}
 		}

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux