[PATCH 25/35] Monitor: fill devstate of containers based on supertype

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>From 4921d3d110d1bf4b70eabedf7aaabca06ef767e8 Mon Sep 17 00:00:00 2001
From: Anna Czarnowska <anna.czarnowska@xxxxxxxxx>
Date: Tue, 20 Jul 2010 16:16:29 +0100
Subject: [PATCH 25/35] Monitor: fill devstate of containers based on supertype

Normally containers have no information in devstate. Volumes have states
of their members. To get state of all disks in container we use
load_super on container and create mdinfo list with all disk states.
We will use it later to find spares.

Signed-off-by: Anna Czarnowska <anna.czarnowska@xxxxxxxxx>
---
 Monitor.c |   54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 54 insertions(+), 0 deletions(-)

diff --git a/Monitor.c b/Monitor.c
index 91a8b69..776cf54 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -549,6 +549,60 @@ int Monitor(mddev_dev_t devlist,
 	return 0;
 }
 
+/* get states of all disks in each container from metadata*/
+int getinfo_containers(struct state *statelist)
+{
+	struct state *st;
+	struct supertype *sty;
+	int fd, id, i, rv = 1;
+	struct mdinfo *infolist = NULL, *info;
+	for (st = statelist; st; st = st->next) {
+		if (st->err || !is_external(st->metadata_version) ||
+		    is_subarray(st->metadata_version+9))
+			continue;
+		fd = open(st->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, st->devname)) {
+			rv = 0;
+			goto cleanup;
+		}
+		infolist = sty->ss->getinfo_super_disks(sty);
+		if (!infolist) {
+			rv = 0;
+			goto cleanup;
+		}
+		for (i = 0; i<st->total; i++) {
+			if (st->devid[i] == 0)
+				continue;
+			for (info = infolist; info; info = info->next) {
+				id = makedev(info->disk.major, info->disk.minor);
+				if (st->devid[i] == id) {
+					st->devstate[i] = info->disk.state;
+					break;
+				}
+			}
+			if (!info)
+				st->devstate[i] = 1<<MD_DISK_FAULTY;
+		}
+cleanup:
+		close(fd);
+		sty->ss->free_super(sty);
+		free(sty);
+		if (infolist)
+			sysfs_free(infolist);
+		infolist = NULL;
+		if (!rv)
+			return 0;
+	}
+	return 1;
+}
+
 static void alert(char *event, char *dev, char *disc, char *mailaddr, char *mailfrom, char *cmd,
 		  int dosyslog)
 {
-- 
1.6.4.2

---------------------------------------------------------------------
Intel Technology Poland sp. z o.o.
z siedziba w Gdansku
ul. Slowackiego 173
80-298 Gdansk

Sad Rejonowy Gdansk Polnoc w Gdansku, 
VII Wydzial Gospodarczy Krajowego Rejestru Sadowego, 
numer KRS 101882

NIP 957-07-52-316
Kapital zakladowy 200.000 zl

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

--
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


[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux