Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:15.0:Ports
mdadm
0120-Monitor-Use-md_array_active-instead-of-man...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0120-Monitor-Use-md_array_active-instead-of-manually-fidd.patch of Package mdadm
From b9a0309c7fc3e6c1607d51ab3c3f8486478a65ef Mon Sep 17 00:00:00 2001 From: Jes Sorensen <jsorensen@fb.com> Date: Mon, 8 May 2017 17:34:08 -0400 Subject: [PATCH] Monitor: Use md_array_active() instead of manually fiddling in sysfs Git-commit: b9a0309c7fc3e6c1607d51ab3c3f8486478a65ef Patch-mainline: mdadm-4.0+ References: bsc#1069165, bsc#1069167, bsc#1068030 This removes a pile of clutter that can easily behandled with a simple check of array_state. Signed-off-by: Jes Sorensen <jsorensen@fb.com> Signed-off-by: Coly Li <colyli@suse.de> --- Monitor.c | 39 +++++++++++---------------------------- 1 file changed, 11 insertions(+), 28 deletions(-) diff --git a/Monitor.c b/Monitor.c index e2b36ff..b5231d2 100644 --- a/Monitor.c +++ b/Monitor.c @@ -454,7 +454,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat, mdu_array_info_t array; struct mdstat_ent *mse = NULL, *mse2; char *dev = st->devname; - int fd = -1; + int fd; int i; int remaining_disks; int last_disk; @@ -462,33 +462,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat, if (test) alert("TestMessage", dev, NULL, ainfo); - if (st->devnm[0]) - fd = open("/sys/block", O_RDONLY|O_DIRECTORY); - if (fd >= 0) { - /* Don't open the device unless it is present and - * active in sysfs. - */ - char buf[10]; - close(fd); - fd = sysfs_open(st->devnm, NULL, "array_state"); - if (fd < 0 || - read(fd, buf, 10) < 5 || - strncmp(buf,"clear",5) == 0 || - strncmp(buf,"inact",5) == 0) { - if (fd >= 0) - close(fd); - fd = sysfs_open(st->devnm, NULL, "level"); - if (fd < 0 || read(fd, buf, 10) != 0) { - if (fd >= 0) - close(fd); - if (!st->err) - alert("DeviceDisappeared", dev, NULL, ainfo); - st->err++; - return 0; - } - } - close(fd); - } + fd = open(dev, O_RDONLY); if (fd < 0) { if (!st->err) @@ -496,6 +470,15 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat, st->err++; return 0; } + + if (!md_array_active(fd)) { + close(fd); + if (!st->err) + alert("DeviceDisappeared", dev, NULL, ainfo); + st->err++; + return 0; + } + fcntl(fd, F_SETFD, FD_CLOEXEC); if (md_get_array_info(fd, &array) < 0) { if (!st->err) -- 2.13.6
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor