]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Allow explicitly listed spared to be included by default.
authorNeilBrown <neilb@suse.de>
Tue, 1 Feb 2011 03:44:02 +0000 (14:44 +1100)
committerNeilBrown <neilb@suse.de>
Tue, 1 Feb 2011 03:44:02 +0000 (14:44 +1100)
When the metadata doesn't identify which array a spare belongs to
we normally require an explicit domain match to connect a spare
with an array.
However when the spare is explicitly listed in argv, it should be
safe to include as long as there is no domain conflict.

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

index b3f54ce43a811b28f425bf1f92b9cb96361af19e..113c29cb2ef711153bc7f9574317d463b9da1e73 100644 (file)
@@ -595,10 +595,15 @@ int Assemble(struct supertype *st, char *mddev,
                                tmpdev->devname, strerror(errno));
                        tmpdev->used = 2;
                } else {
-                       struct dev_policy *pol = NULL;
-                       pol = devnum_policy(stb.st_rdev);
-                       if (domain_test(domains, pol, NULL) == 1)
-                               /* take this spare if domains match */
+                       struct dev_policy *pol = devnum_policy(stb.st_rdev);
+                       int dt = domain_test(domains, pol, NULL);
+                       if (inargv && dt != 0)
+                               /* take this spare as domains match
+                                * if there are any */
+                               tmpdev->used = 1;
+                       else if (!inargv && dt == 1)
+                               /* device wasn't explicitly listed, so need
+                                * explicit domain match - which we have */
                                tmpdev->used = 1;
                        else
                                /* if domains don't match mark as unused */