summaryrefslogtreecommitdiff
path: root/sys/dev/raidframe/rf_revent.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/raidframe/rf_revent.c')
-rw-r--r--sys/dev/raidframe/rf_revent.c132
1 files changed, 64 insertions, 68 deletions
diff --git a/sys/dev/raidframe/rf_revent.c b/sys/dev/raidframe/rf_revent.c
index e664e361110..24864943c3f 100644
--- a/sys/dev/raidframe/rf_revent.c
+++ b/sys/dev/raidframe/rf_revent.c
@@ -1,5 +1,6 @@
-/* $OpenBSD: rf_revent.c,v 1.9 2000/08/08 16:07:45 peter Exp $ */
+/* $OpenBSD: rf_revent.c,v 1.10 2002/12/16 07:01:05 tdeval Exp $ */
/* $NetBSD: rf_revent.c,v 1.7 2000/05/30 02:04:29 oster Exp $ */
+
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -26,8 +27,9 @@
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*/
+
/*
- * revent.c -- reconstruction event handling code
+ * revent.c -- Reconstruction event handling code.
*/
#include <sys/errno.h>
@@ -41,39 +43,36 @@
#include "rf_shutdown.h"
static RF_FreeList_t *rf_revent_freelist;
-#define RF_MAX_FREE_REVENT 128
-#define RF_REVENT_INC 8
-#define RF_REVENT_INITIAL 8
+#define RF_MAX_FREE_REVENT 128
+#define RF_REVENT_INC 8
+#define RF_REVENT_INITIAL 8
#include <sys/proc.h>
#include <sys/kernel.h>
-#define DO_WAIT(_rc) \
- tsleep(&(_rc)->eventQueue, PRIBIO, "raidframe eventq", 0)
+#define DO_WAIT(_rc) \
+ tsleep(&(_rc)->eventQueue, PRIBIO, "RAIDframe eventq", 0)
-#define DO_SIGNAL(_rc) wakeup(&(_rc)->eventQueue)
+#define DO_SIGNAL(_rc) wakeup(&(_rc)->eventQueue)
-static void rf_ShutdownReconEvent(void *);
+void rf_ShutdownReconEvent(void *);
-static RF_ReconEvent_t *
-GetReconEventDesc(RF_RowCol_t row, RF_RowCol_t col,
- void *arg, RF_Revent_t type);
+RF_ReconEvent_t *GetReconEventDesc(RF_RowCol_t, RF_RowCol_t, void *,
+ RF_Revent_t);
-static void
-rf_ShutdownReconEvent(ignored)
- void *ignored;
+void
+rf_ShutdownReconEvent(void *ignored)
{
RF_FREELIST_DESTROY(rf_revent_freelist, next, (RF_ReconEvent_t *));
}
-int
-rf_ConfigureReconEvent(listp)
- RF_ShutdownList_t **listp;
+int
+rf_ConfigureReconEvent(RF_ShutdownList_t **listp)
{
- int rc;
+ int rc;
RF_FREELIST_CREATE(rf_revent_freelist, RF_MAX_FREE_REVENT,
RF_REVENT_INC, sizeof(RF_ReconEvent_t));
@@ -81,8 +80,8 @@ rf_ConfigureReconEvent(listp)
return (ENOMEM);
rc = rf_ShutdownCreate(listp, rf_ShutdownReconEvent, NULL);
if (rc) {
- RF_ERRORMSG3("Unable to add to shutdown list file %s line %d rc=%d\n", __FILE__,
- __LINE__, rc);
+ RF_ERRORMSG3("Unable to add to shutdown list file %s line %d"
+ " rc=%d\n", __FILE__, __LINE__, rc);
rf_ShutdownReconEvent(NULL);
return (rc);
}
@@ -91,16 +90,15 @@ rf_ConfigureReconEvent(listp)
return (0);
}
-/* returns the next reconstruction event, blocking the calling thread
- * until one becomes available. will now return null if it is blocked
- * or will return an event if it is not */
+/*
+ * Returns the next reconstruction event, blocking the calling thread
+ * until one becomes available. Will now return null if it is blocked
+ * or will return an event if it is not.
+ */
RF_ReconEvent_t *
-rf_GetNextReconEvent(reconDesc, row, continueFunc, continueArg)
- RF_RaidReconDesc_t *reconDesc;
- RF_RowCol_t row;
- void (*continueFunc) (void *);
- void *continueArg;
+rf_GetNextReconEvent(RF_RaidReconDesc_t *reconDesc, RF_RowCol_t row,
+ void (*continueFunc) (void *), void *continueArg)
{
RF_Raid_t *raidPtr = reconDesc->raidPtr;
RF_ReconCtrl_t *rctrl = raidPtr->reconControl[row];
@@ -108,41 +106,45 @@ rf_GetNextReconEvent(reconDesc, row, continueFunc, continueArg)
RF_ASSERT(row >= 0 && row <= raidPtr->numRow);
RF_LOCK_MUTEX(rctrl->eq_mutex);
- /* q null and count==0 must be equivalent conditions */
+ /* q NULL and count==0 must be equivalent conditions. */
RF_ASSERT((rctrl->eventQueue == NULL) == (rctrl->eq_count == 0));
rctrl->continueFunc = continueFunc;
rctrl->continueArg = continueArg;
- /* mpsleep timeout value: secs = timo_val/hz. 'ticks' here is
- defined as cycle-counter ticks, not softclock ticks */
+ /*
+ * mpsleep timeout value: secs = timo_val/hz. 'ticks' here is
+ * defined as cycle-counter ticks, not softclock ticks.
+ */
-#define MAX_RECON_EXEC_USECS (100 * 1000) /* 100 ms */
-#define RECON_DELAY_MS 25
-#define RECON_TIMO ((RECON_DELAY_MS * hz) / 1000)
+#define MAX_RECON_EXEC_USECS (100 * 1000) /* 100 ms */
+#define RECON_DELAY_MS 25
+#define RECON_TIMO ((RECON_DELAY_MS * hz) / 1000)
- /* we are not pre-emptible in the kernel, but we don't want to run
+ /*
+ * We are not pre-emptible in the kernel, but we don't want to run
* forever. If we run w/o blocking for more than MAX_RECON_EXEC_USECS
- * delay for RECON_DELAY_MS before continuing. this may murder us with
+ * delay for RECON_DELAY_MS before continuing. This may murder us with
* context switches, so we may need to increase both the
- * MAX...TICKS and the RECON_DELAY_MS. */
+ * MAX...TICKS and the RECON_DELAY_MS.
+ */
if (reconDesc->reconExecTimerRunning) {
- int status;
+ int status;
RF_ETIMER_STOP(reconDesc->recon_exec_timer);
RF_ETIMER_EVAL(reconDesc->recon_exec_timer);
- reconDesc->reconExecTicks +=
- RF_ETIMER_VAL_US(reconDesc->recon_exec_timer);
+ reconDesc->reconExecTicks +=
+ RF_ETIMER_VAL_US(reconDesc->recon_exec_timer);
if (reconDesc->reconExecTicks > reconDesc->maxReconExecTicks)
- reconDesc->maxReconExecTicks =
- reconDesc->reconExecTicks;
+ reconDesc->maxReconExecTicks =
+ reconDesc->reconExecTicks;
if (reconDesc->reconExecTicks >= MAX_RECON_EXEC_USECS) {
- /* we've been running too long - sleep */
+ /* We've been running too long - sleep. */
#if RF_RECON_STATS > 0
reconDesc->numReconExecDelays++;
#endif /* RF_RECON_STATS > 0 */
- status = tsleep(&reconDesc->reconExecTicks,
- PRIBIO, "recon delay", RECON_TIMO);
+ status = tsleep(&reconDesc->reconExecTicks,
+ PRIBIO, "recon delay", RECON_TIMO);
RF_ASSERT(status == EWOULDBLOCK);
reconDesc->reconExecTicks = 0;
}
@@ -152,7 +154,7 @@ rf_GetNextReconEvent(reconDesc, row, continueFunc, continueArg)
reconDesc->numReconEventWaits++;
#endif /* RF_RECON_STATS > 0 */
DO_WAIT(rctrl);
- reconDesc->reconExecTicks = 0; /* we've just waited */
+ reconDesc->reconExecTicks = 0; /* We've just waited. */
}
RF_ETIMER_START(reconDesc->recon_exec_timer);
@@ -163,19 +165,16 @@ rf_GetNextReconEvent(reconDesc, row, continueFunc, continueArg)
event->next = NULL;
rctrl->eq_count--;
- /* q null and count==0 must be equivalent conditions */
+ /* q NULL and count==0 must be equivalent conditions. */
RF_ASSERT((rctrl->eventQueue == NULL) == (rctrl->eq_count == 0));
RF_UNLOCK_MUTEX(rctrl->eq_mutex);
return (event);
}
-/* enqueues a reconstruction event on the indicated queue */
-void
-rf_CauseReconEvent(raidPtr, row, col, arg, type)
- RF_Raid_t *raidPtr;
- RF_RowCol_t row;
- RF_RowCol_t col;
- void *arg;
- RF_Revent_t type;
+
+/* Enqueues a reconstruction event on the indicated queue. */
+void
+rf_CauseReconEvent(RF_Raid_t *raidPtr, RF_RowCol_t row, RF_RowCol_t col,
+ void *arg, RF_Revent_t type)
{
RF_ReconCtrl_t *rctrl = raidPtr->reconControl[row];
RF_ReconEvent_t *event = GetReconEventDesc(row, col, arg, type);
@@ -183,9 +182,10 @@ rf_CauseReconEvent(raidPtr, row, col, arg, type)
if (type == RF_REVENT_BUFCLEAR) {
RF_ASSERT(col != rctrl->fcol);
}
- RF_ASSERT(row >= 0 && row <= raidPtr->numRow && col >= 0 && col <= raidPtr->numCol);
+ RF_ASSERT(row >= 0 && row <= raidPtr->numRow && col >= 0 &&
+ col <= raidPtr->numCol);
RF_LOCK_MUTEX(rctrl->eq_mutex);
- /* q null and count==0 must be equivalent conditions */
+ /* q NULL and count==0 must be equivalent conditions. */
RF_ASSERT((rctrl->eventQueue == NULL) == (rctrl->eq_count == 0));
event->next = rctrl->eventQueue;
rctrl->eventQueue = event;
@@ -194,13 +194,10 @@ rf_CauseReconEvent(raidPtr, row, col, arg, type)
DO_SIGNAL(rctrl);
}
-/* allocates and initializes a recon event descriptor */
-static RF_ReconEvent_t *
-GetReconEventDesc(row, col, arg, type)
- RF_RowCol_t row;
- RF_RowCol_t col;
- void *arg;
- RF_Revent_t type;
+
+/* Allocates and initializes a recon event descriptor. */
+RF_ReconEvent_t *
+GetReconEventDesc(RF_RowCol_t row, RF_RowCol_t col, void *arg, RF_Revent_t type)
{
RF_ReconEvent_t *t;
@@ -213,9 +210,8 @@ GetReconEventDesc(row, col, arg, type)
return (t);
}
-void
-rf_FreeReconEventDesc(event)
- RF_ReconEvent_t *event;
+void
+rf_FreeReconEventDesc(RF_ReconEvent_t *event)
{
RF_FREELIST_FREE(rf_revent_freelist, event, next);
}