diff options
| author | oster <oster@NetBSD.org> | 2002-09-11 02:52:33 +0000 |
|---|---|---|
| committer | oster <oster@NetBSD.org> | 2002-09-11 02:52:33 +0000 |
| commit | 9dfe7eee9111130f6f6c98121a893bc7c379a6a2 (patch) | |
| tree | 9478e140487b63b25d3920ce217286d082803791 /sys/dev/raidframe | |
| parent | fc178c472778d1159b94aa354da8f4bc0ac3fc90 (diff) | |
Use the newly added RF_DEBUG_STRIPELOCK to effectively remove a bunch
of stuff that most of the world will never want to use.
Diffstat (limited to 'sys/dev/raidframe')
| -rw-r--r-- | sys/dev/raidframe/rf_stripelocks.c | 40 |
1 files changed, 35 insertions, 5 deletions
diff --git a/sys/dev/raidframe/rf_stripelocks.c b/sys/dev/raidframe/rf_stripelocks.c index 3f7336131d2..56cecf43a50 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.12 2002/01/19 22:20:48 oster Exp $ */ +/* $NetBSD: rf_stripelocks.c,v 1.13 2002/09/11 02:52:33 oster Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -57,16 +57,16 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rf_stripelocks.c,v 1.12 2002/01/19 22:20:48 oster Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_stripelocks.c,v 1.13 2002/09/11 02:52:33 oster Exp $"); #include <dev/raidframe/raidframevar.h> #include "rf_raid.h" #include "rf_stripelocks.h" #include "rf_alloclist.h" +#include "rf_debugprint.h" #include "rf_general.h" #include "rf_freelist.h" -#include "rf_debugprint.h" #include "rf_driver.h" #include "rf_shutdown.h" @@ -101,7 +101,9 @@ __KERNEL_RCSID(0, "$NetBSD: rf_stripelocks.c,v 1.12 2002/01/19 22:20:48 oster Ex static void AddToWaitersQueue(RF_LockTableEntry_t * lockTable, RF_StripeLockDesc_t * lockDesc, RF_LockReqDesc_t * lockReqDesc); static RF_StripeLockDesc_t *AllocStripeLockDesc(RF_StripeNum_t stripeID); static void FreeStripeLockDesc(RF_StripeLockDesc_t * p); +#if RF_DEBUG_STRIPELOCK static void PrintLockedStripes(RF_LockTableEntry_t * lockTable); +#endif /* determines if two ranges overlap. always yields false if either start value is negative */ #define SINGLE_RANGE_OVERLAP(_strt1, _stop1, _strt2, _stop2) \ @@ -198,9 +200,11 @@ rf_ShutdownStripeLocks(RF_LockTableEntry_t * lockTable) { int i; +#if RF_DEBUG_STRIPELOCK if (rf_stripeLockDebug) { PrintLockedStripes(lockTable); } +#endif for (i = 0; i < rf_lockTableSize; i++) { rf_mutex_destroy(&lockTable[i].mutex); } @@ -248,7 +252,7 @@ rf_AcquireStripeLock( { RF_StripeLockDesc_t *lockDesc; RF_LockReqDesc_t *p; -#ifdef DEBUG +#if defined(DEBUG) && (RF_DEBUG_STRIPELOCK > 0) int tid = 0; #endif int hashval = HASH_STRIPEID(stripeID); @@ -256,6 +260,7 @@ rf_AcquireStripeLock( RF_ASSERT(RF_IO_IS_R_OR_W(lockReqDesc->type)); +#if RF_DEBUG_STRIPELOCK if (rf_stripeLockDebug) { if (stripeID == -1) { Dprintf1("[%d] Lock acquisition supressed (stripeID == -1)\n", tid); @@ -267,6 +272,7 @@ rf_AcquireStripeLock( FLUSH; } } +#endif if (stripeID == -1) return (0); lockReqDesc->next = NULL; /* just to be sure */ @@ -285,11 +291,13 @@ rf_AcquireStripeLock( if (lockReqDesc->type == RF_IO_TYPE_WRITE) lockDesc->nWriters++; lockDesc->granted = lockReqDesc; +#if RF_DEBUG_STRIPELOCK if (rf_stripeLockDebug) { Dprintf7("[%d] no one waiting: lock %ld %c %ld-%ld %ld-%ld granted\n", tid, stripeID, lockReqDesc->type, lockReqDesc->start, lockReqDesc->stop, lockReqDesc->start2, lockReqDesc->stop2); FLUSH; } +#endif } else { if (lockReqDesc->type == RF_IO_TYPE_WRITE) @@ -300,11 +308,13 @@ rf_AcquireStripeLock( * anywhere */ lockReqDesc->next = lockDesc->granted; lockDesc->granted = lockReqDesc; +#if RF_DEBUG_STRIPELOCK if (rf_stripeLockDebug) { Dprintf7("[%d] no writers: lock %ld %c %ld-%ld %ld-%ld granted\n", tid, stripeID, lockReqDesc->type, lockReqDesc->start, lockReqDesc->stop, lockReqDesc->start2, lockReqDesc->stop2); FLUSH; } +#endif } else { /* search the granted & waiting lists for a conflict. @@ -325,13 +335,16 @@ rf_AcquireStripeLock( lockReqDesc->next = lockDesc->granted; /* no conflicts found => * grant lock */ lockDesc->granted = lockReqDesc; +#if RF_DEBUG_STRIPELOCK if (rf_stripeLockDebug) { Dprintf7("[%d] no conflicts: lock %ld %c %ld-%ld %ld-%ld granted\n", tid, stripeID, lockReqDesc->type, lockReqDesc->start, lockReqDesc->stop, lockReqDesc->start2, lockReqDesc->stop2); FLUSH; } +#endif } else { +#if RF_DEBUG_STRIPELOCK if (rf_stripeLockDebug) { Dprintf6("[%d] conflict: lock %ld %c %ld-%ld hashval=%d not granted\n", tid, stripeID, lockReqDesc->type, lockReqDesc->start, lockReqDesc->stop, @@ -339,6 +352,7 @@ rf_AcquireStripeLock( Dprintf3("[%d] lock %ld retcode=%d\n", tid, stripeID, retcode); FLUSH; } +#endif AddToWaitersQueue(lockTable, lockDesc, lockReqDesc); /* conflict => the * current access must * wait */ @@ -358,7 +372,7 @@ rf_ReleaseStripeLock( { RF_StripeLockDesc_t *lockDesc, *ld_t; RF_LockReqDesc_t *lr, *lr_t, *callbacklist, *t; -#ifdef DEBUG +#if defined(DEBUG) && (RF_DEBUG_STRIPELOCK > 0) int tid = 0; #endif int hashval = HASH_STRIPEID(stripeID); @@ -367,6 +381,7 @@ rf_ReleaseStripeLock( RF_ASSERT(RF_IO_IS_R_OR_W(lockReqDesc->type)); +#if RF_DEBUG_STRIPELOCK if (rf_stripeLockDebug) { if (stripeID == -1) { Dprintf1("[%d] Lock release supressed (stripeID == -1)\n", tid); @@ -376,6 +391,7 @@ rf_ReleaseStripeLock( FLUSH; } } +#endif if (stripeID == -1) return; @@ -445,11 +461,13 @@ rf_ReleaseStripeLock( * so that we'll invoke * callback below */ callbacklist = lr; +#if RF_DEBUG_STRIPELOCK if (rf_stripeLockDebug) { Dprintf8("[%d] No writers: granting lock stripe ID %ld, type %c range %ld-%ld %ld-%ld table 0x%lx\n", tid, stripeID, lr->type, lr->start, lr->stop, lr->start2, lr->stop2, (unsigned long) lockTable); FLUSH; } +#endif } lockDesc->waitersT = NULL; /* we've purged the whole * waiters list */ @@ -468,12 +486,14 @@ rf_ReleaseStripeLock( break; } if (!consider_it) { +#if RF_DEBUG_STRIPELOCK if (rf_stripeLockDebug) { Dprintf8("[%d] No overlap: rejecting candidate stripeID %ld, type %c range %ld-%ld %ld-%ld table 0x%lx\n", tid, stripeID, candidate->type, candidate->start, candidate->stop, candidate->start2, candidate->stop2, (unsigned long) lockTable); FLUSH; } +#endif candidate_t = candidate; candidate = candidate->next; continue; @@ -483,12 +503,14 @@ rf_ReleaseStripeLock( release_it = 1; for (predecessor = lockDesc->granted; predecessor; predecessor = predecessor->next) { if (STRIPELOCK_CONFLICT(candidate, predecessor)) { +#if RF_DEBUG_STRIPELOCK if (rf_stripeLockDebug) { Dprintf8("[%d] Conflicts with granted lock: rejecting candidate stripeID %ld, type %c range %ld-%ld %ld-%ld table 0x%lx\n", tid, stripeID, candidate->type, candidate->start, candidate->stop, candidate->start2, candidate->stop2, (unsigned long) lockTable); FLUSH; } +#endif release_it = 0; break; } @@ -499,12 +521,14 @@ rf_ReleaseStripeLock( if (release_it) for (predecessor = lockDesc->waitersH; predecessor != candidate; predecessor = predecessor->next) { if (STRIPELOCK_CONFLICT(candidate, predecessor)) { +#if RF_DEBUG_STRIPELOCK if (rf_stripeLockDebug) { Dprintf8("[%d] Conflicts with waiting lock: rejecting candidate stripeID %ld, type %c range %ld-%ld %ld-%ld table 0x%lx\n", tid, stripeID, candidate->type, candidate->start, candidate->stop, candidate->start2, candidate->stop2, (unsigned long) lockTable); FLUSH; } +#endif release_it = 0; break; } @@ -512,12 +536,14 @@ rf_ReleaseStripeLock( /* release it if indicated */ if (release_it) { +#if RF_DEBUG_STRIPELOCK if (rf_stripeLockDebug) { Dprintf8("[%d] Granting lock to candidate stripeID %ld, type %c range %ld-%ld %ld-%ld table 0x%lx\n", tid, stripeID, candidate->type, candidate->start, candidate->stop, candidate->start2, candidate->stop2, (unsigned long) lockTable); FLUSH; } +#endif if (candidate_t) { candidate_t->next = candidate->next; if (lockDesc->waitersT == candidate) @@ -556,10 +582,12 @@ rf_ReleaseStripeLock( /* delete the descriptor if no one is waiting or active */ if (!lockDesc->granted && !lockDesc->waitersH) { RF_ASSERT(lockDesc->nWriters == 0); +#if RF_DEBUG_STRIPELOCK if (rf_stripeLockDebug) { Dprintf3("[%d] Last lock released (table 0x%lx): deleting desc for stripeID %ld\n", tid, (unsigned long) lockTable, stripeID); FLUSH; } +#endif if (ld_t) ld_t->next = lockDesc->next; else { @@ -617,6 +645,7 @@ FreeStripeLockDesc(RF_StripeLockDesc_t * p) RF_FREELIST_FREE(rf_stripelock_freelist, p, next); } +#if RF_DEBUG_STRIPELOCK static void PrintLockedStripes(lockTable) RF_LockTableEntry_t *lockTable; @@ -680,3 +709,4 @@ PrintLockedStripes(lockTable) printf("\n"); RF_UNLOCK_MUTEX(rf_printf_mutex); } +#endif |
