Allow domain_test to report that no domains were found.
Sometime we will need to know the difference between no domains found and domains didn't match. So allow domain_test to return different values and fix up all callers to maintain current behaviour. Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
parent
d11128690b
commit
e5508b361d
|
@ -597,7 +597,7 @@ int Assemble(struct supertype *st, char *mddev,
|
||||||
} else {
|
} else {
|
||||||
struct dev_policy *pol = NULL;
|
struct dev_policy *pol = NULL;
|
||||||
pol = devnum_policy(stb.st_rdev);
|
pol = devnum_policy(stb.st_rdev);
|
||||||
if (domain_test(domains, pol, NULL))
|
if (domain_test(domains, pol, NULL) == 1)
|
||||||
/* take this spare if domains match */
|
/* take this spare if domains match */
|
||||||
tmpdev->used = 1;
|
tmpdev->used = 1;
|
||||||
else
|
else
|
||||||
|
|
|
@ -995,7 +995,7 @@ static int array_try_spare(char *devname, int *dfdp, struct dev_policy *pol,
|
||||||
}
|
}
|
||||||
|
|
||||||
dl = domain_from_array(sra, st2->ss->name);
|
dl = domain_from_array(sra, st2->ss->name);
|
||||||
if (!domain_test(dl, pol, st2->ss->name)) {
|
if (domain_test(dl, pol, st2->ss->name) != 1) {
|
||||||
/* domain test fails */
|
/* domain test fails */
|
||||||
if (verbose > 1)
|
if (verbose > 1)
|
||||||
fprintf(stderr, Name ": not adding %s to %s as"
|
fprintf(stderr, Name ": not adding %s to %s as"
|
||||||
|
@ -1111,7 +1111,7 @@ static int partition_try_spare(char *devname, int *dfdp, struct dev_policy *pol,
|
||||||
pol2 = path_policy(de->d_name, type_disk);
|
pol2 = path_policy(de->d_name, type_disk);
|
||||||
|
|
||||||
domain_merge(&domlist, pol2, st ? st->ss->name : NULL);
|
domain_merge(&domlist, pol2, st ? st->ss->name : NULL);
|
||||||
if (domain_test(domlist, pol, st ? st->ss->name : NULL) == 0)
|
if (domain_test(domlist, pol, st ? st->ss->name : NULL) != 1)
|
||||||
/* new device is incompatible with this device. */
|
/* new device is incompatible with this device. */
|
||||||
goto next;
|
goto next;
|
||||||
|
|
||||||
|
@ -1137,7 +1137,7 @@ static int partition_try_spare(char *devname, int *dfdp, struct dev_policy *pol,
|
||||||
if (!st) {
|
if (!st) {
|
||||||
/* Check domain policy again, this time referring to metadata */
|
/* Check domain policy again, this time referring to metadata */
|
||||||
domain_merge(&domlist, pol2, st2->ss->name);
|
domain_merge(&domlist, pol2, st2->ss->name);
|
||||||
if (domain_test(domlist, pol, st2->ss->name) == 0)
|
if (domain_test(domlist, pol, st2->ss->name) != 1)
|
||||||
/* Incompatible devices for this metadata type */
|
/* Incompatible devices for this metadata type */
|
||||||
goto next;
|
goto next;
|
||||||
if (!policy_action_allows(pol, st2->ss->name, act_spare))
|
if (!policy_action_allows(pol, st2->ss->name, act_spare))
|
||||||
|
|
|
@ -778,7 +778,7 @@ static dev_t choose_spare(struct state *from, struct state *to,
|
||||||
if (from->spare_group)
|
if (from->spare_group)
|
||||||
pol_add(&pol, pol_domain,
|
pol_add(&pol, pol_domain,
|
||||||
from->spare_group, NULL);
|
from->spare_group, NULL);
|
||||||
if (domain_test(domlist, pol, to->metadata->ss->name))
|
if (domain_test(domlist, pol, to->metadata->ss->name) == 1)
|
||||||
dev = from->devid[d];
|
dev = from->devid[d];
|
||||||
dev_policy_free(pol);
|
dev_policy_free(pol);
|
||||||
}
|
}
|
||||||
|
|
7
policy.c
7
policy.c
|
@ -648,9 +648,12 @@ int domain_test(struct domainlist *dom, struct dev_policy *pol,
|
||||||
/* Check that all domains in pol (for metadata) are also in
|
/* Check that all domains in pol (for metadata) are also in
|
||||||
* dom. Both lists are sorted.
|
* dom. Both lists are sorted.
|
||||||
* If pol has no domains, we don't really know about this device
|
* If pol has no domains, we don't really know about this device
|
||||||
* so we reject the match.
|
* so we allow caller to choose:
|
||||||
|
* -1: has no domains
|
||||||
|
* 0: has domains, not all match
|
||||||
|
* 1: has domains, all match
|
||||||
*/
|
*/
|
||||||
int found_any = 0;
|
int found_any = -1;
|
||||||
struct dev_policy *p;
|
struct dev_policy *p;
|
||||||
|
|
||||||
pol = pol_find(pol, pol_domain);
|
pol = pol_find(pol, pol_domain);
|
||||||
|
|
2
util.c
2
util.c
|
@ -1956,7 +1956,7 @@ struct mdinfo *container_choose_spares(struct supertype *st,
|
||||||
if (spare_group)
|
if (spare_group)
|
||||||
pol_add(&pol, pol_domain,
|
pol_add(&pol, pol_domain,
|
||||||
spare_group, NULL);
|
spare_group, NULL);
|
||||||
if (!domain_test(domlist, pol, metadata))
|
if (domain_test(domlist, pol, metadata) != 1)
|
||||||
found = 0;
|
found = 0;
|
||||||
dev_policy_free(pol);
|
dev_policy_free(pol);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue