|
|
2c1b57 |
From b13b52c80f3d9e3184ea1d6d39aa7053ef7bae49 Mon Sep 17 00:00:00 2001
|
|
|
2c1b57 |
From: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
|
|
|
2c1b57 |
Date: Wed, 31 May 2017 12:46:57 +0200
|
|
|
2c1b57 |
Subject: [RHEL7.5 PATCH 151/169] Get failed disk count from array state
|
|
|
2c1b57 |
|
|
|
2c1b57 |
Recent commit has changed the way failed disks are counted. It breaks
|
|
|
2c1b57 |
recovery for external metadata arrays as failed disks are not part of
|
|
|
2c1b57 |
the array and have no corresponding entries is sysfs (they are only
|
|
|
2c1b57 |
reported for containers) so degraded arrays show no failed disks.
|
|
|
2c1b57 |
|
|
|
2c1b57 |
Recent commit overwrites GET_DEGRADED result prior to GET_STATE and it
|
|
|
2c1b57 |
is not set again if GET_STATE has not been requested. As GET_STATE
|
|
|
2c1b57 |
provides the same information as GET_DEGRADED, the latter is not needed
|
|
|
2c1b57 |
anymore. Remove GET_DEGRADED option and replace it with GET_STATE
|
|
|
2c1b57 |
option.
|
|
|
2c1b57 |
|
|
|
2c1b57 |
Don't count number of failed disks looking at sysfs entries but
|
|
|
2c1b57 |
calculate it at the end. Do it only for arrays as containers report
|
|
|
2c1b57 |
no disks, just spares.
|
|
|
2c1b57 |
|
|
|
2c1b57 |
Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
|
|
|
2c1b57 |
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
|
|
|
2c1b57 |
---
|
|
|
2c1b57 |
Incremental.c | 14 ++++----------
|
|
|
2c1b57 |
Monitor.c | 4 ++--
|
|
|
2c1b57 |
managemon.c | 4 ++--
|
|
|
2c1b57 |
mdadm.h | 1 -
|
|
|
2c1b57 |
raid6check.c | 2 +-
|
|
|
2c1b57 |
sysfs.c | 18 ++++++++----------
|
|
|
2c1b57 |
6 files changed, 17 insertions(+), 26 deletions(-)
|
|
|
2c1b57 |
|
|
|
2c1b57 |
diff --git a/Incremental.c b/Incremental.c
|
|
|
2c1b57 |
index 30dc7a2..6cf2174 100644
|
|
|
2c1b57 |
--- a/Incremental.c
|
|
|
2c1b57 |
+++ b/Incremental.c
|
|
|
2c1b57 |
@@ -886,16 +886,10 @@ static int array_try_spare(char *devname, int *dfdp, struct dev_policy *pol,
|
|
|
2c1b57 |
}
|
|
|
2c1b57 |
sra = sysfs_read(-1, mp->devnm,
|
|
|
2c1b57 |
GET_DEVS|GET_OFFSET|GET_SIZE|GET_STATE|
|
|
|
2c1b57 |
- GET_DEGRADED|GET_COMPONENT|GET_VERSION);
|
|
|
2c1b57 |
- if (!sra) {
|
|
|
2c1b57 |
- /* Probably a container - no degraded info */
|
|
|
2c1b57 |
- sra = sysfs_read(-1, mp->devnm,
|
|
|
2c1b57 |
- GET_DEVS|GET_OFFSET|GET_SIZE|GET_STATE|
|
|
|
2c1b57 |
- GET_COMPONENT|GET_VERSION);
|
|
|
2c1b57 |
- if (sra)
|
|
|
2c1b57 |
- sra->array.failed_disks = -1;
|
|
|
2c1b57 |
- }
|
|
|
2c1b57 |
- if (!sra)
|
|
|
2c1b57 |
+ GET_COMPONENT|GET_VERSION);
|
|
|
2c1b57 |
+ if (sra)
|
|
|
2c1b57 |
+ sra->array.failed_disks = -1;
|
|
|
2c1b57 |
+ else
|
|
|
2c1b57 |
continue;
|
|
|
2c1b57 |
if (st == NULL) {
|
|
|
2c1b57 |
int i;
|
|
|
2c1b57 |
diff --git a/Monitor.c b/Monitor.c
|
|
|
2c1b57 |
index 725f47d..bef2f1b 100644
|
|
|
2c1b57 |
--- a/Monitor.c
|
|
|
2c1b57 |
+++ b/Monitor.c
|
|
|
2c1b57 |
@@ -485,8 +485,8 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
|
|
|
2c1b57 |
if (st->devnm[0] == 0)
|
|
|
2c1b57 |
strcpy(st->devnm, fd2devnm(fd));
|
|
|
2c1b57 |
|
|
|
2c1b57 |
- sra = sysfs_read(-1, st->devnm, GET_LEVEL | GET_DISKS | GET_DEGRADED |
|
|
|
2c1b57 |
- GET_MISMATCH | GET_DEVS | GET_STATE);
|
|
|
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 |
diff --git a/managemon.c b/managemon.c
|
|
|
2c1b57 |
index a8df666..68f0c2d 100644
|
|
|
2c1b57 |
--- a/managemon.c
|
|
|
2c1b57 |
+++ b/managemon.c
|
|
|
2c1b57 |
@@ -685,8 +685,8 @@ static void manage_new(struct mdstat_ent *mdstat,
|
|
|
2c1b57 |
|
|
|
2c1b57 |
mdi = sysfs_read(-1, mdstat->devnm,
|
|
|
2c1b57 |
GET_LEVEL|GET_CHUNK|GET_DISKS|GET_COMPONENT|
|
|
|
2c1b57 |
- GET_DEGRADED|GET_SAFEMODE|
|
|
|
2c1b57 |
- GET_DEVS|GET_OFFSET|GET_SIZE|GET_STATE|GET_LAYOUT);
|
|
|
2c1b57 |
+ GET_SAFEMODE|GET_DEVS|GET_OFFSET|GET_SIZE|GET_STATE|
|
|
|
2c1b57 |
+ GET_LAYOUT);
|
|
|
2c1b57 |
|
|
|
2c1b57 |
if (!mdi)
|
|
|
2c1b57 |
return;
|
|
|
2c1b57 |
diff --git a/mdadm.h b/mdadm.h
|
|
|
2c1b57 |
index ec0a39e..ee9b837 100644
|
|
|
2c1b57 |
--- a/mdadm.h
|
|
|
2c1b57 |
+++ b/mdadm.h
|
|
|
2c1b57 |
@@ -637,7 +637,6 @@ enum sysfs_read_flags {
|
|
|
2c1b57 |
GET_MISMATCH = (1 << 5),
|
|
|
2c1b57 |
GET_VERSION = (1 << 6),
|
|
|
2c1b57 |
GET_DISKS = (1 << 7),
|
|
|
2c1b57 |
- GET_DEGRADED = (1 << 8),
|
|
|
2c1b57 |
GET_SAFEMODE = (1 << 9),
|
|
|
2c1b57 |
GET_BITMAP_LOCATION = (1 << 10),
|
|
|
2c1b57 |
|
|
|
2c1b57 |
diff --git a/raid6check.c b/raid6check.c
|
|
|
2c1b57 |
index 551f835..a8e6005 100644
|
|
|
2c1b57 |
--- a/raid6check.c
|
|
|
2c1b57 |
+++ b/raid6check.c
|
|
|
2c1b57 |
@@ -562,7 +562,7 @@ int main(int argc, char *argv[])
|
|
|
2c1b57 |
GET_LEVEL|
|
|
|
2c1b57 |
GET_LAYOUT|
|
|
|
2c1b57 |
GET_DISKS|
|
|
|
2c1b57 |
- GET_DEGRADED |
|
|
|
2c1b57 |
+ GET_STATE |
|
|
|
2c1b57 |
GET_COMPONENT|
|
|
|
2c1b57 |
GET_CHUNK|
|
|
|
2c1b57 |
GET_DEVS|
|
|
|
2c1b57 |
diff --git a/sysfs.c b/sysfs.c
|
|
|
2c1b57 |
index e47f5e4..78d2b52 100644
|
|
|
2c1b57 |
--- a/sysfs.c
|
|
|
2c1b57 |
+++ b/sysfs.c
|
|
|
2c1b57 |
@@ -162,18 +162,12 @@ struct mdinfo *sysfs_read(int fd, char *devnm, unsigned long options)
|
|
|
2c1b57 |
goto abort;
|
|
|
2c1b57 |
sra->array.layout = strtoul(buf, NULL, 0);
|
|
|
2c1b57 |
}
|
|
|
2c1b57 |
- if (options & GET_DISKS) {
|
|
|
2c1b57 |
+ if (options & (GET_DISKS|GET_STATE)) {
|
|
|
2c1b57 |
strcpy(base, "raid_disks");
|
|
|
2c1b57 |
if (load_sys(fname, buf, sizeof(buf)))
|
|
|
2c1b57 |
goto abort;
|
|
|
2c1b57 |
sra->array.raid_disks = strtoul(buf, NULL, 0);
|
|
|
2c1b57 |
}
|
|
|
2c1b57 |
- if (options & GET_DEGRADED) {
|
|
|
2c1b57 |
- strcpy(base, "degraded");
|
|
|
2c1b57 |
- if (load_sys(fname, buf, sizeof(buf)))
|
|
|
2c1b57 |
- goto abort;
|
|
|
2c1b57 |
- sra->array.failed_disks = strtoul(buf, NULL, 0);
|
|
|
2c1b57 |
- }
|
|
|
2c1b57 |
if (options & GET_COMPONENT) {
|
|
|
2c1b57 |
strcpy(base, "component_size");
|
|
|
2c1b57 |
if (load_sys(fname, buf, sizeof(buf)))
|
|
|
2c1b57 |
@@ -359,10 +353,9 @@ struct mdinfo *sysfs_read(int fd, char *devnm, unsigned long options)
|
|
|
2c1b57 |
strcpy(dbase, "state");
|
|
|
2c1b57 |
if (load_sys(fname, buf, sizeof(buf)))
|
|
|
2c1b57 |
goto abort;
|
|
|
2c1b57 |
- if (strstr(buf, "faulty")) {
|
|
|
2c1b57 |
+ if (strstr(buf, "faulty"))
|
|
|
2c1b57 |
dev->disk.state |= (1<
|
|
|
2c1b57 |
- sra->array.failed_disks++;
|
|
|
2c1b57 |
- } else {
|
|
|
2c1b57 |
+ else {
|
|
|
2c1b57 |
sra->array.working_disks++;
|
|
|
2c1b57 |
if (strstr(buf, "in_sync")) {
|
|
|
2c1b57 |
dev->disk.state |= (1<
|
|
|
2c1b57 |
@@ -379,6 +372,11 @@ struct mdinfo *sysfs_read(int fd, char *devnm, unsigned long options)
|
|
|
2c1b57 |
dev->errors = strtoul(buf, NULL, 0);
|
|
|
2c1b57 |
}
|
|
|
2c1b57 |
}
|
|
|
2c1b57 |
+
|
|
|
2c1b57 |
+ if ((options & GET_STATE) && sra->array.raid_disks)
|
|
|
2c1b57 |
+ sra->array.failed_disks = sra->array.raid_disks -
|
|
|
2c1b57 |
+ sra->array.active_disks - sra->array.spare_disks;
|
|
|
2c1b57 |
+
|
|
|
2c1b57 |
closedir(dir);
|
|
|
2c1b57 |
return sra;
|
|
|
2c1b57 |
|
|
|
2c1b57 |
--
|
|
|
2c1b57 |
2.7.4
|
|
|
2c1b57 |
|