*/
struct mdinfo *(*activate_spare)(struct active_array *a,
struct metadata_update **updates);
+ /*
+ * Return statically allocated string that represents metadata specific
+ * controller domain of the disk. The domain is used in disk domain
+ * matching functions. Disks belong to the same domain if the they have
+ * the same domain from mdadm.conf and belong the same metadata domain.
+ * Returning NULL or not providing this handler means that metadata
+ * does not distinguish the differences between disks that belong to
+ * different controllers. They are in the domain specified by
+ * configuration file (mdadm.conf).
+ * In case when the metadata has the notion of domains based on disk
+ * it shall return NULL for disks that do not belong to the controller
+ * the supported domains. Such disks will form another domain and won't
+ * be mixed with supported ones.
+ */
+ const char *(*get_disk_controller_domain)(const char *path);
int swapuuid; /* true if uuid is bigending rather than hostendian */
int external;
* name and metadata can be compared by address equality.
*/
const char *metadata;
- char *value;
+ const char *value;
};
extern char pol_act[], pol_domain[], pol_metadata[], pol_auto[];
struct domainlist {
struct domainlist *next;
- char *dom;
+ const char *dom;
};
extern int domain_test(struct domainlist *dom, struct dev_policy *pol,
* 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;
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);
{
struct pol_rule *rules;
struct dev_policy *pol = NULL;
+ int i;
if (!type)
return NULL;
}
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;
}
}
-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;
* 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
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)
{
}
#endif /* MDASSEMBLE */
+static char disk_by_path[] = "/dev/disk/by-path/";
+
+static const char *imsm_get_disk_controller_domain(const char *path)
+{
+ struct sys_dev *list, *hba = NULL;
+ char disk_path[PATH_MAX];
+ int ahci = 0;
+ char *dpath = NULL;
+
+ list = find_driver_devices("pci", "ahci");
+ for (hba = list; hba; hba = hba->next)
+ if (devpath_to_vendor(hba->path) == 0x8086)
+ break;
+
+ if (hba) {
+ struct stat st;
+
+ strncpy(disk_path, disk_by_path, PATH_MAX - 1);
+ strncat(disk_path, path, PATH_MAX - strlen(disk_path) - 1);
+ if (stat(disk_path, &st) == 0) {
+ dpath = devt_to_devpath(st.st_rdev);
+ if (dpath)
+ ahci = path_attached_to_hba(dpath, hba->path);
+ }
+ }
+ dprintf("path: %s(%s) hba: %s attached: %d\n",
+ path, dpath, (hba) ? hba->path : "NULL", ahci);
+ free_sys_dev(&list);
+ if (ahci)
+ return "ahci";
+ else
+ return NULL;
+}
+
+
struct superswitch super_imsm = {
#ifndef MDASSEMBLE
.examine_super = examine_super_imsm,
.match_metadata_desc = match_metadata_desc_imsm,
.container_content = container_content_imsm,
.default_layout = imsm_level_to_layout,
+ .get_disk_controller_domain = imsm_get_disk_controller_domain,
.external = 1,
.name = "imsm",