re-apply the reverted previous, after fixing the missed wakeup:

convert eq_mutex to a kmutex/cv.
convert ltsleep() used for plain timeout into kpause().
This commit is contained in:
mrg 2011-05-02 01:07:24 +00:00
parent a0ccbf8109
commit 70f1be105d
4 changed files with 38 additions and 33 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: rf_reconstruct.h,v 1.26 2011/05/02 00:39:37 mrg Exp $ */
/* $NetBSD: rf_reconstruct.h,v 1.27 2011/05/02 01:07:24 mrg Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@ -137,8 +137,8 @@ struct RF_ReconCtrl_s {
/* reconstruction event queue */
RF_ReconEvent_t *eventQueue; /* queue of pending reconstruction
* events */
RF_DECLARE_MUTEX(eq_mutex) /* mutex for locking event
* queue */
rf_declare_mutex2(eq_mutex); /* mutex for locking event */
rf_declare_cond2(eq_cv); /* queue */
int eq_count; /* debug only */
/* reconstruction buffer management */

View File

@ -1,4 +1,4 @@
/* $NetBSD: rf_reconutil.c,v 1.31 2011/05/02 00:39:37 mrg Exp $ */
/* $NetBSD: rf_reconutil.c,v 1.32 2011/05/02 01:07:24 mrg Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@ -31,7 +31,7 @@
********************************************/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: rf_reconutil.c,v 1.31 2011/05/02 00:39:37 mrg Exp $");
__KERNEL_RCSID(0, "$NetBSD: rf_reconutil.c,v 1.32 2011/05/02 01:07:24 mrg Exp $");
#include <dev/raidframe/raidframevar.h>
@ -125,7 +125,8 @@ rf_MakeReconControl(RF_RaidReconDesc_t *reconDesc,
}
/* initialize the event queue */
rf_mutex_init(&reconCtrlPtr->eq_mutex);
rf_init_mutex2(reconCtrlPtr->eq_mutex, IPL_VM);
rf_init_cond2(reconCtrlPtr->eq_cv, "rfevq");
reconCtrlPtr->eventQueue = NULL;
reconCtrlPtr->eq_count = 0;
@ -171,6 +172,9 @@ rf_FreeReconControl(RF_Raid_t *raidPtr)
t = reconCtrlPtr->floatingRbufs;
}
rf_destroy_mutex2(reconCtrlPtr->eq_mutex);
rf_destroy_cond2(reconCtrlPtr->eq_cv);
rf_FreeReconMap(reconCtrlPtr->reconMap);
rf_FreeParityStripeStatusTable(raidPtr, reconCtrlPtr->pssTable);
RF_Free(reconCtrlPtr->perDiskInfo,

View File

@ -1,4 +1,4 @@
/* $NetBSD: rf_revent.c,v 1.27 2011/05/02 00:39:37 mrg Exp $ */
/* $NetBSD: rf_revent.c,v 1.28 2011/05/02 01:07:24 mrg Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: rf_revent.c,v 1.27 2011/05/02 00:39:37 mrg Exp $");
__KERNEL_RCSID(0, "$NetBSD: rf_revent.c,v 1.28 2011/05/02 01:07:24 mrg Exp $");
#include <sys/errno.h>
@ -81,7 +81,7 @@ rf_GetNextReconEvent(RF_RaidReconDesc_t *reconDesc)
RF_ReconEvent_t *event;
int stall_count;
RF_LOCK_MUTEX(rctrl->eq_mutex);
rf_lock_mutex2(rctrl->eq_mutex);
/* q null and count==0 must be equivalent conditions */
RF_ASSERT((rctrl->eventQueue == NULL) == (rctrl->eq_count == 0));
@ -114,9 +114,8 @@ rf_GetNextReconEvent(RF_RaidReconDesc_t *reconDesc)
reconDesc->numReconExecDelays++;
#endif /* RF_RECON_STATS > 0 */
status = ltsleep(&reconDesc->reconExecTicks, PRIBIO,
"recon delay", RECON_TIMO,
&rctrl->eq_mutex);
status = rf_sleep("rfrecond", RECON_TIMO,
rctrl->eq_mutex);
RF_ASSERT(status == EWOULDBLOCK);
reconDesc->reconExecTicks = 0;
}
@ -128,8 +127,8 @@ rf_GetNextReconEvent(RF_RaidReconDesc_t *reconDesc)
reconDesc->numReconEventWaits++;
#endif /* RF_RECON_STATS > 0 */
ltsleep(&(rctrl)->eventQueue, PRIBIO, "raidframe eventq",
RF_EVENTQ_WAIT, &((rctrl)->eq_mutex));
rf_timedwait_cond2(rctrl->eq_cv, rctrl->eq_mutex,
RF_EVENTQ_WAIT);
stall_count++;
@ -155,7 +154,7 @@ rf_GetNextReconEvent(RF_RaidReconDesc_t *reconDesc)
/* q null and count==0 must be equivalent conditions */
RF_ASSERT((rctrl->eventQueue == NULL) == (rctrl->eq_count == 0));
RF_UNLOCK_MUTEX(rctrl->eq_mutex);
rf_unlock_mutex2(rctrl->eq_mutex);
return (event);
}
/* enqueues a reconstruction event on the indicated queue */
@ -170,15 +169,14 @@ rf_CauseReconEvent(RF_Raid_t *raidPtr, RF_RowCol_t col, void *arg,
RF_ASSERT(col != rctrl->fcol);
}
RF_ASSERT(col >= 0 && col <= raidPtr->numCol);
RF_LOCK_MUTEX(rctrl->eq_mutex);
rf_lock_mutex2(rctrl->eq_mutex);
/* 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;
rctrl->eq_count++;
RF_UNLOCK_MUTEX(rctrl->eq_mutex);
wakeup(&(rctrl)->eventQueue);
rf_broadcast_cond2(rctrl->eq_cv);
rf_unlock_mutex2(rctrl->eq_mutex);
}
/* allocates and initializes a recon event descriptor */
static RF_ReconEvent_t *
@ -206,7 +204,7 @@ rf_DrainReconEventQueue(RF_RaidReconDesc_t *reconDesc)
RF_ReconCtrl_t *rctrl = reconDesc->raidPtr->reconControl;
RF_ReconEvent_t *event;
RF_LOCK_MUTEX(rctrl->eq_mutex);
rf_lock_mutex2(rctrl->eq_mutex);
while (rctrl->eventQueue!=NULL) {
event = rctrl->eventQueue;
@ -216,7 +214,7 @@ rf_DrainReconEventQueue(RF_RaidReconDesc_t *reconDesc)
/* dump it */
rf_FreeReconEventDesc(event);
}
RF_UNLOCK_MUTEX(rctrl->eq_mutex);
rf_unlock_mutex2(rctrl->eq_mutex);
}
void

