NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: kern/39514: ataraid(4): basic bio(4) support
The following reply was made to PR kern/39514; it has been noted by GNATS.
From: Juan RP <xtraeme%gmail.com@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc:
Subject: Re: kern/39514: ataraid(4): basic bio(4) support
Date: Thu, 11 Sep 2008 22:58:41 +0200
Here's the patch against latest HEAD:
Index: sys/dev/ata/ata_raidvar.h
===================================================================
RCS file: /cvsroot/src/sys/dev/ata/ata_raidvar.h,v
retrieving revision 1.8
diff -b -u -p -r1.8 ata_raidvar.h
--- sys/dev/ata/ata_raidvar.h 11 Sep 2008 11:08:50 -0000 1.8
+++ sys/dev/ata/ata_raidvar.h 11 Sep 2008 20:57:03 -0000
@@ -98,6 +98,8 @@ struct ataraid_array_info {
u_int aai_offset; /* component start offset */
u_int aai_reserved; /* component reserved sectors */
+ char aai_name[32]; /* array volume name */
+
struct ataraid_disk_info aai_disks[ATA_RAID_MAX_DISKS];
};
Index: sys/dev/ata/ld_ataraid.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ata/ld_ataraid.c,v
retrieving revision 1.29
diff -b -u -p -r1.29 ld_ataraid.c
--- sys/dev/ata/ld_ataraid.c 9 Sep 2008 12:45:39 -0000 1.29
+++ sys/dev/ata/ld_ataraid.c 11 Sep 2008 20:57:04 -0000
@@ -42,11 +42,14 @@
* controllers we're dealing with (Promise, etc.) only support
* configuration data on the component disks, with the BIOS supporting
* booting from the RAID volumes.
+ *
+ * bio(4) support was written by Juan Romero Pardines
<xtraeme%gmail.com@localhost>.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ld_ataraid.c,v 1.29 2008/09/09 12:45:39 tron Exp
$");
+#include "bio.h"
#include "rnd.h"
#include <sys/param.h>
@@ -66,6 +69,13 @@ __KERNEL_RCSID(0, "$NetBSD: ld_ataraid.c
#if NRND > 0
#include <sys/rnd.h>
#endif
+#if NBIO > 0
+#include <dev/ata/atavar.h>
+#include <dev/ata/atareg.h>
+#include <dev/ata/wdvar.h>
+#include <dev/biovar.h>
+#include <dev/scsipi/scsipiconf.h> /* for scsipi_strvis() */
+#endif
#include <miscfs/specfs/specdev.h>
@@ -92,6 +102,14 @@ static int ld_ataraid_start_span(struct
static int ld_ataraid_start_raid0(struct ld_softc *, struct buf *);
static void ld_ataraid_iodone_raid0(struct buf *);
+#if NBIO > 0
+static int ld_ataraid_bioctl(device_t, u_long, void *);
+static int ld_ataraid_bioinq(struct ld_ataraid_softc *, struct bioc_inq *);
+static int ld_ataraid_biovol(struct ld_ataraid_softc *, struct bioc_vol *);
+static int ld_ataraid_biodisk(struct ld_ataraid_softc *,
+ struct bioc_disk *);
+#endif
+
CFATTACH_DECL_NEW(ld_ataraid, sizeof(struct ld_ataraid_softc),
ld_ataraid_match, ld_ataraid_attach, NULL, NULL);
@@ -233,6 +251,11 @@ ld_ataraid_attach(device_t parent, devic
}
finish:
+#if NBIO > 0
+ if (bio_register(self, ld_ataraid_bioctl) != 0)
+ panic("%s: bioctl registration failed\n",
+ device_xname(ld->sc_dv));
+#endif
ldattach(ld);
}
@@ -541,3 +564,139 @@ ld_ataraid_dump(struct ld_softc *sc, voi
return (EIO);
}
+
+#if NBIO > 0
+static int
+ld_ataraid_bioctl(device_t self, u_long cmd, void *addr)
+{
+ struct ld_ataraid_softc *sc = device_private(self);
+ int error = 0;
+
+ switch (cmd) {
+ case BIOCINQ:
+ error = ld_ataraid_bioinq(sc, (struct bioc_inq *)addr);
+ break;
+ case BIOCVOL:
+ error = ld_ataraid_biovol(sc, (struct bioc_vol *)addr);
+ break;
+ case BIOCDISK:
+ error = ld_ataraid_biodisk(sc, (struct bioc_disk *)addr);
+ break;
+ default:
+ error = ENOTTY;
+ break;
+ }
+
+ return error;
+}
+
+static int
+ld_ataraid_bioinq(struct ld_ataraid_softc *sc, struct bioc_inq *bi)
+{
+ struct ataraid_array_info *aai = sc->sc_aai;
+
+ /* there's always one volume per ld device */
+ bi->bi_novol = 1;
+ bi->bi_nodisk = aai->aai_ndisks;
+
+ return 0;
+}
+
+static int
+ld_ataraid_biovol(struct ld_ataraid_softc *sc, struct bioc_vol *bv)
+{
+ struct ataraid_array_info *aai = sc->sc_aai;
+ struct ld_softc *ld = &sc->sc_ld;
+
+ /* Fill in data for _this_ volume */
+ bv->bv_percent = -1;
+ bv->bv_seconds = 0;
+
+ switch (aai->aai_status) {
+ case AAI_S_READY:
+ bv->bv_status = BIOC_SVONLINE;
+ break;
+ case AAI_S_DEGRADED:
+ bv->bv_status = BIOC_SVDEGRADED;
+ break;
+ }
+
+ bv->bv_size = ld->sc_secsize * ld->sc_secperunit;
+
+ switch (aai->aai_level) {
+ case AAI_L_SPAN:
+ case AAI_L_RAID0:
+ bv->bv_stripe_size = aai->aai_interleave;
+ bv->bv_level = 0;
+ break;
+ case AAI_L_RAID1:
+ bv->bv_stripe_size = 0;
+ bv->bv_level = 1;
+ break;
+ case AAI_L_RAID5:
+ bv->bv_stripe_size = aai->aai_interleave;
+ bv->bv_level = 5;
+ break;
+ }
+
+ bv->bv_nodisk = aai->aai_ndisks;
+ strlcpy(bv->bv_dev, device_xname(ld->sc_dv), sizeof(bv->bv_dev));
+ if (aai->aai_name)
+ strlcpy(bv->bv_vendor, aai->aai_name,
+ sizeof(bv->bv_vendor));
+
+ return 0;
+}
+
+static int
+ld_ataraid_biodisk(struct ld_ataraid_softc *sc, struct bioc_disk *bd)
+{
+ struct ataraid_array_info *aai = sc->sc_aai;
+ struct ataraid_disk_info *adi;
+ struct ld_softc *ld = &sc->sc_ld;
+ struct atabus_softc *atabus;
+ struct wd_softc *wd;
+ char model[81], serial[41], rev[17];
+
+ /* sanity check */
+ if (bd->bd_diskid > aai->aai_ndisks)
+ return EINVAL;
+
+ adi = &aai->aai_disks[bd->bd_diskid];
+ atabus = device_private(device_parent(adi->adi_dev));
+ wd = device_private(adi->adi_dev);
+
+ /* fill in data for _this_ disk */
+ switch (adi->adi_status) {
+ case ADI_S_ONLINE | ADI_S_ASSIGNED:
+ bd->bd_status = BIOC_SDONLINE;
+ break;
+ case ADI_S_SPARE:
+ bd->bd_status = BIOC_SDHOTSPARE;
+ break;
+ default:
+ bd->bd_status = BIOC_SDOFFLINE;
+ break;
+ }
+
+ bd->bd_channel = 0;
+ bd->bd_target = atabus->sc_chan->ch_channel;
+ bd->bd_lun = 0;
+ bd->bd_size = (wd->sc_capacity * ld->sc_secsize) - aai->aai_reserved;
+
+ strlcpy(bd->bd_procdev, device_xname(adi->adi_dev),
+ sizeof(bd->bd_procdev));
+
+ scsipi_strvis(serial, sizeof(serial), wd->sc_params.atap_serial,
+ sizeof(wd->sc_params.atap_serial));
+ scsipi_strvis(model, sizeof(model), wd->sc_params.atap_model,
+ sizeof(wd->sc_params.atap_model));
+ scsipi_strvis(rev, sizeof(rev), wd->sc_params.atap_revision,
+ sizeof(wd->sc_params.atap_revision));
+
+ snprintf(bd->bd_vendor, sizeof(bd->bd_vendor), "%s %s", model, rev);
+ strlcpy(bd->bd_serial, serial, sizeof(bd->bd_serial));
+
+ return 0;
+}
+#endif /* NBIO > 0 */
Index: sys/dev/ata/ata_raid_adaptec.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ata/ata_raid_adaptec.c,v
retrieving revision 1.8
diff -b -u -p -r1.8 ata_raid_adaptec.c
--- sys/dev/ata/ata_raid_adaptec.c 18 Mar 2008 20:46:36 -0000 1.8
+++ sys/dev/ata/ata_raid_adaptec.c 11 Sep 2008 20:57:04 -0000
@@ -160,6 +160,9 @@ ata_raid_read_config_adaptec(struct wd_s
aai->aai_cylinders = aai->aai_capacity / (63 * 255);
aai->aai_offset = 0;
aai->aai_reserved = 17;
+ if (info->configs[0].name)
+ strlcpy(aai->aai_name, info->configs[0].name,
+ sizeof(aai->aai_name));
/* XXX - bogus. RAID1 shouldn't really have an interleave */
if (aai->aai_interleave == 0)
Index: sys/dev/ata/ata_raid_intel.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ata/ata_raid_intel.c,v
retrieving revision 1.1
diff -b -u -p -r1.1 ata_raid_intel.c
--- sys/dev/ata/ata_raid_intel.c 11 Sep 2008 11:08:50 -0000 1.1
+++ sys/dev/ata/ata_raid_intel.c 11 Sep 2008 20:57:04 -0000
@@ -252,6 +252,8 @@ ata_raid_read_config_intel(struct wd_sof
aai->aai_capacity / (aai->aai_heads * aai->aai_sectors);
aai->aai_offset = map->offset;
aai->aai_reserved = 3;
+ if (map->name)
+ strlcpy(aai->aai_name, map->name, sizeof(aai->aai_name));
/* Fill in disk info */
adi = &aai->aai_disks[curdrive];
Index: sys/dev/ata/ata_raid_jmicron.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ata/ata_raid_jmicron.c,v
retrieving revision 1.2
diff -b -u -p -r1.2 ata_raid_jmicron.c
--- sys/dev/ata/ata_raid_jmicron.c 10 Sep 2008 16:59:32 -0000 1.2
+++ sys/dev/ata/ata_raid_jmicron.c 11 Sep 2008 20:57:04 -0000
@@ -240,6 +240,8 @@ ata_raid_read_config_jmicron(struct wd_s
aai->aai_capacity / (aai->aai_heads * aai->aai_sectors);
aai->aai_offset = info->offset * 16;
aai->aai_reserved = 2;
+ if (info->name)
+ strlcpy(aai->aai_name, info->name, sizeof(aai->aai_name));
atabus = device_private(device_parent(sc->sc_dev));
drive = atabus->sc_chan->ch_channel;
Index: share/man/man4/ataraid.4
===================================================================
RCS file: /cvsroot/src/share/man/man4/ataraid.4,v
retrieving revision 1.12
diff -b -u -p -r1.12 ataraid.4
--- share/man/man4/ataraid.4 11 Sep 2008 11:18:11 -0000 1.12
+++ share/man/man4/ataraid.4 11 Sep 2008 20:57:04 -0000
@@ -61,8 +61,14 @@ Promise FastTrak
.It
Via V-RAID (found in many VIA-based motherboards)
.El
+.Pp
+Status of the logical disk as well as the disks associated with it,
+can be viewed through the
+.Xr bioctl 8
+utility.
.Sh SEE ALSO
-.Xr ld 4
+.Xr ld 4 ,
+.Xr bioctl 8
.Sh HISTORY
The
.Nm
Home |
Main Index |
Thread Index |
Old Index