dcavalca / rpms / mdadm

Forked from rpms/mdadm 3 years ago
Clone

Blame SOURCES/sysfs-sysfs_read-Count-workingdisks.patch

b7f731
From 8b0ebd645202b627982eb3ed9fc72583c4f245d3 Mon Sep 17 00:00:00 2001
b7f731
From: Jes Sorensen <jsorensen@fb.com>
b7f731
Date: Tue, 9 May 2017 17:09:40 -0400
b7f731
Subject: [RHEL7.5 PATCH 133/169] sysfs/sysfs_read: Count working_disks
b7f731
b7f731
This counts working_disks the same way as get_array_info counts it in
b7f731
the kernel.
b7f731
b7f731
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
b7f731
---
b7f731
 sysfs.c | 15 +++++++++------
b7f731
 1 file changed, 9 insertions(+), 6 deletions(-)
b7f731
b7f731
diff --git a/sysfs.c b/sysfs.c
b7f731
index f7967e8..e47f5e4 100644
b7f731
--- a/sysfs.c
b7f731
+++ b/sysfs.c
b7f731
@@ -272,6 +272,7 @@ struct mdinfo *sysfs_read(int fd, char *devnm, unsigned long options)
b7f731
 	sra->array.spare_disks = 0;
b7f731
 	sra->array.active_disks = 0;
b7f731
 	sra->array.failed_disks = 0;
b7f731
+	sra->array.working_disks = 0;
b7f731
 
b7f731
 	devp = &sra->devs;
b7f731
 	sra->devs = NULL;
b7f731
@@ -358,16 +359,18 @@ struct mdinfo *sysfs_read(int fd, char *devnm, unsigned long options)
b7f731
 			strcpy(dbase, "state");
b7f731
 			if (load_sys(fname, buf, sizeof(buf)))
b7f731
 				goto abort;
b7f731
-			if (strstr(buf, "in_sync")) {
b7f731
-				dev->disk.state |= (1<
b7f731
-				sra->array.active_disks++;
b7f731
-			}
b7f731
 			if (strstr(buf, "faulty")) {
b7f731
 				dev->disk.state |= (1<
b7f731
 				sra->array.failed_disks++;
b7f731
+			} else {
b7f731
+				sra->array.working_disks++;
b7f731
+				if (strstr(buf, "in_sync")) {
b7f731
+					dev->disk.state |= (1<
b7f731
+					sra->array.active_disks++;
b7f731
+				}
b7f731
+				if (dev->disk.state == 0)
b7f731
+					sra->array.spare_disks++;
b7f731
 			}
b7f731
-			if (dev->disk.state == 0)
b7f731
-				sra->array.spare_disks++;
b7f731
 		}
b7f731
 		if (options & GET_ERROR) {
b7f731
 			strcpy(buf, "errors");
b7f731
-- 
b7f731
2.7.4
b7f731