From 5cc0208a757d2b37c43398bf68fec145568c1a25 Mon Sep 17 00:00:00 2001 From: Alexander Kabaev Date: Tue, 15 Nov 2005 02:38:35 +0000 Subject: [PATCH] Keep track of volumes in non-optimal state and expose a simple count of volumes that might need administrator attention through device specific sysctl to simplify device monitoring. Submitted by: Deomid Ryabkov --- sys/dev/mpt/mpt.h | 1 + sys/dev/mpt/mpt_raid.c | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/sys/dev/mpt/mpt.h b/sys/dev/mpt/mpt.h index c7a7ed0faab..8baae3a8737 100644 --- a/sys/dev/mpt/mpt.h +++ b/sys/dev/mpt/mpt.h @@ -450,6 +450,7 @@ struct mpt_softc { u_int raid_resync_rate; u_int raid_mwce_setting; u_int raid_queue_depth; + u_int raid_nonopt_volumes; struct proc *raid_thread; struct callout raid_timer; diff --git a/sys/dev/mpt/mpt_raid.c b/sys/dev/mpt/mpt_raid.c index c62b3af1d3d..4395ab30928 100644 --- a/sys/dev/mpt/mpt_raid.c +++ b/sys/dev/mpt/mpt_raid.c @@ -1226,6 +1226,7 @@ mpt_refresh_raid_data(struct mpt_softc *mpt) size_t len; int rv; int i; + u_int nonopt_volumes; if (mpt->ioc_page2 == NULL || mpt->ioc_page3 == NULL) return; @@ -1303,6 +1304,7 @@ mpt_refresh_raid_data(struct mpt_softc *mpt) mpt_vol->flags |= MPT_RVF_ACTIVE; } + nonopt_volumes = 0; for (i = 0; i < mpt->ioc_page2->MaxVolumes; i++) { struct mpt_raid_volume *mpt_vol; uint64_t total; @@ -1329,6 +1331,10 @@ mpt_refresh_raid_data(struct mpt_softc *mpt) mpt_vol->flags |= MPT_RVF_ANNOUNCED; } + if (vol_pg->VolumeStatus.State != + MPI_RAIDVOL0_STATUS_STATE_OPTIMAL) + nonopt_volumes++; + if ((mpt_vol->flags & MPT_RVF_UP2DATE) != 0) continue; @@ -1436,6 +1442,8 @@ mpt_refresh_raid_data(struct mpt_softc *mpt) } mpt_prtc(mpt, " )\n"); } + + mpt->raid_nonopt_volumes = nonopt_volumes; } static void @@ -1671,4 +1679,8 @@ mpt_raid_sysctl_attach(struct mpt_softc *mpt) "vol_resync_rate", CTLTYPE_INT | CTLFLAG_RW, mpt, 0, mpt_raid_sysctl_vol_resync_rate, "I", "volume resync priority (0 == NC, 1 - 255)"); + SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, + "nonoptimal_volumes", CTLFLAG_RD, + &mpt->raid_nonopt_volumes, 0, + "number of nonoptimal volumes"); }