From: Czarnowska, Anna Sent: Monday, July 05, 2010 11:28 AM To: Neil Brown Cc: linux-raid@xxxxxxxxxxxxxxx; Czarnowska, Anna; Hawrylewicz Czarnowski, Przemyslaw; Labun, Marcin; Neubauer, Wojciech; Williams, Dan J; Ciechanowski, Ed; dledford@xxxxxxxxxx Subject: [PATCH 14/33] manage: domains support in Manage_subdev From: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@xxxxxxxxx> if disk is added to array, it must belong the same domain as current members of this array. Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@xxxxxxxxx> --- Manage.c | 33 +++++++++++++++++++++++++++++++++ util.c | 15 ++++++++++++++- 2 files changed, 47 insertions(+), 1 deletions(-) diff --git a/Manage.c b/Manage.c index 67bef11..e733c2d 100644 --- a/Manage.c +++ b/Manage.c @@ -354,6 +354,8 @@ int Manage_subdevs(char *devname, int fd, int ouuid[4]; int lfd = -1; int sysfd = -1; + struct domain_ent *arrdomain, *devdomain; + struct subset *arrsubset, *devsubset; if (ioctl(fd, GET_ARRAY_INFO, &array)) { fprintf(stderr, Name ": cannot get array info for %s\n", @@ -361,6 +363,12 @@ int Manage_subdevs(char *devname, int fd, return 1; } + if (get_active_array_domain(devname, fd, &arrdomain, &arrsubset)) { + fprintf(stderr, Name " : Cannot determine domain for %s!\n", + devname); + return 1; + } + /* array.size is only 32 bit and may be truncated. * So read from sysfs if possible, and record number of sectors */ @@ -531,6 +539,31 @@ int Manage_subdevs(char *devname, int fd, st = dup_super(tst); + devdomain = conf_get_domain(dv->devname, + (char *)st->ss->name); + if (!devdomain) { + fprintf(stderr, Name " : Cannot determine domain " + " of device: %s\n", dv->devname); + close(tfd); + free(st); + return 1; + } + devsubset = conf_get_subset(dv->devname, st, devdomain); + if (!devsubset) { + fprintf(stderr, Name " : Cannot determine subset " + " of device: %s\n", dv->devname); + close(tfd); + free(st); + return 1; + } + if (arrdomain != devdomain || + arrsubset != devsubset) { + fprintf(stderr, Name " : Domain/subdomain of " + "disk differs of arrays'."); + close(tfd); + free(st); + return 1; + } if (array.not_persistent==0) st->ss->load_super(st, tfd, NULL); diff --git a/util.c b/util.c index 62544fd..a746b83 100644 --- a/util.c +++ b/util.c @@ -1893,7 +1893,20 @@ int get_active_array_domain(char *array_name, int fd, struct domain_ent **domain st = dev_load_supertype(dm->name); if (!st) continue; - *domain = conf_get_domain(dm->name, me->metadata_version); + if (!strncmp(me->metadata_version, "external:", 9) && + is_subarray(me->metadata_version+9)) { + struct mdstat_ent *m; + for (m = mds; m; m = m->next) + if (devname2devnum(me->metadata_version+10) == m->devnum) + break; + if (!m) + continue; + *domain = conf_get_domain(dm->name, + m->metadata_version); + } else { + *domain = conf_get_domain(dm->name, + me->metadata_version); + } if (!*domain) { st->ss->free_super(st); free(st); -- 1.6.4.2 -- To unsubscribe from this list: send the line "unsubscribe linux-raid" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html