From: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com>
To: linux-raid@vger.kernel.org
Cc: jes.sorensen@gmail.com, Mariusz Tkaczyk <mariusz.tkaczyk@intel.com>
Subject: [PATCH v2] Monitor: containers don't have the same sysfs properties as arrays
Date: Thu, 27 Jul 2017 15:22:08 +0200 [thread overview]
Message-ID: <1501161728-580-1-git-send-email-mariusz.tkaczyk@intel.com> (raw)
GET_MISMATCH option doesn't exist for containers so sysfs_read fails if
this information is requested. Set options according to the device using
information from /proc/mdstat.
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com>
---
Monitor.c | 45 +++++++++++++++++++++++++++------------------
1 file changed, 27 insertions(+), 18 deletions(-)
diff --git a/Monitor.c b/Monitor.c
index 48c451c..de470bd 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -465,6 +465,8 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
int last_disk;
int new_array = 0;
int retval;
+ int is_container;
+ unsigned long array_only_flags = 0;
if (test)
alert("TestMessage", dev, NULL, ainfo);
@@ -475,6 +477,25 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
if (fd < 0)
goto disappeared;
+ if (st->devnm[0] == 0)
+ strcpy(st->devnm, fd2devnm(fd));
+
+ for (mse2 = mdstat; mse2; mse2 = mse2->next)
+ if (strcmp(mse2->devnm, st->devnm) == 0) {
+ mse2->devnm[0] = 0; /* flag it as "used" */
+ mse = mse2;
+ }
+
+ if (!mse) {
+ /* duplicated array in statelist
+ * or re-created after reading mdstat
+ */
+ st->err++;
+ goto out;
+ }
+
+ is_container = mse->level == NULL;
+
if (!md_array_active(fd))
goto disappeared;
@@ -482,11 +503,12 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
if (md_get_array_info(fd, &array) < 0)
goto disappeared;
- if (st->devnm[0] == 0)
- strcpy(st->devnm, fd2devnm(fd));
+ if (!is_container)
+ array_only_flags |= GET_MISMATCH;
+
+ sra = sysfs_read(-1, st->devnm, GET_LEVEL | GET_DISKS | GET_DEVS |
+ GET_STATE | array_only_flags);
- sra = sysfs_read(-1, st->devnm, GET_LEVEL | GET_DISKS | GET_MISMATCH |
- GET_DEVS | GET_STATE);
if (!sra)
goto disappeared;
@@ -500,19 +522,6 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
goto out;
}
- for (mse2 = mdstat; mse2; mse2 = mse2->next)
- if (strcmp(mse2->devnm, st->devnm) == 0) {
- mse2->devnm[0] = 0; /* flag it as "used" */
- mse = mse2;
- }
-
- if (!mse) {
- /* duplicated array in statelist
- * or re-created after reading mdstat*/
- st->err++;
- close(fd);
- goto out;
- }
/* this array is in /proc/mdstat */
if (array.utime == 0)
/* external arrays don't update utime, so
@@ -653,7 +662,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
out:
if (sra)
sysfs_free(sra);
- if (fd > 0)
+ if (fd >= 0)
close(fd);
return retval;
--
1.8.3.1
next reply other threads:[~2017-07-27 13:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-27 13:22 Mariusz Tkaczyk [this message]
2017-08-16 10:34 ` [PATCH v2] Monitor: containers don't have the same sysfs properties as arrays Jes Sorensen
2017-08-16 12:22 ` [PATCH v3] " Mariusz Tkaczyk
2017-08-16 12:26 ` Jes Sorensen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1501161728-580-1-git-send-email-mariusz.tkaczyk@intel.com \
--to=mariusz.tkaczyk@intel.com \
--cc=jes.sorensen@gmail.com \
--cc=linux-raid@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).