• NeilBrown's avatar
    [PATCH] md: make /proc/mdstat pollable · d7603b7e
    NeilBrown authored
    With this patch it is possible to poll /proc/mdstat to detect arrays appearing
    or disappearing, to detect failures, recovery starting, recovery completing,
    and devices being added and removed.
    
    It is similar to the poll-ability of /proc/mounts, though different in that:
    
    We always report that the file is readable (because face it, it is, even if
    only for EOF).
    
    We report POLLPRI when there is a change so that select() can detect
    it as an exceptional event.  Not only are these exceptional events, but
    that is the mechanism that the current 'mdadm' uses to watch for events
    (It also polls after a timeout).
    (We also report POLLERR like /proc/mounts).
    
    Finally, we only reset the per-file event counter when the start of the file
    is read, rather than when poll() returns an event.  This is more robust as it
    means that an fd will continue to report activity to poll/select until the
    program clearly responds to that activity.
    
    md_new_event takes an 'mddev' which isn't currently used, but it will be soon.
    Signed-off-by: default avatarNeil Brown <neilb@suse.de>
    Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
    d7603b7e
md.c 112 KB