Re: Catching a RAID error in a process
From: NeilBrown <hidden>
Date: 2012-07-18 23:00:45
Attachments
- signature.asc [application/pgp-signature] 828 bytes
From: NeilBrown <hidden>
Date: 2012-07-18 23:00:45
On Wed, 18 Jul 2012 16:31:55 -0400 Bill Davidsen [off-list ref] wrote:
Can someone point me to the docs to have a process run or notified when a RAID event triggers? I've been playing with some recovery ideas, but polling states and status is not the proper way to do this, and I want to test with a user program before I start putting patches in the kernel.
I guess you don't mean "run mdadm --monitor --program /bin/myscript" ??
Do you want "just any event" or some specific set of events?
See mdstat_wait in mdstat.c in the mdadm sources. It waits for any event by
using 'select' on /proc/mdstat.
void mdstat_wait(int seconds)
{
fd_set fds;
struct timeval tm;
int maxfd = 0;
FD_ZERO(&fds);
if (mdstat_fd >= 0) {
FD_SET(mdstat_fd, &fds);
maxfd = mdstat_fd;
}
tm.tv_sec = seconds;
tm.tv_usec = 0;
select(maxfd + 1, NULL, NULL, &fds, &tm);
}
mdstat_fd is a global variable
mdstat_fd = open("/proc/mdstat", O_RDONLY);
NeilBrown