Blame SOURCES/Detail-determine2-array-state-from-sysfs.patch

2c1b57
From a4dcdb23ea639d14e92d1c86336de7ad505b2f7d Mon Sep 17 00:00:00 2001
2c1b57
From: Jes Sorensen <jsorensen@fb.com>
2c1b57
Date: Tue, 25 Apr 2017 11:40:27 -0400
2c1b57
Subject: [RHEL7.5 PATCH 095/169] Detail: determine array state from sysfs
2c1b57
2c1b57
This is easily obtained from sysfs as part of the existing call to
2c1b57
sysfs_read() and it simplifies the code a little too.
2c1b57
2c1b57
Another small step in the process of getting rid of the GET_ARRAY_STATE
2c1b57
ioctl.
2c1b57
2c1b57
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2c1b57
---
2c1b57
 Detail.c | 9 ++++-----
2c1b57
 1 file changed, 4 insertions(+), 5 deletions(-)
2c1b57
2c1b57
diff --git a/Detail.c b/Detail.c
2c1b57
index 91c5a98..eb69276 100644
2c1b57
--- a/Detail.c
2c1b57
+++ b/Detail.c
2c1b57
@@ -86,7 +86,7 @@ int Detail(char *dev, struct context *c)
2c1b57
 			dev, strerror(errno));
2c1b57
 		return rv;
2c1b57
 	}
2c1b57
-	sra = sysfs_read(fd, NULL, GET_VERSION|GET_DEVS);
2c1b57
+	sra = sysfs_read(fd, NULL, GET_VERSION | GET_DEVS | GET_ARRAY_STATE);
2c1b57
 	if (!sra) {
2c1b57
 		pr_err("%s does not appear to be an md device\n", dev);
2c1b57
 		close(fd);
2c1b57
@@ -94,10 +94,10 @@ int Detail(char *dev, struct context *c)
2c1b57
 	}
2c1b57
 	external = (sra != NULL && sra->array.major_version == -1 &&
2c1b57
 		    sra->array.minor_version == -2);
2c1b57
+	inactive = (sra->array_state == ARRAY_ACTIVE ||
2c1b57
+		    sra->array_state == ARRAY_CLEAR);
2c1b57
 	st = super_by_fd(fd, &subarray);
2c1b57
-	if (md_get_array_info(fd, &array) == 0) {
2c1b57
-		inactive = 0;
2c1b57
-	} else if (errno == ENODEV && sra) {
2c1b57
+	if (md_get_array_info(fd, &array) && errno == ENODEV) {
2c1b57
 		if (sra->array.major_version == -1 &&
2c1b57
 		    sra->array.minor_version == -1 &&
2c1b57
 		    sra->devs == NULL) {
2c1b57
@@ -107,7 +107,6 @@ int Detail(char *dev, struct context *c)
2c1b57
 			return rv;
2c1b57
 		}
2c1b57
 		array = sra->array;
2c1b57
-		inactive = 1;
2c1b57
 	} else {
2c1b57
 		pr_err("cannot get array detail for %s: %s\n",
2c1b57
 		       dev, strerror(errno));
2c1b57
-- 
2c1b57
2.7.4
2c1b57