diff options
author | Marcin Labun <marcin.labun@intel.com> | 2010-11-22 20:58:07 +1100 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2010-11-22 20:58:07 +1100 |
commit | 2cda7640f9e2d4eb880914260da6e61a01e5234c (patch) | |
tree | e31b7d232957631631b18b7f32810c79cf053ff1 /super-intel.c | |
parent | 80e7f8c31a514b02d227a083cb2bcb34f70c0eee (diff) |
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 'super-intel.c')
-rw-r--r-- | super-intel.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/super-intel.c b/super-intel.c index 805ee997..7087af23 100644 --- a/super-intel.c +++ b/super-intel.c @@ -5635,6 +5635,41 @@ static void imsm_delete(struct intel_super *super, struct dl **dlp, unsigned ind } #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, @@ -5670,6 +5705,7 @@ struct superswitch 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", |