]> git.ipfire.org Git - thirdparty/mdadm.git/commit
Monitor: release /proc/mdstat fd when no arrays present
authorTomasz Majchrzak <tomasz.majchrzak@intel.com>
Tue, 5 Jul 2016 07:12:51 +0000 (09:12 +0200)
committerJes Sorensen <Jes.Sorensen@redhat.com>
Thu, 21 Jul 2016 15:37:17 +0000 (11:37 -0400)
commit52209d6ee1183581e148791cf6ee4d60a0193b1d
tree518c81be1c4f86cf89c59caa72291bfc5d245412
parentc922221e2522fd24f86e5a0de0bfba60b14353c0
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 <tomasz.majchrzak@intel.com>
Reviewed-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Monitor.c
mdstat.c