From 52209d6ee1183581e148791cf6ee4d60a0193b1d Mon Sep 17 00:00:00 2001 From: Tomasz Majchrzak Date: Tue, 5 Jul 2016 09:12:51 +0200 Subject: Monitor: release /proc/mdstat fd when no arrays present If md kernel module is reloaded, /proc/mdstat cannot be accessed ("cat: /proc/mdstat: No such file or directory"). The reason is mdadm monitor still holds a file descriptor to previous /proc/mdstat instance. It leads to really confusing outcome of the following operations - mdadm seems to run without errors, however some udev rules don't get executed and new array doesn't work. Add a check if lseek was successful as it fails if md kernel module has been unloaded - close a file descriptor then. The problem is mdadm monitor doesn't always do it before next operation takes place. To prevent it monitor always releases /proc/mdstat descriptor when there are no arrays to be monitored, just in case driver unload happens in a moment. Signed-off-by: Tomasz Majchrzak Reviewed-by: Artur Paszkiewicz Signed-off-by: Jes Sorensen --- Monitor.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Monitor.c') diff --git a/Monitor.c b/Monitor.c index 4adc2375..802a9d98 100644 --- a/Monitor.c +++ b/Monitor.c @@ -213,6 +213,8 @@ int Monitor(struct mddev_dev *devlist, if (mdstat) free_mdstat(mdstat); mdstat = mdstat_read(oneshot?0:1, 0); + if (!mdstat) + mdstat_close(); for (st=statelist; st; st=st->next) if (check_array(st, mdstat, c->test, &info, -- cgit v1.2.3