]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Assemble: call remove_partitions later.
authorNeilBrown <neilb@suse.de>
Tue, 30 Nov 2010 05:56:01 +0000 (16:56 +1100)
committerNeilBrown <neilb@suse.de>
Thu, 10 Mar 2011 06:21:19 +0000 (17:21 +1100)
We shouldn't call remove_partitions until we have made a really firm
decision to include the device into the array.

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

index afd4e60a283f7cfb641463e200775bda04b701b8..ea3a6484d9ad78ac8977a0efa02e686c9662324b 100644 (file)
@@ -618,8 +618,6 @@ int Assemble(struct supertype *st, char *mddev,
                        }
                        dfd = dev_open(devname, O_RDWR|O_EXCL);
 
-                       remove_partitions(dfd);
-
                        tst = dup_super(st);
                        if (dfd < 0 || tst->ss->load_super(tst, dfd, NULL) != 0) {
                                fprintf(stderr, Name ": cannot re-read metadata from %s - aborting\n",
@@ -669,8 +667,6 @@ int Assemble(struct supertype *st, char *mddev,
                        int dfd;
                        dfd = dev_open(devname, O_RDWR|O_EXCL);
 
-                       remove_partitions(dfd);
-
                        if (dfd < 0 || tst->ss->load_super(tst, dfd, NULL) != 0) {
                                fprintf(stderr, Name ": cannot re-read metadata from %s - aborting\n",
                                        devname);
@@ -1104,6 +1100,12 @@ int Assemble(struct supertype *st, char *mddev,
                                j = chosen_drive;
 
                        if (j >= 0 /* && devices[j].uptodate */) {
+                               int dfd = dev_open(devices[j].devname,
+                                                  O_RDWR|O_EXCL);
+                               if (dfd >= 0) {
+                                       remove_partitions(dfd);
+                                       close(dfd);
+                               }
                                rv = add_disk(mdfd, st, content, &devices[j].i);
 
                                if (rv) {