All of lore.kernel.org
 help / color / mirror / Atom feed
From: NeilBrown <neilb@suse.de>
To: Bill Davidsen <davidsen@tmr.com>
Cc: Linux RAID <linux-raid@vger.kernel.org>
Subject: Re: Catching a RAID error in a process
Date: Thu, 19 Jul 2012 09:00:45 +1000	[thread overview]
Message-ID: <20120719090045.361edaef@notabene.brown> (raw)
In-Reply-To: <50071D3B.3090309@tmr.com>

[-- Attachment #1: Type: text/plain, Size: 1007 bytes --]

On Wed, 18 Jul 2012 16:31:55 -0400 Bill Davidsen <davidsen@tmr.com> 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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

  reply	other threads:[~2012-07-18 23:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-18 20:31 Catching a RAID error in a process Bill Davidsen
2012-07-18 23:00 ` NeilBrown [this message]
2012-07-19 14:40   ` Bill Davidsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120719090045.361edaef@notabene.brown \
    --to=neilb@suse.de \
    --cc=davidsen@tmr.com \
    --cc=linux-raid@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.