]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Add some extra consistency checks based on level.
authorNeil Brown <neilb@suse.de>
Wed, 17 Oct 2007 03:08:12 +0000 (13:08 +1000)
committerNeil Brown <neilb@suse.de>
Wed, 17 Oct 2007 03:08:12 +0000 (13:08 +1000)
Also use LEVEL_LINEAR, LEVEL_MULTIPATH in place of -1 or -4 in a few places.

Create.c
ReadMe.c

index 31b63b446d394a2d6b2897b9dabe1084f2d45015..55034716f22b32ab4377db37c1c7a7477e0f475e 100644 (file)
--- 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 */
 
index 9a33abcb3c15f59b90f3aa308b6d299bb83cac7d..96296acb4ebd4e3ff8fbb1b2c0bbac5e268b21a2 100644 (file)
--- 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}
 };