[PATCH] Monitor: fix for regression with container devices

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch fixes 2 problems introduced by commit 9a518d8: not closing a
file descriptor and ignoring container devices. Array state is always
'inactive' for containers, so we make sure that the device is not a
container by reading the "level" sysfs entry.

Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@xxxxxxxxx>
Reviewed-by: Pawel Baldysiak <pawel.baldysiak@xxxxxxxxx>
---
 Monitor.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/Monitor.c b/Monitor.c
index 971d2ec..66d67ba 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -483,11 +483,17 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
 		    strncmp(buf,"inact",5) == 0) {
 			if (fd >= 0)
 				close(fd);
-			if (!st->err)
-				alert("DeviceDisappeared", dev, NULL, ainfo);
-			st->err++;
-			return 0;
+			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) {
-- 
2.1.2

--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux