|
|
2c1b57 |
From aed5f5c34c2b248876b874898d0b3bf65b6cca53 Mon Sep 17 00:00:00 2001
|
|
|
2c1b57 |
From: Jes Sorensen <jsorensen@fb.com>
|
|
|
2c1b57 |
Date: Tue, 9 May 2017 16:49:33 -0400
|
|
|
2c1b57 |
Subject: [RHEL7.5 PATCH 128/169] Monitor/check_array: Read sysfs entry
|
|
|
2c1b57 |
earlier
|
|
|
2c1b57 |
|
|
|
2c1b57 |
This will allow us to pull additional info from sysfs, such as level
|
|
|
2c1b57 |
and device info.
|
|
|
2c1b57 |
|
|
|
2c1b57 |
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
|
|
|
2c1b57 |
---
|
|
|
2c1b57 |
Monitor.c | 16 ++++++++++------
|
|
|
2c1b57 |
1 file changed, 10 insertions(+), 6 deletions(-)
|
|
|
2c1b57 |
|
|
|
2c1b57 |
diff --git a/Monitor.c b/Monitor.c
|
|
|
2c1b57 |
index bb3a2c4..75aea91 100644
|
|
|
2c1b57 |
--- a/Monitor.c
|
|
|
2c1b57 |
+++ b/Monitor.c
|
|
|
2c1b57 |
@@ -451,7 +451,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
|
|
|
2c1b57 |
* '1' if the array is degraded, or '0' if it is optimal (or dead).
|
|
|
2c1b57 |
*/
|
|
|
2c1b57 |
struct { int state, major, minor; } info[MAX_DISKS];
|
|
|
2c1b57 |
- struct mdinfo *sra;
|
|
|
2c1b57 |
+ struct mdinfo *sra = NULL;
|
|
|
2c1b57 |
mdu_array_info_t array;
|
|
|
2c1b57 |
struct mdstat_ent *mse = NULL, *mse2;
|
|
|
2c1b57 |
char *dev = st->devname;
|
|
|
2c1b57 |
@@ -478,6 +478,13 @@ 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 |
+
|
|
|
2c1b57 |
+ sra = sysfs_read(-1, st->devnm, GET_MISMATCH);
|
|
|
2c1b57 |
+ if (!sra)
|
|
|
2c1b57 |
+ goto disappeared;
|
|
|
2c1b57 |
+
|
|
|
2c1b57 |
/* It's much easier to list what array levels can't
|
|
|
2c1b57 |
* have a device disappear than all of them that can
|
|
|
2c1b57 |
*/
|
|
|
2c1b57 |
@@ -487,8 +494,6 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
|
|
|
2c1b57 |
st->err++;
|
|
|
2c1b57 |
goto out;
|
|
|
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 |
@@ -557,7 +562,6 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
|
|
|
2c1b57 |
* If there is a number in /mismatch_cnt,
|
|
|
2c1b57 |
* we should report that.
|
|
|
2c1b57 |
*/
|
|
|
2c1b57 |
- sra = sysfs_read(-1, st->devnm, GET_MISMATCH);
|
|
|
2c1b57 |
if (sra && sra->mismatch_cnt > 0) {
|
|
|
2c1b57 |
char cnt[80];
|
|
|
2c1b57 |
snprintf(cnt, sizeof(cnt),
|
|
|
2c1b57 |
@@ -566,8 +570,6 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
|
|
|
2c1b57 |
alert("RebuildFinished", dev, cnt, ainfo);
|
|
|
2c1b57 |
} else
|
|
|
2c1b57 |
alert("RebuildFinished", dev, NULL, ainfo);
|
|
|
2c1b57 |
- if (sra)
|
|
|
2c1b57 |
- sysfs_free(sra);
|
|
|
2c1b57 |
}
|
|
|
2c1b57 |
st->percent = mse->percent;
|
|
|
2c1b57 |
|
|
|
2c1b57 |
@@ -644,6 +646,8 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
|
|
|
2c1b57 |
retval = 1;
|
|
|
2c1b57 |
|
|
|
2c1b57 |
out:
|
|
|
2c1b57 |
+ if (sra)
|
|
|
2c1b57 |
+ sysfs_free(sra);
|
|
|
2c1b57 |
if (fd > 0)
|
|
|
2c1b57 |
close(fd);
|
|
|
2c1b57 |
return retval;
|
|
|
2c1b57 |
--
|
|
|
2c1b57 |
2.7.4
|
|
|
2c1b57 |
|