diff options
author | Marcin Labun <marcin.labun@intel.com> | 2010-11-22 10:58:07 +0100 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2010-11-22 10:58:07 +0100 |
commit | 2cda7640f9e2d4eb880914260da6e61a01e5234c (patch) | |
tree | e31b7d232957631631b18b7f32810c79cf053ff1 /policy.c | |
parent | Monitor: Allow metadata to set minimum size for spare to migrate in. (diff) | |
download | mdadm-2cda7640f9e2d4eb880914260da6e61a01e5234c.tar.xz mdadm-2cda7640f9e2d4eb880914260da6e61a01e5234c.zip |
Policy is aware of metadata disk's controller domains.
Platform (metadata) domain let the metadata handlers differentiate
disk domains based on controllers that the disk belongs to.
Platform domain is sub-domain inside user specified domain
in mdadm.conf configuration files inheriting all parameters from it.
The metadata domain name is used disk domain matching functions.
The disk with the same metadata domain name belong to the same metadata
domain.
New metadata handler is added that retrieves platform domain string based
on disk path:
const char *(*get_disk_controller_domain)(const char *path);
Signed-off-by: Marcin Labun <marcin.labun@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'policy.c')
-rw-r--r-- | policy.c | 37 |
1 files changed, 33 insertions, 4 deletions
@@ -40,7 +40,8 @@ * particularly from a set of policy rules in mdadm.conf */ -static void pol_new(struct dev_policy **pol, char *name, char *val, char *metadata) +static void pol_new(struct dev_policy **pol, char *name, const char *val, + const char *metadata) { struct dev_policy *n = malloc(sizeof(*n)); const char *real_metadata = NULL; @@ -64,7 +65,7 @@ static void pol_new(struct dev_policy **pol, char *name, char *val, char *metada real_metadata = super1.name; } if (!real_metadata) { - static char *prev = NULL; + static const char *prev = NULL; if (prev != metadata) { fprintf(stderr, Name ": metadata=%s unrecognised - ignoring rule\n", metadata); @@ -340,6 +341,7 @@ struct dev_policy *path_policy(char *path, char *type) { struct pol_rule *rules; struct dev_policy *pol = NULL; + int i; if (!type) return NULL; @@ -360,6 +362,18 @@ struct dev_policy *path_policy(char *path, char *type) } rules = rules->next; } + + /* Now add any metadata-specific internal knowledge + * about this path + */ + for (i=0; superlist[i]; i++) + if (superlist[i]->get_disk_controller_domain) { + const char *d = + superlist[i]->get_disk_controller_domain(path); + if (d) + pol_new(&pol, pol_domain, d, superlist[i]->name); + } + pol_sort(&pol); pol_dedup(pol); return pol; @@ -521,7 +535,7 @@ void dev_policy_free(struct dev_policy *p) } } -static enum policy_action map_act(char *act) +static enum policy_action map_act(const char *act) { if (strcmp(act, "include") == 0) return act_include; @@ -581,7 +595,8 @@ int disk_action_allows(struct mdinfo *disk, const char *metadata, enum policy_ac * As dev policies are already sorted, this is fairly easy to manage. */ -static struct domainlist **domain_merge_one(struct domainlist **domp, char *domain) +static struct domainlist **domain_merge_one(struct domainlist **domp, + const char *domain) { /* merge a domain name into a sorted list and return the * location of the insertion or match @@ -601,6 +616,20 @@ static struct domainlist **domain_merge_one(struct domainlist **domp, char *doma return domp; } +#if (DEBUG) +void dump_policy(struct dev_policy *policy) +{ + while (policy) { + dprintf("policy: %p name: %s value: %s metadata: %s\n", + policy, + policy->name, + policy->value, + policy->metadata); + policy = policy->next; + } +} +#endif + void domain_merge(struct domainlist **domp, struct dev_policy *pollist, const char *metadata) { |