]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Incremental: restore assembly for inactive containers, block active
authorDan Williams <dan.j.williams@intel.com>
Mon, 19 Jul 2010 21:59:25 +0000 (14:59 -0700)
committerDan Williams <dan.j.williams@intel.com>
Mon, 19 Jul 2010 21:59:25 +0000 (14:59 -0700)
GET_ARRAY_INFO always succeeds on an inactive container, so we need to
be a bit more diligent about adding a disk to an active container.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Incremental.c
mdadm.h
util.c

index 96bfcec7fc586f38a1cec96c746cb188981b0bc7..abfea243c1f9143bc1eb6accf36035ae342669eb 100644 (file)
@@ -376,7 +376,16 @@ int Incremental(char *devname, int verbose, int runstop,
                 * statement about this.
                 */
                if (runstop < 1) {
-                       if (ioctl(mdfd, GET_ARRAY_INFO, &ainf) == 0) {
+                       int active = 0;
+                       
+                       if (st->ss->external) {
+                               char *devname = devnum2devname(fd2devnum(mdfd));
+
+                               active = devname && is_container_active(devname);
+                               free(devname);
+                       } else if (ioctl(mdfd, GET_ARRAY_INFO, &ainf) == 0)
+                               active = 1;
+                       if (active) {
                                fprintf(stderr, Name
                                        ": not adding %s to active array (without --run) %s\n",
                                        devname, chosen_name);
diff --git a/mdadm.h b/mdadm.h
index 55e9e465fdde8da0b07dd74ed4e738083bffa80d..f1fe24f3c03184eec1ec3200545c89154c1d858a 100644 (file)
--- a/mdadm.h
+++ b/mdadm.h
@@ -930,6 +930,7 @@ extern int open_mddev(char *dev, int report_errors);
 extern int open_container(int fd);
 extern int is_container_member(struct mdstat_ent *ent, char *devname);
 extern int is_subarray_active(char *subarray, char *devname);
+int is_container_active(char *devname);
 extern int open_subarray(char *dev, struct supertype *st, int quiet);
 extern struct superswitch *version_to_superswitch(char *vers);
 
diff --git a/util.c b/util.c
index d22b0d085473925eb2010eb1dc8392aaa681ee02..1ce6a7a93b56d405aac63bb8dbea7a19e8f1a021 100644 (file)
--- a/util.c
+++ b/util.c
@@ -1427,7 +1427,7 @@ int is_subarray_active(char *subarray, char *container)
                if (is_container_member(ent, container)) {
                        char *inst = &ent->metadata_version[10+strlen(container)+1];
 
-                       if (strcmp(inst, subarray) == 0)
+                       if (!subarray || strcmp(inst, subarray) == 0)
                                break;
                }
        }
@@ -1437,6 +1437,11 @@ int is_subarray_active(char *subarray, char *container)
        return ent != NULL;
 }
 
+int is_container_active(char *container)
+{
+       return is_subarray_active(NULL, container);
+}
+
 /* open_subarray - opens a subarray in a container
  * @dev: container device name
  * @st: supertype with only ->subarray set