Blame SOURCES/Monitor-containers-don-t-have-the-same-sysfs-propert.patch

2c1b57
From 802961a2396d342b7bb3d548d412be26acbd7fa8 Mon Sep 17 00:00:00 2001
2c1b57
From: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com>
2c1b57
Date: Wed, 16 Aug 2017 14:22:32 +0200
2c1b57
Subject: [RHEL7.5 PATCH 168/169] Monitor: containers don't have the same
2c1b57
 sysfs properties as arrays
2c1b57
2c1b57
GET_MISMATCH option doesn't exist for containers so sysfs_read fails if
2c1b57
this information is requested. Set options according to the device using
2c1b57
information from /proc/mdstat.
2c1b57
2c1b57
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com>
2c1b57
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2c1b57
---
2c1b57
 Monitor.c | 46 ++++++++++++++++++++++++++++------------------
2c1b57
 1 file changed, 28 insertions(+), 18 deletions(-)
2c1b57
2c1b57
diff --git a/Monitor.c b/Monitor.c
2c1b57
index 48c451c..f70e5b5 100644
2c1b57
--- a/Monitor.c
2c1b57
+++ b/Monitor.c
2c1b57
@@ -465,6 +465,8 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
2c1b57
 	int last_disk;
2c1b57
 	int new_array = 0;
2c1b57
 	int retval;
2c1b57
+	int is_container = 0;
2c1b57
+	unsigned long array_only_flags = 0;
2c1b57
 
2c1b57
 	if (test)
2c1b57
 		alert("TestMessage", dev, NULL, ainfo);
2c1b57
@@ -475,6 +477,26 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
2c1b57
 	if (fd < 0)
2c1b57
 		goto disappeared;
2c1b57
 
2c1b57
+	if (st->devnm[0] == 0)
2c1b57
+		strcpy(st->devnm, fd2devnm(fd));
2c1b57
+
2c1b57
+	for (mse2 = mdstat; mse2; mse2 = mse2->next)
2c1b57
+		if (strcmp(mse2->devnm, st->devnm) == 0) {
2c1b57
+			mse2->devnm[0] = 0; /* flag it as "used" */
2c1b57
+			mse = mse2;
2c1b57
+		}
2c1b57
+
2c1b57
+	if (!mse) {
2c1b57
+		/* duplicated array in statelist
2c1b57
+		 * or re-created after reading mdstat
2c1b57
+		 */
2c1b57
+		st->err++;
2c1b57
+		goto out;
2c1b57
+	}
2c1b57
+
2c1b57
+	if (mse->level == NULL)
2c1b57
+		is_container = 1;
2c1b57
+
2c1b57
 	if (!md_array_active(fd))
2c1b57
 		goto disappeared;
2c1b57
 
2c1b57
@@ -482,11 +504,12 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
2c1b57
 	if (md_get_array_info(fd, &array) < 0)
2c1b57
 		goto disappeared;
2c1b57
 
2c1b57
-	if (st->devnm[0] == 0)
2c1b57
-		strcpy(st->devnm, fd2devnm(fd));
2c1b57
+	if (!is_container)
2c1b57
+		array_only_flags |= GET_MISMATCH;
2c1b57
+
2c1b57
+	sra = sysfs_read(-1, st->devnm, GET_LEVEL | GET_DISKS | GET_DEVS |
2c1b57
+			GET_STATE | array_only_flags);
2c1b57
 
2c1b57
-	sra = sysfs_read(-1, st->devnm, GET_LEVEL | GET_DISKS | GET_MISMATCH |
2c1b57
-			 GET_DEVS | GET_STATE);
2c1b57
 	if (!sra)
2c1b57
 		goto disappeared;
2c1b57
 
2c1b57
@@ -500,19 +523,6 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
2c1b57
 		goto out;
2c1b57
 	}
2c1b57
 
2c1b57
-	for (mse2 = mdstat; mse2; mse2 = mse2->next)
2c1b57
-		if (strcmp(mse2->devnm, st->devnm) == 0) {
2c1b57
-			mse2->devnm[0] = 0; /* flag it as "used" */
2c1b57
-			mse = mse2;
2c1b57
-		}
2c1b57
-
2c1b57
-	if (!mse) {
2c1b57
-		/* duplicated array in statelist
2c1b57
-		 * or re-created after reading mdstat*/
2c1b57
-		st->err++;
2c1b57
-		close(fd);
2c1b57
-		goto out;
2c1b57
-	}
2c1b57
 	/* this array is in /proc/mdstat */
2c1b57
 	if (array.utime == 0)
2c1b57
 		/* external arrays don't update utime, so
2c1b57
@@ -653,7 +663,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
2c1b57
  out:
2c1b57
 	if (sra)
2c1b57
 		sysfs_free(sra);
2c1b57
-	if (fd > 0)
2c1b57
+	if (fd >= 0)
2c1b57
 		close(fd);
2c1b57
 	return retval;
2c1b57
 
2c1b57
-- 
2c1b57
2.7.4
2c1b57