View File

@ -1,4 +1,4 @@
/* $NetBSD: rf_threadstuff.h,v 1.28 2011/05/02 00:39:37 mrg Exp $ */
/* $NetBSD: rf_threadstuff.h,v 1.29 2011/05/02 01:07:24 mrg Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@ -75,21 +75,24 @@ typedef void *RF_ThreadArg_t;
/* Modern mutex */
/* Note that rf_declare_{mutex,cond}2() do _NOT_ append the ; */
#define rf_declare_mutex2(_m_) kmutex_t _m_
#define rf_declare_cond2(_c_) kcondvar_t _c_
#define rf_declare_mutex2(_m_) kmutex_t _m_
#define rf_declare_cond2(_c_) kcondvar_t _c_
#define rf_lock_mutex2(_m_) mutex_enter(&(_m_))
#define rf_unlock_mutex2(_m_) mutex_exit(&(_m_))
#define rf_lock_mutex2(_m_) mutex_enter(&(_m_))
#define rf_unlock_mutex2(_m_) mutex_exit(&(_m_))
#define rf_init_mutex2(_m_, _p_) mutex_init(&(_m_), MUTEX_DEFAULT, (_p_))
#define rf_destroy_mutex2(_m_) mutex_destroy(&(_m_))
#define rf_init_mutex2(_m_, _p_) mutex_init(&(_m_), MUTEX_DEFAULT, (_p_))
#define rf_destroy_mutex2(_m_) mutex_destroy(&(_m_))
#define rf_init_cond2(_c_, _w_) cv_init(&(_c_), (_w_))
#define rf_destroy_cond2(_c_) cv_destroy(&(_c_))
#define rf_init_cond2(_c_, _w_) cv_init(&(_c_), (_w_))
#define rf_destroy_cond2(_c_) cv_destroy(&(_c_))
#define rf_wait_cond2(_c_,_m_) cv_wait(&(_c_), &(_m_))
#define rf_timedwait_cond2(_c_,_m_,_t_) cv_timedwait(&(_c_), &(_m_), (_t_))
#define rf_signal_cond2(_c_) cv_signal(&(_c_))
#define rf_broadcast_cond2(_c_) cv_broadcast(&(_c_))
#define rf_wait_cond2(_c_,_m_) cv_wait(&(_c_), &(_m_))
#define rf_signal_cond2(_c_) cv_signal(&(_c_))
#define rf_broadcast_cond2(_c_) cv_broadcast(&(_c_))
#define rf_sleep(_w_,_t_,_m_) kpause((_w_), false, (_t_), &(_m_))
/*
* In NetBSD, kernel threads are simply processes which share several