diff options
author | jhb <jhb@FreeBSD.org> | 2007-08-13 18:46:31 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2007-08-13 18:46:31 +0000 |
commit | 47d488244c8d1ac0d8f9233b24cf663131829cc0 (patch) | |
tree | 75d4acb106f3718b75777370d636afa6a0d5d25a /sys | |
parent | 7473c1093a1b04fa2dfcdc5d4f98adf43ef3d315 (diff) | |
download | FreeBSD-src-47d488244c8d1ac0d8f9233b24cf663131829cc0.zip FreeBSD-src-47d488244c8d1ac0d8f9233b24cf663131829cc0.tar.gz |
Expand the data structure returned by the ATA RAID status ioctl to include
detailed status on each of the backing subdisks. This allows userland
to see which subdisks are online, failed, missing, or a hot spare.
MFC after: 1 week
Approved by: re (bmah)
Reviewed by: sos
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/ata/ata-raid.c | 36 | ||||
-rw-r--r-- | sys/sys/ata.h | 18 |
2 files changed, 39 insertions, 15 deletions
diff --git a/sys/dev/ata/ata-raid.c b/sys/dev/ata/ata-raid.c index 4501f5a..2356d23 100644 --- a/sys/dev/ata/ata-raid.c +++ b/sys/dev/ata/ata-raid.c @@ -56,7 +56,7 @@ __FBSDID("$FreeBSD$"); /* prototypes */ static void ata_raid_done(struct ata_request *request); static void ata_raid_config_changed(struct ar_softc *rdp, int writeback); -static int ata_raid_status(struct ata_ioc_raid_config *config); +static int ata_raid_status(struct ata_ioc_raid_status *status); static int ata_raid_create(struct ata_ioc_raid_config *config); static int ata_raid_delete(int array); static int ata_raid_addspare(struct ata_ioc_raid_config *config); @@ -216,13 +216,14 @@ ata_raid_attach(struct ar_softc *rdp, int writeback) static int ata_raid_ioctl(u_long cmd, caddr_t data) { + struct ata_ioc_raid_status *status = (struct ata_ioc_raid_status *)data; struct ata_ioc_raid_config *config = (struct ata_ioc_raid_config *)data; int *lun = (int *)data; int error = EOPNOTSUPP; switch (cmd) { case IOCATARAIDSTATUS: - error = ata_raid_status(config); + error = ata_raid_status(status); break; case IOCATARAIDCREATE: @@ -929,25 +930,32 @@ ata_raid_config_changed(struct ar_softc *rdp, int writeback) } static int -ata_raid_status(struct ata_ioc_raid_config *config) +ata_raid_status(struct ata_ioc_raid_status *status) { struct ar_softc *rdp; int i; - if (!(rdp = ata_raid_arrays[config->lun])) + if (!(rdp = ata_raid_arrays[status->lun])) return ENXIO; - config->type = rdp->type; - config->total_disks = rdp->total_disks; + status->type = rdp->type; + status->total_disks = rdp->total_disks; for (i = 0; i < rdp->total_disks; i++ ) { - if ((rdp->disks[i].flags & AR_DF_PRESENT) && rdp->disks[i].dev) - config->disks[i] = device_get_unit(rdp->disks[i].dev); - else - config->disks[i] = -1; - } - config->interleave = rdp->interleave; - config->status = rdp->status; - config->progress = 100 * rdp->rebuild_lba / rdp->total_sectors; + status->disks[i].state = 0; + if ((rdp->disks[i].flags & AR_DF_PRESENT) && rdp->disks[i].dev) { + status->disks[i].lun = device_get_unit(rdp->disks[i].dev); + if (rdp->disks[i].flags & AR_DF_PRESENT) + status->disks[i].state |= AR_DISK_PRESENT; + if (rdp->disks[i].flags & AR_DF_ONLINE) + status->disks[i].state |= AR_DISK_ONLINE; + if (rdp->disks[i].flags & AR_DF_SPARE) + status->disks[i].state |= AR_DISK_SPARE; + } else + status->disks[i].lun = -1; + } + status->interleave = rdp->interleave; + status->status = rdp->status; + status->progress = 100 * rdp->rebuild_lba / rdp->total_sectors; return 0; } diff --git a/sys/sys/ata.h b/sys/sys/ata.h index 43b8e83..4eab64d 100644 --- a/sys/sys/ata.h +++ b/sys/sys/ata.h @@ -447,10 +447,26 @@ struct ata_ioc_raid_config { int disks[16]; }; +struct ata_ioc_raid_status { + int lun; + int type; + int interleave; + int status; + int progress; + int total_disks; + struct { + int state; +#define AR_DISK_ONLINE 0x01 +#define AR_DISK_PRESENT 0x02 +#define AR_DISK_SPARE 0x04 + int lun; + } disks[16]; +}; + /* ATA RAID ioctl calls */ #define IOCATARAIDCREATE _IOWR('a', 200, struct ata_ioc_raid_config) #define IOCATARAIDDELETE _IOW('a', 201, int) -#define IOCATARAIDSTATUS _IOWR('a', 202, struct ata_ioc_raid_config) +#define IOCATARAIDSTATUS _IOWR('a', 202, struct ata_ioc_raid_status) #define IOCATARAIDADDSPARE _IOW('a', 203, struct ata_ioc_raid_config) #define IOCATARAIDREBUILD _IOW('a', 204, int) |