]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Incr: don't exclude 'active' devices from auto inclusion in a container.
authorNeilBrown <neilb@suse.de>
Tue, 1 Feb 2011 02:07:36 +0000 (13:07 +1100)
committerNeilBrown <neilb@suse.de>
Tue, 1 Feb 2011 02:07:36 +0000 (13:07 +1100)
For containers, it is always appropriate to include a device in the
container.
Whether it should then be included in an array is a separate question.

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

index 7a4906dd5a2458834cc0636fe60314b95fdab5e8..0d0a1fdcae90420bfc4b0104bedda434c9429138 100644 (file)
@@ -358,22 +358,17 @@ int Incremental(char *devname, int verbose, int runstop,
                 * array was possibly started early and our best bet is
                 * to add this anyway.
                 * Also if action policy is re-add or better we allow
-                * re-add
+                * re-add.
+                * This doesn't apply to containers as the 'non-spare'
+                * flag has a different meaning.  The test has to happen
+                * at the device level there
                 */
-               if ((info.disk.state & (1<<MD_DISK_SYNC)) != 0
+               if (!st->ss->external
+                   && (info.disk.state & (1<<MD_DISK_SYNC)) != 0
                    && ! policy_action_allows(policy, st->ss->name,
                                              act_re_add)
                    && runstop < 1) {
-                       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) {
+                       if (ioctl(mdfd, GET_ARRAY_INFO, &ainf) == 0) {
                                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 8fa3af466ef81e997838e63f62af769528ea50b1..608095f42bba91f489c33bb2858cde5f8c2730a5 100644 (file)
--- a/mdadm.h
+++ b/mdadm.h
@@ -1164,7 +1164,6 @@ 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, char *subarray, struct supertype *st, int quiet);
 extern struct superswitch *version_to_superswitch(char *vers);
 
diff --git a/util.c b/util.c
index 38750b248892e5eef8dcc1e38e42521ba5a64553..a0d8283c79bdcedf7f96e18b7b63acef28595bb1 100644 (file)
--- a/util.c
+++ b/util.c
@@ -1490,8 +1490,7 @@ int is_subarray_active(char *subarray, char *container)
 
        for (ent = mdstat; ent; ent = ent->next)
                if (is_container_member(ent, container))
-                       if (!subarray ||
-                           strcmp(to_subarray(ent, container), subarray) == 0)
+                       if (strcmp(to_subarray(ent, container), subarray) == 0)
                                break;
 
        free_mdstat(mdstat);
@@ -1499,11 +1498,6 @@ 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: empty supertype