From b68ecaf95f541f5543bc75315fe8b3e40a4aa68f Mon Sep 17 00:00:00 2001 From: oster Date: Fri, 23 Jan 2004 01:57:08 +0000 Subject: Always ask for a new RF_StripeLockDesc_t "just in case", and then give it back if we don't need it. If we don't allocate it before we take our lock, LOCKDEBUG (rightfully) complains that we're trying to grab something from the pool with PR_WAITOK. This code (and the PR_WAITOK in particular) really needs to be revisited at some point. --- sys/dev/raidframe/rf_stripelocks.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'sys/dev/raidframe') diff --git a/sys/dev/raidframe/rf_stripelocks.c b/sys/dev/raidframe/rf_stripelocks.c index 4d75b560c9c..64c711ea895 100644 --- a/sys/dev/raidframe/rf_stripelocks.c +++ b/sys/dev/raidframe/rf_stripelocks.c @@ -1,4 +1,4 @@ -/* $NetBSD: rf_stripelocks.c,v 1.21 2003/12/30 21:59:03 oster Exp $ */ +/* $NetBSD: rf_stripelocks.c,v 1.22 2004/01/23 01:57:08 oster Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -57,7 +57,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: rf_stripelocks.c,v 1.21 2003/12/30 21:59:03 oster Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_stripelocks.c,v 1.22 2004/01/23 01:57:08 oster Exp $"); #include @@ -256,6 +256,7 @@ rf_AcquireStripeLock(RF_LockTableEntry_t *lockTable, RF_StripeNum_t stripeID, RF_LockReqDesc_t *lockReqDesc) { RF_StripeLockDesc_t *lockDesc; + RF_StripeLockDesc_t *newlockDesc; RF_LockReqDesc_t *p; #if defined(DEBUG) && (RF_DEBUG_STRIPELOCK > 0) int tid = 0; @@ -281,6 +282,7 @@ rf_AcquireStripeLock(RF_LockTableEntry_t *lockTable, RF_StripeNum_t stripeID, if (stripeID == -1) return (0); lockReqDesc->next = NULL; /* just to be sure */ + newlockDesc = AllocStripeLockDesc(stripeID); RF_LOCK_MUTEX(lockTable[hashval].mutex); for (lockDesc = lockTable[hashval].descList; lockDesc; @@ -291,7 +293,7 @@ rf_AcquireStripeLock(RF_LockTableEntry_t *lockTable, RF_StripeNum_t stripeID, if (!lockDesc) { /* no entry in table => no one reading or writing */ - lockDesc = AllocStripeLockDesc(stripeID); + lockDesc = newlockDesc; lockDesc->next = lockTable[hashval].descList; lockTable[hashval].descList = lockDesc; if (lockReqDesc->type == RF_IO_TYPE_WRITE) @@ -305,6 +307,8 @@ rf_AcquireStripeLock(RF_LockTableEntry_t *lockTable, RF_StripeNum_t stripeID, } #endif } else { + /* we won't be needing newlockDesc after all.. pity.. */ + FreeStripeLockDesc(newlockDesc); if (lockReqDesc->type == RF_IO_TYPE_WRITE) lockDesc->nWriters++; -- cgit