Neil Brown: Add some extra consistency checks based on level.

Martin F. Krafft madduck at alioth.debian.org
Tue Apr 22 10:25:58 UTC 2008


Module: mdadm
Branch: upstream-patches
Commit: 570510ba32858ddedf20a055240ddbf39d3b76e1
URL:    http://git.debian.org/?p=pkg-mdadm/mdadm.git/?a=commit;h=570510ba32858ddedf20a055240ddbf39d3b76e1

Author: Neil Brown <neilb at suse.de>
Date:   Wed Oct 17 13:08:12 2007 +1000

Add some extra consistency checks based on level.

Also use LEVEL_LINEAR, LEVEL_MULTIPATH in place of -1 or -4 in a few places.

---

 Create.c |   19 +++++++++++++++++--
 ReadMe.c |    8 ++++----
 2 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/Create.c b/Create.c
index 31b63b4..5503471 100644
--- a/Create.c
+++ b/Create.c
@@ -111,6 +111,11 @@ int Create(struct supertype *st, char *mddev, int mdfd,
 			Name ": at least 2 raid-devices needed for level 4 or 5\n");
 		return 1;
 	}
+	if (level <= 0 && sparedisks) {
+		fprintf(stderr,
+			Name ": This level does not support spare devices\n");
+		return 1;
+	}
 	if (subdevs > raiddisks+sparedisks) {
 		fprintf(stderr, Name ": You have listed more devices (%d) than are in the array(%d)!\n", subdevs, raiddisks+sparedisks);
 		return 1;
@@ -167,20 +172,24 @@ int Create(struct supertype *st, char *mddev, int mdfd,
 	case 10:
 	case 6:
 	case 0:
-	case -1: /* linear */
+	case LEVEL_LINEAR: /* linear */
 		if (chunk == 0) {
 			chunk = 64;
 			if (verbose > 0)
 				fprintf(stderr, Name ": chunk size defaults to 64K\n");
 		}
 		break;
-	default: /* raid1, multipath */
+	case 1:
+	case LEVEL_MULTIPATH:
 		if (chunk) {
 			chunk = 0;
 			if (verbose > 0)
 				fprintf(stderr, Name ": chunk size ignored for this level\n");
 		}
 		break;
+	default:
+		fprintf(stderr, Name ": unknown level %d\n", level);
+		return 1;
 	}
 
 	/* now look at the subdevs */
@@ -332,6 +341,12 @@ int Create(struct supertype *st, char *mddev, int mdfd,
 			break;
 		}
 	}
+
+	if (level <= 0 && first_missing != subdevs * 2) {
+		fprintf(stderr,
+			Name ": This level does not support missing devices\n");
+		return 1;
+	}
 	
 	/* Ok, lets try some ioctls */
 
diff --git a/ReadMe.c b/ReadMe.c
index 9a33abc..96296ac 100644
--- a/ReadMe.c
+++ b/ReadMe.c
@@ -592,7 +592,7 @@ mapping_t r5layout[] = {
 };
 
 mapping_t pers[] = {
-	{ "linear", -1},
+	{ "linear", LEVEL_LINEAR},
 	{ "raid0", 0},
 	{ "0", 0},
 	{ "stripe", 0},
@@ -603,13 +603,13 @@ mapping_t pers[] = {
 	{ "4", 4},
 	{ "raid5", 5},
 	{ "5", 5},
-	{ "multipath", -4},
-	{ "mp", -4},
+	{ "multipath", LEVEL_MULTIPATH},
+	{ "mp", LEVEL_MULTIPATH},
 	{ "raid6", 6},
 	{ "6", 6},
 	{ "raid10", 10},
 	{ "10", 10},
-	{ "faulty", -5},
+	{ "faulty", LEVEL_FAULTY},
 	{ NULL, 0}
 };
 




More information about the pkg-mdadm-commits mailing list