From: Czarnowska, Anna Sent: Monday, July 05, 2010 11:36 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 22/33] Monitor: added function to get domain and subset of a disk For spare sharing. Performs a check for failed status if required. Signed-off-by: Anna Czarnowska <anna.czarnowska@xxxxxxxxx> --- Monitor.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 49 insertions(+), 0 deletions(-) diff --git a/Monitor.c b/Monitor.c index e16af2d..ed57af0 100644 --- a/Monitor.c +++ b/Monitor.c @@ -601,6 +601,55 @@ int check_disk_is_free(struct state *donor, int disk_idx, int ext) return disk_idx; } +int get_disk_domain_and_subset(int devid, char *metadata_version, struct domain_ent **domain, + struct subset **subset, int fcheck) { + struct supertype *sty; + int fd; + char *devname = map_dev(major(devid), minor(devid), 1); + + if (!devname) + return 0; + fd = open(devname, O_RDONLY); + if (fd < 0) + return 0; + + sty = guess_super(fd); + if (!sty) { + close(fd); + return 0; + } + + if (sty->ss->load_super(sty, fd, devname)) + goto fail; + + /* check metadata for failed status*/ + if (fcheck && disk_faulty(sty, major(devid), minor(devid))) + goto fail; + close(fd); + + *domain = conf_get_domain(strrchr(devname, '/'), metadata_version); + if (*domain == NULL) { + *subset = NULL; + goto fail; + } + + *subset = conf_get_subset(strrchr(devname, '/'), sty, *domain); + if (*subset == NULL) + goto fail; + + sty->ss->free_super(sty); + free(sty); + return 1; + +fail: + if (fd >= 0) + close(fd); + sty->ss->free_super(sty); + free(sty); + return 0; +} + static void alert(char *event, char *dev, char *disc, char *mailaddr, char *mailfrom, char *cmd, int dosyslog) { -- 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