summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorMarco Peereboom <marco@cvs.openbsd.org>2006-06-09 04:27:11 +0000
committerMarco Peereboom <marco@cvs.openbsd.org>2006-06-09 04:27:11 +0000
commita56dd0d7aefc07006cda8eda1d15c8bf87a7f8a1 (patch)
tree0104b1498e7ff9cb1d2b570276360c7047c67861 /sys/dev
parente4ee18020865be9dbe3ae68ff3d1c45e5ce7076d (diff)
Add percentages for BGI and Rebuild. Example:
# bioctl -h ami0 Volume Status Size Device ami0 0 Rebuild 1000M sd1 RAID5 8% done
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/ic/ami.c49
-rw-r--r--sys/dev/ic/amireg.h7
2 files changed, 53 insertions, 3 deletions
diff --git a/sys/dev/ic/ami.c b/sys/dev/ic/ami.c
index ecff986aa88..b5cf335b72f 100644
--- a/sys/dev/ic/ami.c
+++ b/sys/dev/ic/ami.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ami.c,v 1.164 2006/05/28 09:21:57 uwe Exp $ */
+/* $OpenBSD: ami.c,v 1.165 2006/06/09 04:27:10 marco Exp $ */
/*
* Copyright (c) 2001 Michael Shalayeff
@@ -2079,8 +2079,10 @@ int
ami_ioctl_vol(struct ami_softc *sc, struct bioc_vol *bv)
{
struct ami_big_diskarray *p; /* struct too large for stack */
- int i, s, t;
+ int i, s, t, off;
int error = 0;
+ struct ami_progress perc;
+ u_int8_t bgi[5]; /* 40 LD, 1 bit per LD if BGI is active */
p = malloc(sizeof *p, M_DEVBUF, M_NOWAIT);
if (!p)
@@ -2109,12 +2111,55 @@ ami_ioctl_vol(struct ami_softc *sc, struct bioc_vol *bv)
case AMI_RDRV_OPTIMAL:
bv->bv_status = BIOC_SVONLINE;
+ bv->bv_percent = -1;
+
+ /* get BGI progress here and over-ride status if so */
+ memset(bgi, 0, sizeof bgi);
+ if (ami_mgmt(sc, AMI_MISC, AMI_GET_BGI, 0, 0, sizeof bgi, &bgi))
+ break;
+
+ if ((bgi[i / 8] & (1 << i % 8)) == 0)
+ break;
+
+ if (!ami_mgmt(sc, AMI_GCHECKPROGR, i, 0, 0, sizeof perc, &perc))
+ if (perc.apr_progress < 100) {
+ bv->bv_status = BIOC_SVSCRUB;
+ bv->bv_percent = perc.apr_progress >= 100 ? -1 :
+ perc.apr_progress;
+ }
break;
default:
bv->bv_status = BIOC_SVINVALID;
}
+ /* over-ride status if a pd is in rebuild status for this ld */
+ for (s = 0; s < p->ald[i].adl_spandepth; s++)
+ for (t = 0; t < p->ald[i].adl_nstripes; t++) {
+ off = p->ald[i].asp[s].adv[t].add_channel *
+ AMI_MAX_TARGET +
+ p->ald[i].asp[s].adv[t].add_target;
+
+ if (p->apd[off].adp_ostatus != AMI_PD_RBLD)
+ continue;
+
+ /* get rebuild progress here */
+ bv->bv_status = BIOC_SVREBUILD;
+ if (ami_mgmt(sc, AMI_GRBLDPROGR,
+ p->ald[i].asp[s].adv[t].add_channel,
+ p->ald[i].asp[s].adv[t].add_target, 0,
+ sizeof perc, &perc))
+ bv->bv_percent = -1;
+ else
+ bv->bv_percent = perc.apr_progress >= 100 ? -1 :
+ perc.apr_progress;
+
+ /* XXX fix this, we should either use lowest percentage
+ * of all disks in rebuild state or an average
+ */
+ break;
+ }
+
bv->bv_size = 0;
bv->bv_level = p->ald[i].adl_raidlvl;
bv->bv_nodisk = 0;
diff --git a/sys/dev/ic/amireg.h b/sys/dev/ic/amireg.h
index 67fb53123b0..b248138d0fa 100644
--- a/sys/dev/ic/amireg.h
+++ b/sys/dev/ic/amireg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: amireg.h,v 1.26 2006/04/26 07:53:22 dlg Exp $ */
+/* $OpenBSD: amireg.h,v 1.27 2006/06/09 04:27:10 marco Exp $ */
/*
* Copyright (c) 2000 Michael Shalayeff
@@ -214,6 +214,7 @@
#define AMI_FC_EINQ3_SOLICITED_FULL 0x02
#define AMI_FC_EINQ3_UNSOLICITED 0x03
#define AMI_MISC 0xa4
+#define AMI_GET_BGI 0x13
#define AMI_GET_IO_CMPL 0x5b
#define AMI_SET_IO_CMPL 0x5c
#define AMI_CHFUNC 0xa9
@@ -679,3 +680,7 @@ struct ami_inq_data {
u_int8_t resv2[20];
} __packed;
+
+struct ami_progress {
+ u_int32_t apr_progress;
+} __packed;