]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Allow --incremental to add spares to an array.
authorNeilBrown <neilb@suse.de>
Thu, 12 Aug 2010 01:41:41 +0000 (11:41 +1000)
committerNeilBrown <neilb@suse.de>
Thu, 12 Aug 2010 01:41:41 +0000 (11:41 +1000)
Commit 3a6ec29ad56 stopped us from adding apparently-working devices
to an active array with --incremental as there is a good chance that they
are actually old/failed devices.

Unfortunately it also stopped spares from being added to an active
array, which is wrong.  This patch refines the test to be more
careful.

Reported-by: <fibreraid@gmail.com>
Analysed-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
Incremental.c

index e4b6196a5682752a48276e785fb4fc53d6572ca6..4d3d181b10fbac9cce3e0dc119120925830fc5d4 100644 (file)
@@ -370,14 +370,15 @@ int Incremental(char *devname, int verbose, int runstop,
                else
                        strcpy(chosen_name, devnum2devname(mp->devnum));
 
-               /* It is generally not OK to add drives to a running array
-                * as they are probably missing because they failed.
-                * However if runstop is 1, then the array was possibly
-                * started early and our best be is to add this anyway.
-                * It would probably be good to allow explicit policy
-                * statement about this.
+               /* It is generally not OK to add non-spare drives to a
+                * running array as they are probably missing because
+                * they failed.  However if runstop is 1, then the
+                * array was possibly started early and our best be is
+                * to add this anyway.  It would probably be good to
+                * allow explicit policy statement about this.
                 */
-               if (runstop < 1) {
+               if ((info.disk.state & (1<<MD_DISK_SYNC)) != 0
+                   && runstop < 1) {
                        int active = 0;
                        
                        if (st->ss->external) {