linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Detecting that an array has been stopped
@ 2013-09-24 20:20 Ian Pilcher
  2013-09-27 23:00 ` CoolCold
  0 siblings, 1 reply; 4+ messages in thread
From: Ian Pilcher @ 2013-09-24 20:20 UTC (permalink / raw)
  To: linux-raid

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.
========================================================================


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-10-11  4:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-24 20:20 Detecting that an array has been stopped Ian Pilcher
2013-09-27 23:00 ` CoolCold
2013-09-27 23:03   ` CoolCold
2013-10-11  4:48   ` Can running array device name change? - Was: " Ian Pilcher

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).