linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ian Pilcher <arequipeno@gmail.com>
To: linux-raid@vger.kernel.org
Subject: Detecting that an array has been stopped
Date: Tue, 24 Sep 2013 15:20:24 -0500	[thread overview]
Message-ID: <l1ss60$fun$1@ger.gmane.org> (raw)

I've successfully gotten my NAS monitoring program to check the status
of my RAID arrays by parsing /proc/mdstat.  (Definitely a PITA, but I
did get to learn about RAID 10 layouts ans POSIX regular expressions.)

I'm now thinking about how to make the program robust in the situation
where the array names (in /proc/mdstat) aren't necessarily stable.  For
example, a couple of arrays might be stopped for some sort of
maintenance activity and "swap" names when they are reassembled.

The obvious answer is to use mdadm to check the UUIDs of the arrays, but
I don't want to do that every time I check the RAID status (currently
every 30 seconds).  So my plan is to only read the UUID of an array
when it first appears in /proc/mdstat (i.e. it wasn't there the last
time I read the file).

This will work as long as the program notices that an array has been
stopped before a (possibly different) array appears with the same name.
So it would be nice if there were a simple way to reliably detect that
a particular array has been stopped -- even if a different array has
since been started with the same name.  It appears that I can do this
pretty easily with sysfs.

From my initial testing, it looks like I can open each array's
array_state file when I first detect the array, and lseek/read will
return ENODEV if the array is ever stopped -- even if the array is
restarted (with the same or a different name) or if a different array is
started with the same name.

It seems almost too easy.

Is there any reason that this approach won't work?

Thanks!

-- 
========================================================================
Ian Pilcher                                         arequipeno@gmail.com
Sometimes there's nothing left to do but crash and burn...or die trying.
========================================================================


             reply	other threads:[~2013-09-24 20:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-24 20:20 Ian Pilcher [this message]
2013-09-27 23:00 ` Detecting that an array has been stopped CoolCold
2013-09-27 23:03   ` CoolCold
2013-10-11  4:48   ` Can running array device name change? - Was: " Ian Pilcher

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='l1ss60$fun$1@ger.gmane.org' \
    --to=arequipeno@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).