dcavalca / rpms / mdadm

Forked from rpms/mdadm 3 years ago
Clone

Blame SOURCES/Avoid-to-take-spare-without-defined-domain-by-imsm.patch

b7f731
commit 3bf9495270d7cd00da942e183dc5f7c7eb68ff69
b7f731
Author: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com>
b7f731
Date:   Thu Jan 11 12:39:49 2018 +0100
b7f731
b7f731
    policy.c: Avoid to take spare without defined domain by imsm
b7f731
    
b7f731
    Only Imsm get_disk_controller_domain returns disk controller domain for
b7f731
    each disk. It causes that mdadm automatically creates disk controller
b7f731
    domain policy for imsm metadata, and imsm containers in the same disk
b7f731
    controller domain can take spare for recovery.
b7f731
    
b7f731
    Ignore spares if only one imsm domain is matched.
b7f731
    
b7f731
    Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com>
b7f731
    Signed-off-by: Jes Sorensen <jsorensen@fb.com>
b7f731
b7f731
diff --git a/policy.c b/policy.c
b7f731
index b17585a..c0d18a7 100644
b7f731
--- a/policy.c
b7f731
+++ b/policy.c
b7f731
@@ -661,6 +661,7 @@ int domain_test(struct domainlist *dom, struct dev_policy *pol,
b7f731
 	 *  1:  has domains, all match
b7f731
 	 */
b7f731
 	int found_any = -1;
b7f731
+	int has_one_domain = 1;
b7f731
 	struct dev_policy *p;
b7f731
 
b7f731
 	pol = pol_find(pol, pol_domain);
b7f731
@@ -670,6 +671,9 @@ int domain_test(struct domainlist *dom, struct dev_policy *pol,
b7f731
 			dom = dom->next;
b7f731
 		if (!dom || strcmp(dom->dom, p->value) != 0)
b7f731
 			return 0;
b7f731
+		if (has_one_domain && metadata && strcmp(metadata, "imsm") == 0)
b7f731
+			found_any = -1;
b7f731
+		has_one_domain = 0;
b7f731
 	}
b7f731
 	return found_any;
b7f731
 }