Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/raidframe Use the newly added RF_DEBUG_STRIPELOCK to...



details:   https://anonhg.NetBSD.org/src/rev/3e43a8cef2d1
branches:  trunk
changeset: 536199:3e43a8cef2d1
user:      oster <oster%NetBSD.org@localhost>
date:      Wed Sep 11 02:52:33 2002 +0000

description:
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:

 sys/dev/raidframe/rf_stripelocks.c |  40 +++++++++++++++++++++++++++++++++----
 1 files changed, 35 insertions(+), 5 deletions(-)

diffs (253 lines):

diff -r d985fbf5b370 -r 3e43a8cef2d1 sys/dev/raidframe/rf_stripelocks.c
--- a/sys/dev/raidframe/rf_stripelocks.c        Wed Sep 11 02:51:21 2002 +0000
+++ b/sys/dev/raidframe/rf_stripelocks.c        Wed Sep 11 02:52:33 2002 +0000
@@ -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 @@
 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 @@
 {
        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_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_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 @@
                        FLUSH;
                }
        }
+#endif
        if (stripeID == -1)
                return (0);
        lockReqDesc->next = NULL;       /* just to be sure */
@@ -285,11 +291,13 @@
                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 @@
                                                 * 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 @@
                                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 @@
                                        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_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_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 @@
                        FLUSH;
                }
        }
+#endif
        if (stripeID == -1)
                return;
 
@@ -445,11 +461,13 @@
                                                         * 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 @@
                                                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 @@
                        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 @@
                        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 @@
 
                        /* 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 @@
        /* 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 @@
        RF_FREELIST_FREE(rf_stripelock_freelist, p, next);
 }
 
+#if RF_DEBUG_STRIPELOCK
 static void 
 PrintLockedStripes(lockTable)
        RF_LockTableEntry_t *lockTable;
@@ -680,3 +709,4 @@
                printf("\n");
        RF_UNLOCK_MUTEX(rf_printf_mutex);
 }
+#endif



Home | Main Index | Thread Index | Old Index