dcavalca / rpms / mdadm

Forked from rpms/mdadm 3 years ago
Clone

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

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