diff options
| author | oster <oster@NetBSD.org> | 2004-03-02 15:47:35 +0000 |
|---|---|---|
| committer | oster <oster@NetBSD.org> | 2004-03-02 15:47:35 +0000 |
| commit | d2accf5991c361ba6d4c4b62d5ffb58eb9147c45 (patch) | |
| tree | 1a6e8b9222f822f8fb94f8b3c72b1610d002a1d4 /sys/dev/raidframe | |
| parent | a2989006c90011ad40ea3459ca6fbd2cc437d9e0 (diff) | |
Fix more cases where mutex locks were being held longer than necessary.
[For the record: The mcpair mutex is being used to protect mcpair->flag.
mcpair gets allocated before each call to rf_DispatchDAG(), so there is no
other process/thread that could be mucking with it. It is only used to
detect the completion of a given parity unit, and rf_DispatchDAG()
only uses it to setup the callback argument for rf_MCPairWakeupFunc()
which will be called when the IO completes. The code after the call
to rf_DispatchDAG() sits and waits for a 'wakeup' on mcpair->cond
(rf_MCPairWakeupFunc() does that). If mcpair->flag is 0 when
rf_DispatchDAG() completes, then rf_MCPairWakeupFunc() hasn't been
called yet (the IO hasn't completed). If it is 1, then the IO is
already done, and we continue on our merry way without sleeping.
Thus, we don't need to hold any lock on mcpair while calling
rf_DispatchDAG().]
Diffstat (limited to 'sys/dev/raidframe')
| -rw-r--r-- | sys/dev/raidframe/rf_parityscan.c | 12 | ||||
| -rw-r--r-- | sys/dev/raidframe/rf_raid1.c | 8 |
2 files changed, 16 insertions, 4 deletions
diff --git a/sys/dev/raidframe/rf_parityscan.c b/sys/dev/raidframe/rf_parityscan.c index 557b945e7d7..71c90e7061c 100644 --- a/sys/dev/raidframe/rf_parityscan.c +++ b/sys/dev/raidframe/rf_parityscan.c @@ -1,4 +1,4 @@ -/* $NetBSD: rf_parityscan.c,v 1.24 2004/03/01 23:30:59 oster Exp $ */ +/* $NetBSD: rf_parityscan.c,v 1.25 2004/03/02 15:47:35 oster Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -33,7 +33,7 @@ ****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rf_parityscan.c,v 1.24 2004/03/01 23:30:59 oster Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_parityscan.c,v 1.25 2004/03/02 15:47:35 oster Exp $"); #include <dev/raidframe/raidframevar.h> @@ -249,8 +249,12 @@ rf_VerifyParityBasic(RF_Raid_t *raidPtr, RF_RaidAddr_t raidAddr, #endif RF_LOCK_MUTEX(mcpair->mutex); mcpair->flag = 0; + RF_UNLOCK_MUTEX(mcpair->mutex); + rf_DispatchDAG(rd_dag_h, (void (*) (void *)) rf_MCPairWakeupFunc, (void *) mcpair); + + RF_LOCK_MUTEX(mcpair->mutex); while (!mcpair->flag) RF_WAIT_COND(mcpair->cond, mcpair->mutex); RF_UNLOCK_MUTEX(mcpair->mutex); @@ -291,8 +295,12 @@ rf_VerifyParityBasic(RF_Raid_t *raidPtr, RF_RaidAddr_t raidAddr, #endif RF_LOCK_MUTEX(mcpair->mutex); mcpair->flag = 0; + RF_UNLOCK_MUTEX(mcpair->mutex); + rf_DispatchDAG(wr_dag_h, (void (*) (void *)) rf_MCPairWakeupFunc, (void *) mcpair); + + RF_LOCK_MUTEX(mcpair->mutex); while (!mcpair->flag) RF_WAIT_COND(mcpair->cond, mcpair->mutex); RF_UNLOCK_MUTEX(mcpair->mutex); diff --git a/sys/dev/raidframe/rf_raid1.c b/sys/dev/raidframe/rf_raid1.c index 15aee7ece7b..fe48d1b9cf5 100644 --- a/sys/dev/raidframe/rf_raid1.c +++ b/sys/dev/raidframe/rf_raid1.c @@ -1,4 +1,4 @@ -/* $NetBSD: rf_raid1.c,v 1.19 2004/03/01 23:30:59 oster Exp $ */ +/* $NetBSD: rf_raid1.c,v 1.20 2004/03/02 15:47:35 oster Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -33,7 +33,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rf_raid1.c,v 1.19 2004/03/01 23:30:59 oster Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_raid1.c,v 1.20 2004/03/02 15:47:35 oster Exp $"); #include "rf_raid.h" #include "rf_raid1.h" @@ -492,9 +492,13 @@ rf_VerifyParityRAID1(RF_Raid_t *raidPtr, RF_RaidAddr_t raidAddr, #endif RF_LOCK_MUTEX(mcpair->mutex); mcpair->flag = 0; + RF_UNLOCK_MUTEX(mcpair->mutex); + /* fire off the write DAG */ rf_DispatchDAG(wr_dag_h, (void (*) (void *)) rf_MCPairWakeupFunc, (void *) mcpair); + + RF_LOCK_MUTEX(mcpair->mutex); while (!mcpair->flag) { RF_WAIT_COND(mcpair->cond, mcpair->mutex); } |
