All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sysfs: include faulty drive in disk count
@ 2017-11-07 15:49 Mariusz Tkaczyk
  2017-11-09 20:46 ` Jes Sorensen
  0 siblings, 1 reply; 4+ messages in thread
From: Mariusz Tkaczyk @ 2017-11-07 15:49 UTC (permalink / raw)
  To: jsorensen; +Cc: linux-raid, Mariusz Tkaczyk

When the disk fails, it goes into faulty state first and it is removed
from the array in a while. It gives mdadm monitor a chance to see the disk
has failed and notify an event (e.g. FailSpare). It doesn't work when 
sysfs is used to get a number of disks in the array as it skips faulty
disk. ioctl implementation doesn't differentiate between active and
faulty disk. Do the same for sysfs then. It should not matter that number
of disks reported is greater than list of disk structures returned by the
call because the same approach already takes place for offline disks.

Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@intel.com>
---
 sysfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sysfs.c b/sysfs.c
index bf5c8c5..df6fdda 100644
--- a/sysfs.c
+++ b/sysfs.c
@@ -307,6 +307,7 @@ struct mdinfo *sysfs_read(int fd, char *devnm, unsigned long options)
 		dev->disk.raid_disk = strtoul(buf, &ep, 10);
 		if (*ep) dev->disk.raid_disk = -1;
 
+		sra->array.nr_disks++;
 		strcpy(dbase, "block/dev");
 		if (load_sys(fname, buf, sizeof(buf))) {
 			/* assume this is a stale reference to a hot
@@ -315,7 +316,6 @@ struct mdinfo *sysfs_read(int fd, char *devnm, unsigned long options)
 			free(dev);
 			continue;
 		}
-		sra->array.nr_disks++;
 		sscanf(buf, "%d:%d", &dev->disk.major, &dev->disk.minor);
 
 		/* special case check for block devices that can go 'offline' */
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-11-13 13:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-07 15:49 [PATCH] sysfs: include faulty drive in disk count Mariusz Tkaczyk
2017-11-09 20:46 ` Jes Sorensen
2017-11-13  8:09   ` Tomasz Majchrzak
2017-11-13 13:14     ` Jes Sorensen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.