Subject: Re: port bio(4) and bioctl(8) from openbsd ?
To: None <tech-kern@NetBSD.org>
From: Manuel Bouyer <bouyer@antioche.eu.org>
List: tech-kern
Date: 04/09/2007 00:06:24
On Sat, Apr 07, 2007 at 07:07:19PM +0200, Manuel Bouyer wrote:
> Hi,
> do we want to port the bio(4) interface and associated bioctl(8) tool
> from openbsd ? Basically it allows control of hardware RAID controllers in a
> generic way (get states, add hot-spare, start rebuilds, etc ...).
> On OpenBSD it's currently supported on ami(4), arc(4), ciss(4), mfi(4).
> I won't go into the softraid stuff, at last not yet.
> Man pages:
> http://www.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sbin/bioctl/bioctl.8?rev=1.43&content-type=text/plain
> http://www.openbsd.org/cgi-bin/cvsweb/~checkout~/src/share/man/man4/bio.4?rev=1.19&content-type=text/plain
> 
> In kernel, there's a pseudo-device (bio) to which RAID controllers registers
> (note that we can use the controllers without bio(4) in the kernel).
> This pseudo-device keeps a list of raid controllers, and dispatch the
> IOCTLs. This avoids having one major device per controller driver type.
> 
> OpenBSD has added sensors for the drives: SENSOR_DRIVE, with the states:
> #define SENSOR_DRIVE_EMPTY    1
> #define SENSOR_DRIVE_READY    2
> #define SENSOR_DRIVE_POWERUP  3
> #define SENSOR_DRIVE_ONLINE   4
> #define SENSOR_DRIVE_IDLE     5
> #define SENSOR_DRIVE_ACTIVE   6
> #define SENSOR_DRIVE_REBUILD  7
> #define SENSOR_DRIVE_POWERDOWN        8
> #define SENSOR_DRIVE_FAIL     9
> #define SENSOR_DRIVE_PFAIL    10
> The benefit of this is that we could get notification in real time
> instead of polling though bioctl.
> 
> I want this for mfi(4), for which I have no alternatives to get RAID status
> (if a drive fail you don't know, unless you go in front of the box and look
> at the LEDs). I will also add support to amr(4) as I have the hardware
> for this.

OK, attached is my first cut at getting this working. I've not looked at
kauth at all for this yet.
Here's what it can do so far:
cuba# bioctl -h mfi0
Volume  Status               Size Device  
 mfi0 0 Online                74G mfi0    RAID1
      0 Online                75G 1:0.0   noencl <ATA     WDC WD800JD-75MS1E04>
      1 Online                75G 1:1.0   noencl <ATA     WDC WD800JD-75MS1E04>
 mfi0 1 Online               697G mfi0    RAID5
      0 Online               233G 1:3.0   noencl <ATA     WDC WD2500JS-75N2E04>
      1 Online               233G 1:2.0   noencl <ATA     WDC WD2500JS-75N2E04>
      2 Online               233G 1:4.0   noencl <ATA     WDC WD2500JS-75N2E04>
      3 Online               233G 1:5.0   noencl <ATA     WDC WD2500JS-75N2E04>
cuba# envstat -r
                                mfi0:0: drive online
                                mfi0:1: drive online
(I still need to update the envsys man page)
I still have to check that drive failures are properly reported, but this
won't be before Tuesday, when I'll have physical access to the machine.
I will also add support for amr(4) as I have hardware to test this.

I've left the softraid stuff in bioctl and bio, with a note in bioctl(8)
that softraid isn't supported yet. I expect this would be usefull for
some adapters such as the promise "RAID" controllers. Would is be better
to comment it out completely for now ?

The diff is at ftp://asim.lip6.fr/outgoing/bouyer/bio.diff

-- 
Manuel Bouyer <bouyer@antioche.eu.org>
     NetBSD: 26 ans d'experience feront toujours la difference
--