]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Fix --incremental assembly of partitions arrays.
authorNeilBrown <neilb@suse.de>
Wed, 29 Oct 2008 22:34:04 +0000 (09:34 +1100)
committerNeilBrown <neilb@suse.de>
Wed, 29 Oct 2008 22:34:04 +0000 (09:34 +1100)
If incremental assembly finds an array mentioned in mdadm.conf,
with a 'standard partitioned' name like /dev/md_d0 or /dev/md/d0,
it will not create a partitioned array like it should.
This is because it mishandled the 'devnum' returned by
is_standard.
That is a devnum that does not have the partition-or-not encoded
into it.  So we need to check the actual return value of
is_standard and encode the partition-or-not info into the devnum.

Also fix a couple of comments.

Signed-off-by: NeilBrown <neilb@suse.de>
Incremental.c
util.c

index 9c6524f2e9e7dbeb4231ceb27254d3320d8de47b..5d26b77f5c1ab1b0e9ea9006bb994d7f5610642d 100644 (file)
@@ -214,16 +214,16 @@ int Incremental(char *devname, int verbose, int runstop,
                }
        }
        /* 4/ Determine device number. */
-       /* - If in mdadm.conf with std name, use that */
-       /* - UUID in /var/run/mdadm.map  use that */
+       /* - If in mdadm.conf with std name, get number from name. */
+       /* - UUID in /var/run/mdadm.map  get number from mapping */
        /* - If name is suggestive, use that. unless in use with */
        /*           different uuid. */
        /* - Choose a free, high number. */
        /* - Use a partitioned device unless strong suggestion not to. */
        /*         e.g. auto=md */
-       if (match && is_standard(match->devname, &devnum))
-               /* We have devnum now */;
-       else if ((mp = map_by_uuid(&map, info.uuid)) != NULL)
+       if (match && (rv = is_standard(match->devname, &devnum))) {
+               devnum = (rv > 0) ? (-1-devnum) : devnum;
+       else if ((mp = map_by_uuid(&map, info.uuid)) != NULL)
                devnum = mp->devnum;
        else {
                /* Have to guess a bit. */
diff --git a/util.c b/util.c
index 2d51de02ba4386ea3fae93a4cd41d7b7e998773b..a50036c116a76c86c2205ac3c148de345d4e9b93 100644 (file)
--- a/util.c
+++ b/util.c
@@ -398,7 +398,7 @@ int is_standard(char *dev, int *nump)
        if (strncmp(d, "/d",2)==0)
                d += 2, type=1; /* /dev/md/dN{pM} */
        else if (strncmp(d, "/md_d", 5)==0)
-               d += 5, type=1; /* /dev/md_dNpM */
+               d += 5, type=1; /* /dev/md_dN{pM} */
        else if (strncmp(d, "/md", 3)==0)
                d += 3, type=-1; /* /dev/mdN */
        else if (d-dev > 3 && strncmp(d-2, "md/", 3)==0)