summaryrefslogtreecommitdiff
path: root/sys/dev/raidframe
diff options
context:
space:
mode:
authoroster <oster@NetBSD.org>2003-12-29 03:33:47 +0000
committeroster <oster@NetBSD.org>2003-12-29 03:33:47 +0000
commitee19b085aa7404f91d9876986c2070b47e6f1399 (patch)
treea9c852447a8a7f093056262151734dfea2b0b4d4 /sys/dev/raidframe
parentb852db83fb14fe9a32a03051ea869b353a2d8534 (diff)
- first kick at a major reworking of RAIDframe's memory allocation code:
- all freelists converted to pools - initialization of structure members in certain cases where code was relying on specific allocation and usage properties to keep structures in a "known state" (that doesn't work with pools!). - make most pool_get() be "PR_WAITOK" until they can be analyzed further, and/or have proper error handling added. - all RF_Mallocs zero the space returned, so there is no difference between RF_Calloc and RF_Malloc. In fact, all the RF_Calloc()'s do is tend to do is get things horribly confused. Make RF_Malloc() the "general memory allocator", with RF_MallocAndAdd() the "general memory allocator with allocation list". - some of these RF_Malloc's et al. are destined to disappear. - remove rf_rdp_freelist entirely (it's not used anywhere!) - remove: #include "rf_freelist.h" - to the files that were relying on the above, add: #include "rf_general.h" - add: #include "rf_debugMem.h" to rf_shutdown.h to make it happy about the loss of: #include "rf_freelist.h". This shrinks an i386 GENERIC kernel by approx 5K. RAIDframe now weighs in at about 162K on i386.
Diffstat (limited to 'sys/dev/raidframe')
-rw-r--r--sys/dev/raidframe/rf_aselect.c16
-rw-r--r--sys/dev/raidframe/rf_callback.c9
-rw-r--r--sys/dev/raidframe/rf_dagdegrd.c17
-rw-r--r--sys/dev/raidframe/rf_dagdegwr.c17
-rw-r--r--sys/dev/raidframe/rf_dagffrd.c8
-rw-r--r--sys/dev/raidframe/rf_dagffwr.c34
-rw-r--r--sys/dev/raidframe/rf_dagutils.c39
-rw-r--r--sys/dev/raidframe/rf_debugMem.h13
-rw-r--r--sys/dev/raidframe/rf_diskqueue.c35
-rw-r--r--sys/dev/raidframe/rf_disks.c11
-rw-r--r--sys/dev/raidframe/rf_driver.c47
-rw-r--r--sys/dev/raidframe/rf_evenodd.c10
-rw-r--r--sys/dev/raidframe/rf_fifo.c7
-rw-r--r--sys/dev/raidframe/rf_freelist.h115
-rw-r--r--sys/dev/raidframe/rf_map.c112
-rw-r--r--sys/dev/raidframe/rf_mcpair.c33
-rw-r--r--sys/dev/raidframe/rf_netbsdkintf.c8
-rw-r--r--sys/dev/raidframe/rf_paritylogging.c8
-rw-r--r--sys/dev/raidframe/rf_parityloggingdags.c16
-rw-r--r--sys/dev/raidframe/rf_parityscan.c10
-rw-r--r--sys/dev/raidframe/rf_psstatus.c13
-rw-r--r--sys/dev/raidframe/rf_reconmap.c6
-rw-r--r--sys/dev/raidframe/rf_reconstruct.c30
-rw-r--r--sys/dev/raidframe/rf_reconutil.c8
-rw-r--r--sys/dev/raidframe/rf_revent.c26
-rw-r--r--sys/dev/raidframe/rf_shutdown.c6
-rw-r--r--sys/dev/raidframe/rf_sstf.c10
-rw-r--r--sys/dev/raidframe/rf_stripelocks.c32
28 files changed, 305 insertions, 391 deletions
diff --git a/sys/dev/raidframe/rf_aselect.c b/sys/dev/raidframe/rf_aselect.c
index d4d1e984be0..dd1264c9137 100644
--- a/sys/dev/raidframe/rf_aselect.c
+++ b/sys/dev/raidframe/rf_aselect.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_aselect.c,v 1.8 2003/07/01 22:05:39 oster Exp $ */
+/* $NetBSD: rf_aselect.c,v 1.9 2003/12/29 03:33:47 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -33,7 +33,7 @@
*****************************************************************************/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_aselect.c,v 1.8 2003/07/01 22:05:39 oster Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_aselect.c,v 1.9 2003/12/29 03:33:47 oster Exp $");
#include <dev/raidframe/raidframevar.h>
@@ -154,7 +154,7 @@ rf_SelectAlgorithm(desc, flags)
if (asm_h->numStripes <= MAXNSTRIPES)
stripeFuncs = normalStripeFuncs;
else
- RF_Calloc(stripeFuncs, asm_h->numStripes, sizeof(RF_VoidFuncPtr), (RF_VoidFuncPtr *));
+ RF_Malloc(stripeFuncs, asm_h->numStripes * sizeof(RF_VoidFuncPtr), (RF_VoidFuncPtr *));
/* walk through the asm list once collecting information */
/* attempt to find a single creation function for each stripe */
@@ -174,12 +174,12 @@ rf_SelectAlgorithm(desc, flags)
RF_Malloc(asmh_u, sizeof(RF_AccessStripeMapHeader_t **) * asm_h->numStripes, (RF_AccessStripeMapHeader_t ***));
/* create an array of ptrs to arrays of
* stripeFuncs */
- RF_Calloc(stripeUnitFuncs, asm_h->numStripes, sizeof(RF_VoidFuncPtr), (RF_VoidFuncPtr **));
+ RF_Malloc(stripeUnitFuncs, asm_h->numStripes * sizeof(RF_VoidFuncPtr), (RF_VoidFuncPtr **));
}
/* create an array of creation funcs (called
* stripeFuncs) for this stripe */
numStripeUnits = asm_p->numStripeUnitsAccessed;
- RF_Calloc(stripeUnitFuncs[numStripesBailed], numStripeUnits, sizeof(RF_VoidFuncPtr), (RF_VoidFuncPtr *));
+ RF_Malloc(stripeUnitFuncs[numStripesBailed], numStripeUnits * sizeof(RF_VoidFuncPtr), (RF_VoidFuncPtr *));
RF_Malloc(asmh_u[numStripesBailed], numStripeUnits * sizeof(RF_AccessStripeMapHeader_t *), (RF_AccessStripeMapHeader_t **));
/* lookup array of stripeUnitFuncs for this stripe */
@@ -209,14 +209,14 @@ rf_SelectAlgorithm(desc, flags)
RF_Malloc(asmh_b, sizeof(RF_AccessStripeMapHeader_t **) * asm_h->numStripes * raidPtr->Layout.numDataCol, (RF_AccessStripeMapHeader_t ***));
/* create an array of ptrs to
* arrays of blockFuncs */
- RF_Calloc(blockFuncs, asm_h->numStripes * raidPtr->Layout.numDataCol, sizeof(RF_VoidFuncPtr), (RF_VoidFuncPtr **));
+ RF_Malloc(blockFuncs, asm_h->numStripes * raidPtr->Layout.numDataCol * sizeof(RF_VoidFuncPtr), (RF_VoidFuncPtr **));
}
/* create an array of creation funcs
* (called blockFuncs) for this stripe
* unit */
numBlocks = physPtr->numSector;
numBlockDags += numBlocks;
- RF_Calloc(blockFuncs[numStripeUnitsBailed], numBlocks, sizeof(RF_VoidFuncPtr), (RF_VoidFuncPtr *));
+ RF_Malloc(blockFuncs[numStripeUnitsBailed], numBlocks * sizeof(RF_VoidFuncPtr), (RF_VoidFuncPtr *));
RF_Malloc(asmh_b[numStripeUnitsBailed], numBlocks * sizeof(RF_AccessStripeMapHeader_t *), (RF_AccessStripeMapHeader_t **));
/* lookup array of blockFuncs for this
@@ -277,7 +277,7 @@ rf_SelectAlgorithm(desc, flags)
stripeUnitNum = 0;
/* create an array of dagLists and fill them in */
- RF_CallocAndAdd(desc->dagArray, desc->numStripes, sizeof(RF_DagList_t), (RF_DagList_t *), desc->cleanupList);
+ RF_MallocAndAdd(desc->dagArray, desc->numStripes * sizeof(RF_DagList_t), (RF_DagList_t *), desc->cleanupList);
for (i = 0, asm_p = asmap; asm_p; asm_p = asm_p->next, i++) {
/* grab dag header for this stripe */
diff --git a/sys/dev/raidframe/rf_callback.c b/sys/dev/raidframe/rf_callback.c
index c2f74a64d66..7febce4799a 100644
--- a/sys/dev/raidframe/rf_callback.c
+++ b/sys/dev/raidframe/rf_callback.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_callback.c,v 1.10 2003/12/21 15:56:20 oster Exp $ */
+/* $NetBSD: rf_callback.c,v 1.11 2003/12/29 03:33:47 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -34,7 +34,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_callback.c,v 1.10 2003/12/21 15:56:20 oster Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_callback.c,v 1.11 2003/12/29 03:33:47 oster Exp $");
#include <dev/raidframe/raidframevar.h>
#include <sys/pool.h>
@@ -43,11 +43,10 @@ __KERNEL_RCSID(0, "$NetBSD: rf_callback.c,v 1.10 2003/12/21 15:56:20 oster Exp $
#include "rf_threadstuff.h"
#include "rf_callback.h"
#include "rf_debugMem.h"
-#include "rf_freelist.h"
+#include "rf_general.h"
#include "rf_shutdown.h"
static struct pool rf_callback_pool;
-
#define RF_MAX_FREE_CALLBACK 64
#define RF_CALLBACK_INC 4
#define RF_CALLBACK_INITIAL 32
@@ -85,7 +84,7 @@ rf_AllocCallbackDesc()
{
RF_CallbackDesc_t *p;
- p = pool_get(&rf_callback_pool, PR_NOWAIT);
+ p = pool_get(&rf_callback_pool, PR_WAITOK);
return (p);
}
diff --git a/sys/dev/raidframe/rf_dagdegrd.c b/sys/dev/raidframe/rf_dagdegrd.c
index e7d67b074a8..c0cd8e4f50e 100644
--- a/sys/dev/raidframe/rf_dagdegrd.c
+++ b/sys/dev/raidframe/rf_dagdegrd.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_dagdegrd.c,v 1.14 2003/12/29 02:38:17 oster Exp $ */
+/* $NetBSD: rf_dagdegrd.c,v 1.15 2003/12/29 03:33:47 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_dagdegrd.c,v 1.14 2003/12/29 02:38:17 oster Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_dagdegrd.c,v 1.15 2003/12/29 03:33:47 oster Exp $");
#include <dev/raidframe/raidframevar.h>
@@ -139,7 +139,7 @@ rf_CreateRaidOneDegradedReadDAG(
useMirror = RF_TRUE;
/* total number of nodes = 1 + (block + commit + terminator) */
- RF_CallocAndAdd(nodes, 4, sizeof(RF_DagNode_t), (RF_DagNode_t *), allocList);
+ RF_MallocAndAdd(nodes, 4 * sizeof(RF_DagNode_t), (RF_DagNode_t *), allocList);
i = 0;
rdNode = &nodes[i];
i++;
@@ -293,7 +293,7 @@ rf_CreateDegradedReadDAG(
*/
/* overlappingPDAs array must be zero'd */
- RF_Calloc(overlappingPDAs, asmap->numStripeUnitsAccessed, sizeof(char), (char *));
+ RF_Malloc(overlappingPDAs, asmap->numStripeUnitsAccessed * sizeof(char), (char *));
rf_GenerateFailedAccessASMs(raidPtr, asmap, failedPDA, dag_h, new_asm_h, &nXorBufs,
&rpBuf, overlappingPDAs, allocList);
@@ -307,7 +307,7 @@ rf_CreateDegradedReadDAG(
((new_asm_h[1]) ? new_asm_h[1]->stripeMap->numStripeUnitsAccessed : 0);
nNodes = 5 + nRudNodes + nRrdNodes; /* lock, unlock, xor, Rp, Rud,
* Rrd */
- RF_CallocAndAdd(nodes, nNodes, sizeof(RF_DagNode_t), (RF_DagNode_t *),
+ RF_MallocAndAdd(nodes, nNodes * sizeof(RF_DagNode_t), (RF_DagNode_t *),
allocList);
i = 0;
blockNode = &nodes[i];
@@ -560,7 +560,7 @@ rf_CreateRaidCDegradedReadDAG(
useMirror = RF_TRUE;
/* total number of nodes = 1 + (block + commit + terminator) */
- RF_CallocAndAdd(nodes, 4, sizeof(RF_DagNode_t), (RF_DagNode_t *), allocList);
+ RF_MallocAndAdd(nodes, 4 * sizeof(RF_DagNode_t), (RF_DagNode_t *), allocList);
i = 0;
rdNode = &nodes[i];
i++;
@@ -778,7 +778,8 @@ rf_DD_GenerateFailedAccessASMs(
/* allocate up our list of pda's */
- RF_CallocAndAdd(pda_p, napdas, sizeof(RF_PhysDiskAddr_t), (RF_PhysDiskAddr_t *), allocList);
+ RF_MallocAndAdd(pda_p, napdas * sizeof(RF_PhysDiskAddr_t),
+ (RF_PhysDiskAddr_t *), allocList);
*pdap = pda_p;
/* linkem together */
@@ -1017,7 +1018,7 @@ rf_DoubleDegRead(
nReadNodes = nRrdNodes + nRudNodes + 2 * nPQNodes;
nNodes = 4 /* block, unblock, recovery, term */ + nReadNodes;
- RF_CallocAndAdd(nodes, nNodes, sizeof(RF_DagNode_t), (RF_DagNode_t *), allocList);
+ RF_MallocAndAdd(nodes, nNodes * sizeof(RF_DagNode_t), (RF_DagNode_t *), allocList);
i = 0;
blockNode = &nodes[i];
i += 1;
diff --git a/sys/dev/raidframe/rf_dagdegwr.c b/sys/dev/raidframe/rf_dagdegwr.c
index d3661c8fa6f..498226e2d1b 100644
--- a/sys/dev/raidframe/rf_dagdegwr.c
+++ b/sys/dev/raidframe/rf_dagdegwr.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_dagdegwr.c,v 1.12 2003/12/29 02:38:17 oster Exp $ */
+/* $NetBSD: rf_dagdegwr.c,v 1.13 2003/12/29 03:33:47 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_dagdegwr.c,v 1.12 2003/12/29 02:38:17 oster Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_dagdegwr.c,v 1.13 2003/12/29 03:33:47 oster Exp $");
#include <dev/raidframe/raidframevar.h>
@@ -200,7 +200,7 @@ rf_CommonCreateSimpleDegradedWriteDAG(raidPtr, asmap, dag_h, bp, flags,
* we need in order to recover the lost data.
*/
/* overlappingPDAs array must be zero'd */
- RF_Calloc(overlappingPDAs, asmap->numStripeUnitsAccessed, sizeof(char), (char *));
+ RF_Malloc(overlappingPDAs, asmap->numStripeUnitsAccessed * sizeof(char), (char *));
rf_GenerateFailedAccessASMs(raidPtr, asmap, failedPDA, dag_h, new_asm_h,
&nXorBufs, NULL, overlappingPDAs, allocList);
@@ -230,7 +230,7 @@ rf_CommonCreateSimpleDegradedWriteDAG(raidPtr, asmap, dag_h, bp, flags,
}
/* lock, unlock, xor, Wnd, Rrd, W(nfaults) */
nNodes = 5 + nfaults + nWndNodes + nRrdNodes;
- RF_CallocAndAdd(nodes, nNodes, sizeof(RF_DagNode_t),
+ RF_MallocAndAdd(nodes, nNodes * sizeof(RF_DagNode_t),
(RF_DagNode_t *), allocList);
i = 0;
blockNode = &nodes[i];
@@ -337,7 +337,7 @@ rf_CommonCreateSimpleDegradedWriteDAG(raidPtr, asmap, dag_h, bp, flags,
parityPDA->numSector = failedPDA->numSector;
if (!xorTargetBuf) {
- RF_CallocAndAdd(xorTargetBuf, 1,
+ RF_MallocAndAdd(xorTargetBuf,
rf_RaidAddressToByte(raidPtr, failedPDA->numSector), (char *), allocList);
}
/* init the Wnp node */
@@ -361,7 +361,7 @@ rf_CommonCreateSimpleDegradedWriteDAG(raidPtr, asmap, dag_h, bp, flags,
rf_InitNode(wnqNode, rf_wait, RF_FALSE, rf_DiskWriteFunc, rf_DiskWriteUndoFunc,
rf_GenericWakeupFunc, 1, 1, 4, 0, dag_h, "Wnq", allocList);
wnqNode->params[0].p = parityPDA;
- RF_CallocAndAdd(xorNode->results[1], 1,
+ RF_MallocAndAdd(xorNode->results[1],
rf_RaidAddressToByte(raidPtr, failedPDA->numSector), (char *), allocList);
wnqNode->params[1].p = xorNode->results[1];
wnqNode->params[2].v = parityStripeID;
@@ -598,7 +598,8 @@ rf_WriteGenerateFailedAccessASMs(
/* allocate up our list of pda's */
- RF_CallocAndAdd(pda_p, napdas, sizeof(RF_PhysDiskAddr_t), (RF_PhysDiskAddr_t *), allocList);
+ RF_MallocAndAdd(pda_p, napdas * sizeof(RF_PhysDiskAddr_t),
+ (RF_PhysDiskAddr_t *), allocList);
*pdap = pda_p;
/* linkem together */
@@ -704,7 +705,7 @@ rf_DoubleDegSmallWrite(
nWriteNodes = nWudNodes + 2 * nPQNodes;
nNodes = 4 + nReadNodes + nWriteNodes;
- RF_CallocAndAdd(nodes, nNodes, sizeof(RF_DagNode_t), (RF_DagNode_t *), allocList);
+ RF_MallocAndAdd(nodes, nNodes * sizeof(RF_DagNode_t), (RF_DagNode_t *), allocList);
blockNode = nodes;
unblockNode = blockNode + 1;
termNode = unblockNode + 1;
diff --git a/sys/dev/raidframe/rf_dagffrd.c b/sys/dev/raidframe/rf_dagffrd.c
index adde300421d..930b27ceeaf 100644
--- a/sys/dev/raidframe/rf_dagffrd.c
+++ b/sys/dev/raidframe/rf_dagffrd.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_dagffrd.c,v 1.8 2002/09/21 00:40:18 oster Exp $ */
+/* $NetBSD: rf_dagffrd.c,v 1.9 2003/12/29 03:33:47 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_dagffrd.c,v 1.8 2002/09/21 00:40:18 oster Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_dagffrd.c,v 1.9 2003/12/29 03:33:47 oster Exp $");
#include <dev/raidframe/raidframevar.h>
@@ -182,7 +182,7 @@ rf_CreateNonredundantDAG(
*/
RF_ASSERT(n > 0);
totalNumNodes = n + 3;
- RF_CallocAndAdd(nodes, totalNumNodes, sizeof(RF_DagNode_t),
+ RF_MallocAndAdd(nodes, totalNumNodes * sizeof(RF_DagNode_t),
(RF_DagNode_t *), allocList);
i = 0;
diskNodes = &nodes[i];
@@ -342,7 +342,7 @@ CreateMirrorReadDAG(
*/
RF_ASSERT(n > 0);
totalNumNodes = n + 3;
- RF_CallocAndAdd(nodes, totalNumNodes, sizeof(RF_DagNode_t),
+ RF_MallocAndAdd(nodes, totalNumNodes * sizeof(RF_DagNode_t),
(RF_DagNode_t *), allocList);
i = 0;
readNodes = &nodes[i];
diff --git a/sys/dev/raidframe/rf_dagffwr.c b/sys/dev/raidframe/rf_dagffwr.c
index 7e997dff793..846c9290bda 100644
--- a/sys/dev/raidframe/rf_dagffwr.c
+++ b/sys/dev/raidframe/rf_dagffwr.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_dagffwr.c,v 1.11 2003/07/01 22:43:59 oster Exp $ */
+/* $NetBSD: rf_dagffwr.c,v 1.12 2003/12/29 03:33:47 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_dagffwr.c,v 1.11 2003/07/01 22:43:59 oster Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_dagffwr.c,v 1.12 2003/12/29 03:33:47 oster Exp $");
#include <dev/raidframe/raidframevar.h>
@@ -206,8 +206,9 @@ rf_CommonCreateLargeWriteDAG(
/* alloc the nodes: Wnd, xor, commit, block, term, and Wnp */
nWndNodes = asmap->numStripeUnitsAccessed;
- RF_CallocAndAdd(nodes, nWndNodes + 4 + nfaults, sizeof(RF_DagNode_t),
- (RF_DagNode_t *), allocList);
+ RF_MallocAndAdd(nodes,
+ (nWndNodes + 4 + nfaults) * sizeof(RF_DagNode_t),
+ (RF_DagNode_t *), allocList);
i = 0;
wndNodes = &nodes[i];
i += nWndNodes;
@@ -230,8 +231,8 @@ rf_CommonCreateLargeWriteDAG(
rf_MapUnaccessedPortionOfStripe(raidPtr, layoutPtr, asmap, dag_h, new_asm_h,
&nRodNodes, &sosBuffer, &eosBuffer, allocList);
if (nRodNodes > 0) {
- RF_CallocAndAdd(rodNodes, nRodNodes, sizeof(RF_DagNode_t),
- (RF_DagNode_t *), allocList);
+ RF_MallocAndAdd(rodNodes, nRodNodes * sizeof(RF_DagNode_t),
+ (RF_DagNode_t *), allocList);
} else {
rodNodes = NULL;
}
@@ -316,9 +317,9 @@ rf_CommonCreateLargeWriteDAG(
}
}
if ((!allowBufferRecycle) || (i == nRodNodes)) {
- RF_CallocAndAdd(xorNode->results[0], 1,
- rf_RaidAddressToByte(raidPtr, raidPtr->Layout.sectorsPerStripeUnit),
- (void *), allocList);
+ RF_MallocAndAdd(xorNode->results[0],
+ rf_RaidAddressToByte(raidPtr, raidPtr->Layout.sectorsPerStripeUnit),
+ (void *), allocList);
} else {
xorNode->results[0] = rodNodes[i].params[1].p;
}
@@ -340,9 +341,9 @@ rf_CommonCreateLargeWriteDAG(
* to get smashed during the P and Q calculation, guaranteeing
* one would be wrong.
*/
- RF_CallocAndAdd(xorNode->results[1], 1,
- rf_RaidAddressToByte(raidPtr, raidPtr->Layout.sectorsPerStripeUnit),
- (void *), allocList);
+ RF_MallocAndAdd(xorNode->results[1],
+ rf_RaidAddressToByte(raidPtr, raidPtr->Layout.sectorsPerStripeUnit),
+ (void *), allocList);
rf_InitNode(wnqNode, rf_wait, RF_FALSE, rf_DiskWriteFunc, rf_DiskWriteUndoFunc,
rf_GenericWakeupFunc, 1, 1, 4, 0, dag_h, "Wnq", allocList);
wnqNode->params[0].p = asmap->qInfo;
@@ -532,8 +533,8 @@ rf_CommonCreateSmallWriteDAG(
/*
* Step 2. create the nodes
*/
- RF_CallocAndAdd(nodes, totalNumNodes, sizeof(RF_DagNode_t),
- (RF_DagNode_t *), allocList);
+ RF_MallocAndAdd(nodes, totalNumNodes * sizeof(RF_DagNode_t),
+ (RF_DagNode_t *), allocList);
i = 0;
blockNode = &nodes[i];
i += 1;
@@ -1098,8 +1099,9 @@ rf_CreateRaidOneWriteDAG(
/* total number of nodes = nWndNodes + nWmirNodes + (commit + unblock
* + terminator) */
- RF_CallocAndAdd(nodes, nWndNodes + nWmirNodes + 3, sizeof(RF_DagNode_t),
- (RF_DagNode_t *), allocList);
+ RF_MallocAndAdd(nodes,
+ (nWndNodes + nWmirNodes + 3) * sizeof(RF_DagNode_t),
+ (RF_DagNode_t *), allocList);
i = 0;
wndNode = &nodes[i];
i += nWndNodes;
diff --git a/sys/dev/raidframe/rf_dagutils.c b/sys/dev/raidframe/rf_dagutils.c
index 692f93ff468..2f850dbaad0 100644
--- a/sys/dev/raidframe/rf_dagutils.c
+++ b/sys/dev/raidframe/rf_dagutils.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_dagutils.c,v 1.21 2003/12/29 02:38:17 oster Exp $ */
+/* $NetBSD: rf_dagutils.c,v 1.22 2003/12/29 03:33:47 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -33,7 +33,7 @@
*****************************************************************************/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_dagutils.c,v 1.21 2003/12/29 02:38:17 oster Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_dagutils.c,v 1.22 2003/12/29 03:33:47 oster Exp $");
#include <dev/raidframe/raidframevar.h>
@@ -44,7 +44,6 @@ __KERNEL_RCSID(0, "$NetBSD: rf_dagutils.c,v 1.21 2003/12/29 02:38:17 oster Exp $
#include "rf_dagutils.h"
#include "rf_dagfuncs.h"
#include "rf_general.h"
-#include "rf_freelist.h"
#include "rf_map.h"
#include "rf_shutdown.h"
@@ -128,7 +127,8 @@ rf_InitNode(
*/
ptrs = (void **) node->dag_ptrs;
} else {
- RF_CallocAndAdd(ptrs, nptrs, sizeof(void *), (void **), alist);
+ RF_MallocAndAdd(ptrs, nptrs * sizeof(void *),
+ (void **), alist);
}
node->succedents = (nSucc) ? (RF_DagNode_t **) ptrs : NULL;
node->antecedents = (nAnte) ? (RF_DagNode_t **) (ptrs + nSucc) : NULL;
@@ -139,7 +139,9 @@ rf_InitNode(
if (nParam <= RF_DAG_PARAMCACHESIZE) {
node->params = (RF_DagParam_t *) node->dag_params;
} else {
- RF_CallocAndAdd(node->params, nParam, sizeof(RF_DagParam_t), (RF_DagParam_t *), alist);
+ RF_MallocAndAdd(node->params,
+ nParam * sizeof(RF_DagParam_t),
+ (RF_DagParam_t *), alist);
}
} else {
node->params = NULL;
@@ -174,9 +176,7 @@ rf_FreeDAG(dag_h)
}
}
-
-static RF_FreeList_t *rf_dagh_freelist;
-
+static struct pool rf_dagh_pool;
#define RF_MAX_FREE_DAGH 128
#define RF_DAGH_INC 16
#define RF_DAGH_INITIAL 32
@@ -186,7 +186,7 @@ static void
rf_ShutdownDAGs(ignored)
void *ignored;
{
- RF_FREELIST_DESTROY(rf_dagh_freelist, next, (RF_DagHeader_t *));
+ pool_destroy(&rf_dagh_pool);
}
int
@@ -195,18 +195,16 @@ rf_ConfigureDAGs(listp)
{
int rc;
- RF_FREELIST_CREATE(rf_dagh_freelist, RF_MAX_FREE_DAGH,
- RF_DAGH_INC, sizeof(RF_DagHeader_t));
- if (rf_dagh_freelist == NULL)
- return (ENOMEM);
+ pool_init(&rf_dagh_pool, sizeof(RF_DagHeader_t), 0, 0, 0,
+ "rf_dagh_pl", NULL);
+ pool_sethiwat(&rf_dagh_pool, RF_MAX_FREE_DAGH);
+ pool_prime(&rf_dagh_pool, RF_DAGH_INITIAL);
rc = rf_ShutdownCreate(listp, rf_ShutdownDAGs, NULL);
if (rc) {
rf_print_unable_to_add_shutdown(__FILE__, __LINE__, rc);
rf_ShutdownDAGs(NULL);
return (rc);
}
- RF_FREELIST_PRIME(rf_dagh_freelist, RF_DAGH_INITIAL, next,
- (RF_DagHeader_t *));
return (0);
}
@@ -215,7 +213,7 @@ rf_AllocDAGHeader()
{
RF_DagHeader_t *dh;
- RF_FREELIST_GET(rf_dagh_freelist, dh, next, (RF_DagHeader_t *));
+ dh = pool_get(&rf_dagh_pool, PR_WAITOK);
if (dh) {
memset((char *) dh, 0, sizeof(RF_DagHeader_t));
}
@@ -225,7 +223,7 @@ rf_AllocDAGHeader()
void
rf_FreeDAGHeader(RF_DagHeader_t * dh)
{
- RF_FREELIST_FREE(rf_dagh_freelist, dh, next);
+ pool_put(&rf_dagh_pool, dh);
}
/* allocates a buffer big enough to hold the data described by pda */
void *
@@ -641,9 +639,10 @@ rf_ValidateDAG(dag_h)
unvisited = dag_h->succedents[0]->visited;
- RF_Calloc(scount, nodecount, sizeof(int), (int *));
- RF_Calloc(acount, nodecount, sizeof(int), (int *));
- RF_Calloc(nodes, nodecount, sizeof(RF_DagNode_t *), (RF_DagNode_t **));
+ RF_Malloc(scount, nodecount * sizeof(int), (int *));
+ RF_Malloc(acount, nodecount * sizeof(int), (int *));
+ RF_Malloc(nodes, nodecount * sizeof(RF_DagNode_t *),
+ (RF_DagNode_t **));
for (i = 0; i < dag_h->numSuccedents; i++) {
if ((dag_h->succedents[i]->visited == unvisited)
&& rf_ValidateBranch(dag_h->succedents[i], scount,
diff --git a/sys/dev/raidframe/rf_debugMem.h b/sys/dev/raidframe/rf_debugMem.h
index b3d55b1beaa..ffd7d5b0043 100644
--- a/sys/dev/raidframe/rf_debugMem.h
+++ b/sys/dev/raidframe/rf_debugMem.h
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_debugMem.h,v 1.10 2002/09/16 23:40:57 oster Exp $ */
+/* $NetBSD: rf_debugMem.h,v 1.11 2003/12/29 03:33:47 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -67,17 +67,6 @@
if (__alist_) rf_AddToAllocList(__alist_, __p_, __size_); \
}
-#define RF_Calloc(_p_, _nel_, _elsz_, _cast_) \
- { \
- RF_Malloc( _p_, (_nel_) * (_elsz_), _cast_); \
- }
-
-#define RF_CallocAndAdd(__p,__nel,__elsz,__cast,__alist) \
- { \
- RF_Calloc(__p, __nel, __elsz, __cast); \
- if (__alist) rf_AddToAllocList(__alist, __p, (__nel)*(__elsz)); \
- }
-
#if RF_DEBUG_MEM
#define RF_Free(_p_, _sz_) \
{ \
diff --git a/sys/dev/raidframe/rf_diskqueue.c b/sys/dev/raidframe/rf_diskqueue.c
index a3b49f0030a..141e884890b 100644
--- a/sys/dev/raidframe/rf_diskqueue.c
+++ b/sys/dev/raidframe/rf_diskqueue.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_diskqueue.c,v 1.23 2003/12/29 02:38:17 oster Exp $ */
+/* $NetBSD: rf_diskqueue.c,v 1.24 2003/12/29 03:33:47 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -66,7 +66,7 @@
****************************************************************************/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_diskqueue.c,v 1.23 2003/12/29 02:38:17 oster Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_diskqueue.c,v 1.24 2003/12/29 03:33:47 oster Exp $");
#include <dev/raidframe/raidframevar.h>
@@ -77,7 +77,6 @@ __KERNEL_RCSID(0, "$NetBSD: rf_diskqueue.c,v 1.23 2003/12/29 02:38:17 oster Exp
#include "rf_acctrace.h"
#include "rf_etimer.h"
#include "rf_general.h"
-#include "rf_freelist.h"
#include "rf_debugprint.h"
#include "rf_shutdown.h"
#include "rf_cvscan.h"
@@ -150,8 +149,7 @@ static const RF_DiskQueueSW_t diskqueuesw[] = {
};
#define NUM_DISK_QUEUE_TYPES (sizeof(diskqueuesw)/sizeof(RF_DiskQueueSW_t))
-static RF_FreeList_t *rf_dqd_freelist;
-
+static struct pool rf_dqd_pool;
#define RF_MAX_FREE_DQD 256
#define RF_DQD_INC 16
#define RF_DQD_INITIAL 64
@@ -225,7 +223,7 @@ static void
rf_ShutdownDiskQueueSystem(ignored)
void *ignored;
{
- RF_FREELIST_DESTROY_CLEAN(rf_dqd_freelist, next, (RF_DiskQueueData_t *), clean_dqd);
+ pool_destroy(&rf_dqd_pool);
}
int
@@ -234,18 +232,18 @@ rf_ConfigureDiskQueueSystem(listp)
{
int rc;
- RF_FREELIST_CREATE(rf_dqd_freelist, RF_MAX_FREE_DQD,
- RF_DQD_INC, sizeof(RF_DiskQueueData_t));
- if (rf_dqd_freelist == NULL)
- return (ENOMEM);
+ pool_init(&rf_dqd_pool, sizeof(RF_DiskQueueData_t), 0, 0, 0,
+ "rf_dqd_pl", NULL);
+ pool_sethiwat(&rf_dqd_pool, RF_MAX_FREE_DQD);
+ pool_prime(&rf_dqd_pool, RF_DQD_INITIAL);
+
rc = rf_ShutdownCreate(listp, rf_ShutdownDiskQueueSystem, NULL);
if (rc) {
rf_print_unable_to_add_shutdown( __FILE__, __LINE__, rc);
rf_ShutdownDiskQueueSystem(NULL);
return (rc);
}
- RF_FREELIST_PRIME_INIT(rf_dqd_freelist, RF_DQD_INITIAL, next,
- (RF_DiskQueueData_t *), init_dqd);
+
return (0);
}
@@ -274,7 +272,8 @@ rf_ConfigureDiskQueues(
}
raidPtr->qType = p;
- RF_CallocAndAdd(diskQueues, raidPtr->numCol + RF_MAXSPARE,
+ RF_MallocAndAdd(diskQueues,
+ (raidPtr->numCol + RF_MAXSPARE) *
sizeof(RF_DiskQueue_t), (RF_DiskQueue_t *),
raidPtr->cleanupList);
if (diskQueues == NULL)
@@ -519,7 +518,12 @@ rf_CreateDiskQueueData(
{
RF_DiskQueueData_t *p;
- RF_FREELIST_GET_INIT(rf_dqd_freelist, p, next, (RF_DiskQueueData_t *), init_dqd);
+ p = pool_get(&rf_dqd_pool, PR_WAITOK);
+ if (init_dqd(p)) {
+ /* no memory for the buffer!?!? */
+ pool_put(&rf_dqd_pool, p);
+ return(NULL);
+ }
p->sectorOffset = ssect + rf_protectedSectors;
p->numSector = nsect;
@@ -542,5 +546,6 @@ void
rf_FreeDiskQueueData(p)
RF_DiskQueueData_t *p;
{
- RF_FREELIST_FREE_CLEAN(rf_dqd_freelist, p, next, clean_dqd);
+ clean_dqd(p);
+ pool_put(&rf_dqd_pool, p);
}
diff --git a/sys/dev/raidframe/rf_disks.c b/sys/dev/raidframe/rf_disks.c
index c4ede353e08..b7fe11041b8 100644
--- a/sys/dev/raidframe/rf_disks.c
+++ b/sys/dev/raidframe/rf_disks.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_disks.c,v 1.46 2003/12/29 02:38:17 oster Exp $ */
+/* $NetBSD: rf_disks.c,v 1.47 2003/12/29 03:33:48 oster Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -67,7 +67,7 @@
***************************************************************/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_disks.c,v 1.46 2003/12/29 02:38:17 oster Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_disks.c,v 1.47 2003/12/29 03:33:48 oster Exp $");
#include <dev/raidframe/raidframevar.h>
@@ -324,7 +324,7 @@ rf_AllocDiskStructures(raidPtr, cfgPtr)
/* We allocate RF_MAXSPARE on the first row so that we
have room to do hot-swapping of spares */
- RF_CallocAndAdd(raidPtr->Disks, raidPtr->numCol + RF_MAXSPARE,
+ RF_MallocAndAdd(raidPtr->Disks, (raidPtr->numCol + RF_MAXSPARE) *
sizeof(RF_RaidDisk_t), (RF_RaidDisk_t *),
raidPtr->cleanupList);
if (raidPtr->Disks == NULL) {
@@ -333,10 +333,11 @@ rf_AllocDiskStructures(raidPtr, cfgPtr)
}
/* get space for device specific stuff.. */
- RF_CallocAndAdd(raidPtr->raid_cinfo,
- raidPtr->numCol + raidPtr->numSpare,
+ RF_MallocAndAdd(raidPtr->raid_cinfo,
+ (raidPtr->numCol + raidPtr->numSpare) *
sizeof(struct raidcinfo), (struct raidcinfo *),
raidPtr->cleanupList);
+
if (raidPtr->raid_cinfo == NULL) {
ret = ENOMEM;
goto fail;
diff --git a/sys/dev/raidframe/rf_driver.c b/sys/dev/raidframe/rf_driver.c
index 27aba1bb9e3..ccb926d0417 100644
--- a/sys/dev/raidframe/rf_driver.c
+++ b/sys/dev/raidframe/rf_driver.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_driver.c,v 1.72 2003/12/29 02:38:17 oster Exp $ */
+/* $NetBSD: rf_driver.c,v 1.73 2003/12/29 03:33:48 oster Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -73,7 +73,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_driver.c,v 1.72 2003/12/29 02:38:17 oster Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_driver.c,v 1.73 2003/12/29 03:33:48 oster Exp $");
#include "opt_raid_diagnostic.h"
@@ -102,7 +102,6 @@ __KERNEL_RCSID(0, "$NetBSD: rf_driver.c,v 1.72 2003/12/29 02:38:17 oster Exp $")
#include "rf_general.h"
#include "rf_desc.h"
#include "rf_states.h"
-#include "rf_freelist.h"
#include "rf_decluster.h"
#include "rf_map.h"
#include "rf_revent.h"
@@ -123,7 +122,8 @@ __KERNEL_RCSID(0, "$NetBSD: rf_driver.c,v 1.72 2003/12/29 02:38:17 oster Exp $")
#endif
/* rad == RF_RaidAccessDesc_t */
-static RF_FreeList_t *rf_rad_freelist;
+RF_DECLARE_MUTEX(rf_rad_pool_lock)
+static struct pool rf_rad_pool;
#define RF_MAX_FREE_RAD 128
#define RF_RAD_INC 16
#define RF_RAD_INITIAL 32
@@ -238,16 +238,16 @@ rf_Shutdown(raidPtr)
* cuts down on the amount of serialization we've got going
* on.
*/
- RF_FREELIST_DO_LOCK(rf_rad_freelist);
+ RF_LOCK_MUTEX(rf_rad_pool_lock);
if (raidPtr->waitShutdown) {
- RF_FREELIST_DO_UNLOCK(rf_rad_freelist);
+ RF_UNLOCK_MUTEX(rf_rad_pool_lock);
return (EBUSY);
}
raidPtr->waitShutdown = 1;
while (raidPtr->nAccOutstanding) {
- RF_WAIT_COND(raidPtr->outstandingCond, RF_FREELIST_MUTEX_OF(rf_rad_freelist));
+ RF_WAIT_COND(raidPtr->outstandingCond, rf_rad_pool_lock);
}
- RF_FREELIST_DO_UNLOCK(rf_rad_freelist);
+ RF_UNLOCK_MUTEX(rf_rad_pool_lock);
/* Wait for any parity re-writes to stop... */
while (raidPtr->parity_rewrite_in_progress) {
@@ -497,7 +497,7 @@ static void
rf_ShutdownRDFreeList(ignored)
void *ignored;
{
- RF_FREELIST_DESTROY_CLEAN(rf_rad_freelist, next, (RF_RaidAccessDesc_t *), clean_rad);
+ pool_destroy(&rf_rad_pool);
}
static int
@@ -506,19 +506,16 @@ rf_ConfigureRDFreeList(listp)
{
int rc;
- RF_FREELIST_CREATE(rf_rad_freelist, RF_MAX_FREE_RAD,
- RF_RAD_INC, sizeof(RF_RaidAccessDesc_t));
- if (rf_rad_freelist == NULL) {
- return (ENOMEM);
- }
+ pool_init(&rf_rad_pool, sizeof(RF_RaidAccessDesc_t), 0, 0, 0,
+ "rf_rad_pl", NULL);
+ pool_sethiwat(&rf_rad_pool, RF_MAX_FREE_RAD);
+ pool_prime(&rf_rad_pool, RF_RAD_INITIAL);
rc = rf_ShutdownCreate(listp, rf_ShutdownRDFreeList, NULL);
if (rc) {
rf_print_unable_to_add_shutdown(__FILE__, __LINE__, rc);
rf_ShutdownRDFreeList(NULL);
return (rc);
}
- RF_FREELIST_PRIME_INIT(rf_rad_freelist, RF_RAD_INITIAL, next,
- (RF_RaidAccessDesc_t *), init_rad);
return (0);
}
@@ -535,18 +532,23 @@ rf_AllocRaidAccDesc(
{
RF_RaidAccessDesc_t *desc;
- RF_FREELIST_GET_INIT_NOUNLOCK(rf_rad_freelist, desc, next, (RF_RaidAccessDesc_t *), init_rad);
+ desc = pool_get(&rf_rad_pool, PR_WAITOK);
+ init_rad(desc);
+
if (raidPtr->waitShutdown) {
/*
* Actually, we're shutting the array down. Free the desc
* and return NULL.
*/
- RF_FREELIST_DO_UNLOCK(rf_rad_freelist);
- RF_FREELIST_FREE_CLEAN(rf_rad_freelist, desc, next, clean_rad);
+
+ RF_UNLOCK_MUTEX(rf_rad_pool_lock);
+ clean_rad(desc);
+ pool_put(&rf_rad_pool, desc);
return (NULL);
}
raidPtr->nAccOutstanding++;
- RF_FREELIST_DO_UNLOCK(rf_rad_freelist);
+
+ RF_UNLOCK_MUTEX(rf_rad_pool_lock);
desc->raidPtr = (void *) raidPtr;
desc->type = type;
@@ -579,12 +581,13 @@ rf_FreeRaidAccDesc(RF_RaidAccessDesc_t * desc)
RF_ASSERT(desc);
rf_FreeAllocList(desc->cleanupList);
- RF_FREELIST_FREE_CLEAN_NOUNLOCK(rf_rad_freelist, desc, next, clean_rad);
+ clean_rad(desc);
+ pool_put(&rf_rad_pool, desc);
raidPtr->nAccOutstanding--;
if (raidPtr->waitShutdown) {
RF_SIGNAL_COND(raidPtr->outstandingCond);
}
- RF_FREELIST_DO_UNLOCK(rf_rad_freelist);
+ RF_UNLOCK_MUTEX(rf_rad_pool_lock);
}
/*********************************************************************
* Main routine for performing an access.
diff --git a/sys/dev/raidframe/rf_evenodd.c b/sys/dev/raidframe/rf_evenodd.c
index aecd9c849ac..0c82e0d57dc 100644
--- a/sys/dev/raidframe/rf_evenodd.c
+++ b/sys/dev/raidframe/rf_evenodd.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_evenodd.c,v 1.10 2003/11/16 20:32:05 oster Exp $ */
+/* $NetBSD: rf_evenodd.c,v 1.11 2003/12/29 03:33:48 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -33,7 +33,7 @@
****************************************************************************************/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_evenodd.c,v 1.10 2003/11/16 20:32:05 oster Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_evenodd.c,v 1.11 2003/12/29 03:33:48 oster Exp $");
#include "rf_archs.h"
@@ -384,11 +384,9 @@ rf_VerifyParityEvenOdd(raidPtr, raidAddr, parityPDA, correct_it, flags)
mcpair = rf_AllocMCPair();
rf_MakeAllocList(alloclist);
RF_MallocAndAdd(buf, numbytes * (layoutPtr->numDataCol + layoutPtr->numParityCol), (char *), alloclist);
- RF_CallocAndAdd(pbuf, 1, numbytes, (char *), alloclist); /* use calloc to make
- * sure buffer is zeroed */
+ RF_MallocAndAdd(pbuf, numbytes, (char *), alloclist);
end_p = buf + bytesPerStripe;
- RF_CallocAndAdd(redundantbuf2, 1, numbytes, (char *), alloclist); /* use calloc to make
- * sure buffer is zeroed */
+ RF_MallocAndAdd(redundantbuf2, numbytes, (char *), alloclist);
rd_dag_h = rf_MakeSimpleDAG(raidPtr, stripeWidth, numbytes, buf, rf_DiskReadFunc, rf_DiskReadUndoFunc,
"Rod", alloclist, flags, RF_IO_NORMAL_PRIORITY);
diff --git a/sys/dev/raidframe/rf_fifo.c b/sys/dev/raidframe/rf_fifo.c
index 7c6a28c4f98..b27af37797b 100644
--- a/sys/dev/raidframe/rf_fifo.c
+++ b/sys/dev/raidframe/rf_fifo.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_fifo.c,v 1.8 2002/09/17 03:43:34 oster Exp $ */
+/* $NetBSD: rf_fifo.c,v 1.9 2003/12/29 03:33:48 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -36,7 +36,7 @@
***************************************************/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_fifo.c,v 1.8 2002/09/17 03:43:34 oster Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_fifo.c,v 1.9 2003/12/29 03:33:48 oster Exp $");
#include <dev/raidframe/raidframevar.h>
@@ -60,7 +60,8 @@ rf_FifoCreate(sectPerDisk, clList, listp)
{
RF_FifoHeader_t *q;
- RF_CallocAndAdd(q, 1, sizeof(RF_FifoHeader_t), (RF_FifoHeader_t *), clList);
+ RF_MallocAndAdd(q, sizeof(RF_FifoHeader_t),
+ (RF_FifoHeader_t *), clList);
q->hq_count = q->lq_count = 0;
return ((void *) q);
}
diff --git a/sys/dev/raidframe/rf_freelist.h b/sys/dev/raidframe/rf_freelist.h
index 39786535cb9..48e1245e3a3 100644
--- a/sys/dev/raidframe/rf_freelist.h
+++ b/sys/dev/raidframe/rf_freelist.h
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_freelist.h,v 1.7 2002/10/11 02:15:57 oster Exp $ */
+/* $NetBSD: rf_freelist.h,v 1.8 2003/12/29 03:33:48 oster Exp $ */
/*
* rf_freelist.h
*/
@@ -406,70 +406,6 @@ struct RF_FreeList_s {
}
/*
- * fl = freelist
- * obj = object to allocate
- * nextp = name of "next" pointer in obj
- * cast = cast of obj assignment
- * num = num objs to return
- */
-#define RF_FREELIST_GET_N(_fl_,_obj_,_nextp_,_cast_,_num_) { \
- void *_p, *_l, *_f; \
- int _i, _n; \
- _l = _f = NULL; \
- _n = 0; \
- RF_ASSERT(sizeof(*(_obj_))==((_fl_)->obj_size)); \
- for(_n=0;_n<_num_;_n++) { \
- RF_LOCK_MUTEX((_fl_)->lock); \
- if (_fl_->objlist) { \
- _obj_ = _cast_((_fl_)->objlist); \
- (_fl_)->objlist = (void *)((_obj_)->_nextp_); \
- (_fl_)->free_cnt--; \
- RF_UNLOCK_MUTEX((_fl_)->lock); \
- } \
- else { \
- RF_UNLOCK_MUTEX((_fl_)->lock); \
- /* \
- * Allocate one at a time so we can free \
- * one at a time without cleverness when arena \
- * is full. \
- */ \
- RF_Calloc(_obj_,1,(_fl_)->obj_size,_cast_); \
- if (_obj_) { \
- for(_i=1;_i<(_fl_)->obj_inc;_i++) { \
- RF_Calloc(_p,1,(_fl_)->obj_size,(void *)); \
- if (_p) { \
- RF_LOCK_MUTEX((_fl_)->lock); \
- (_cast_(_p))->_nextp_ = (_fl_)->objlist; \
- (_fl_)->objlist = _p; \
- RF_UNLOCK_MUTEX((_fl_)->lock); \
- } \
- else { \
- break; \
- } \
- } \
- } \
- RF_LOCK_MUTEX((_fl_)->lock); \
- RF_FREELIST_STAT_GROW(_fl_); \
- RF_UNLOCK_MUTEX((_fl_)->lock); \
- } \
- RF_LOCK_MUTEX((_fl_)->lock); \
- if (_f == NULL) \
- _f = _obj_; \
- if (_obj_) { \
- (_cast_(_obj_))->_nextp_ = _l; \
- _l = _obj_; \
- RF_FREELIST_STAT_ALLOC(_fl_); \
- } \
- else { \
- (_cast_(_f))->_nextp_ = (_fl_)->objlist; \
- (_fl_)->objlist = _l; \
- _n = _num_; \
- } \
- RF_UNLOCK_MUTEX((_fl_)->lock); \
- } \
-}
-
-/*
* fl = freelist
* obj = object to free
* nextp = name of "next" pointer in obj
@@ -493,36 +429,6 @@ struct RF_FreeList_s {
* fl = freelist
* obj = object to free
* nextp = name of "next" pointer in obj
- * num = num to free (debugging)
- */
-#define RF_FREELIST_FREE_N(_fl_,_obj_,_nextp_,_cast_,_num_) { \
- void *_no; \
- int _n; \
- _n = 0; \
- RF_LOCK_MUTEX((_fl_)->lock); \
- while(_obj_) { \
- _no = (_cast_(_obj_))->_nextp_; \
- if ((_fl_)->free_cnt == (_fl_)->max_free_cnt) { \
- RF_Free(_obj_,(_fl_)->obj_size); \
- } \
- else { \
- RF_ASSERT((_fl_)->free_cnt < (_fl_)->max_free_cnt); \
- (_obj_)->_nextp_ = (_fl_)->objlist; \
- (_fl_)->objlist = (void *)(_obj_); \
- (_fl_)->free_cnt++; \
- } \
- _n++; \
- _obj_ = _no; \
- RF_FREELIST_STAT_FREE(_fl_); \
- } \
- RF_ASSERT(_n==(_num_)); \
- RF_UNLOCK_MUTEX((_fl_)->lock); \
-}
-
-/*
- * fl = freelist
- * obj = object to free
- * nextp = name of "next" pointer in obj
* clean = undo for init
*/
#define RF_FREELIST_FREE_CLEAN(_fl_,_obj_,_nextp_,_clean_) { \
@@ -596,23 +502,4 @@ struct RF_FreeList_s {
RF_Free(_fl_,sizeof(RF_FreeList_t)); \
}
-/*
- * fl = freelist
- * nextp = name of "next" pointer in obj
- * cast = cast to object type
- * clean = func to undo obj init
- * arg = arg for undo func
- */
-#define RF_FREELIST_DESTROY_CLEAN_ARG(_fl_,_nextp_,_cast_,_clean_,_arg_) { \
- void *_cur, *_next; \
- RF_FREELIST_STAT_REPORT(_fl_); \
- rf_mutex_destroy(&((_fl_)->lock)); \
- for(_cur=(_fl_)->objlist;_cur;_cur=_next) { \
- _next = (_cast_ _cur)->_nextp_; \
- _clean_ (_cur,_arg_); \
- RF_Free(_cur,(_fl_)->obj_size); \
- } \
- RF_Free(_fl_,sizeof(RF_FreeList_t)); \
-}
-
#endif /* !_RF__RF_FREELIST_H_ */
diff --git a/sys/dev/raidframe/rf_map.c b/sys/dev/raidframe/rf_map.c
index 11510aa3262..9f233258405 100644
--- a/sys/dev/raidframe/rf_map.c
+++ b/sys/dev/raidframe/rf_map.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_map.c,v 1.23 2003/12/29 02:38:18 oster Exp $ */
+/* $NetBSD: rf_map.c,v 1.24 2003/12/29 03:33:48 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -33,7 +33,7 @@
**************************************************************************/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_map.c,v 1.23 2003/12/29 02:38:18 oster Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_map.c,v 1.24 2003/12/29 03:33:48 oster Exp $");
#include <dev/raidframe/raidframevar.h>
@@ -41,7 +41,6 @@ __KERNEL_RCSID(0, "$NetBSD: rf_map.c,v 1.23 2003/12/29 02:38:18 oster Exp $");
#include "rf_raid.h"
#include "rf_general.h"
#include "rf_map.h"
-#include "rf_freelist.h"
#include "rf_shutdown.h"
static void rf_FreePDAList(RF_PhysDiskAddr_t * start, RF_PhysDiskAddr_t * end, int count);
@@ -304,17 +303,20 @@ rf_MarkFailuresInASMList(raidPtr, asm_h)
*
***************************************************************************/
-static RF_FreeList_t *rf_asmhdr_freelist;
+static struct pool rf_asmhdr_pool;
#define RF_MAX_FREE_ASMHDR 128
#define RF_ASMHDR_INC 16
#define RF_ASMHDR_INITIAL 32
-static RF_FreeList_t *rf_asm_freelist;
+static struct pool rf_asm_pool;
#define RF_MAX_FREE_ASM 192
#define RF_ASM_INC 24
#define RF_ASM_INITIAL 64
-static RF_FreeList_t *rf_pda_freelist;
+static struct pool rf_pda_pool; /* may need to be visible for
+ rf_dagdegrd.c and rf_dagdegwr.c,
+ if they can be convinced to free
+ the space easily */
#define RF_MAX_FREE_PDA 192
#define RF_PDA_INC 24
#define RF_PDA_INITIAL 64
@@ -325,9 +327,9 @@ static void
rf_ShutdownMapModule(ignored)
void *ignored;
{
- RF_FREELIST_DESTROY(rf_asmhdr_freelist, next, (RF_AccessStripeMapHeader_t *));
- RF_FREELIST_DESTROY(rf_pda_freelist, next, (RF_PhysDiskAddr_t *));
- RF_FREELIST_DESTROY(rf_asm_freelist, next, (RF_AccessStripeMap_t *));
+ pool_destroy(&rf_asmhdr_pool);
+ pool_destroy(&rf_asm_pool);
+ pool_destroy(&rf_pda_pool);
}
int
@@ -336,37 +338,27 @@ rf_ConfigureMapModule(listp)
{
int rc;
- RF_FREELIST_CREATE(rf_asmhdr_freelist, RF_MAX_FREE_ASMHDR,
- RF_ASMHDR_INC, sizeof(RF_AccessStripeMapHeader_t));
- if (rf_asmhdr_freelist == NULL) {
- return (ENOMEM);
- }
- RF_FREELIST_CREATE(rf_asm_freelist, RF_MAX_FREE_ASM,
- RF_ASM_INC, sizeof(RF_AccessStripeMap_t));
- if (rf_asm_freelist == NULL) {
- RF_FREELIST_DESTROY(rf_asmhdr_freelist, next, (RF_AccessStripeMapHeader_t *));
- return (ENOMEM);
- }
- RF_FREELIST_CREATE(rf_pda_freelist, RF_MAX_FREE_PDA,
- RF_PDA_INC, sizeof(RF_PhysDiskAddr_t));
- if (rf_pda_freelist == NULL) {
- RF_FREELIST_DESTROY(rf_asmhdr_freelist, next, (RF_AccessStripeMapHeader_t *));
- RF_FREELIST_DESTROY(rf_asm_freelist, next, (RF_AccessStripeMap_t *));
- return (ENOMEM);
- }
+ pool_init(&rf_asmhdr_pool, sizeof(RF_AccessStripeMapHeader_t),
+ 0, 0, 0, "rf_asmhdr_pl", NULL);
+ pool_sethiwat(&rf_asmhdr_pool, RF_MAX_FREE_ASMHDR);
+ pool_prime(&rf_asmhdr_pool, RF_ASMHDR_INITIAL);
+
+ pool_init(&rf_asm_pool, sizeof(RF_AccessStripeMap_t),
+ 0, 0, 0, "rf_asm_pl", NULL);
+ pool_sethiwat(&rf_asm_pool, RF_MAX_FREE_ASM);
+ pool_prime(&rf_asm_pool, RF_ASM_INITIAL);
+
+ pool_init(&rf_pda_pool, sizeof(RF_PhysDiskAddr_t),
+ 0, 0, 0, "rf_pda_pl", NULL);
+ pool_sethiwat(&rf_pda_pool, RF_MAX_FREE_PDA);
+ pool_prime(&rf_pda_pool, RF_PDA_INITIAL);
+
rc = rf_ShutdownCreate(listp, rf_ShutdownMapModule, NULL);
if (rc) {
rf_print_unable_to_add_shutdown(__FILE__, __LINE__, rc);
rf_ShutdownMapModule(NULL);
return (rc);
}
- RF_FREELIST_PRIME(rf_asmhdr_freelist, RF_ASMHDR_INITIAL, next,
- (RF_AccessStripeMapHeader_t *));
- RF_FREELIST_PRIME(rf_asm_freelist, RF_ASM_INITIAL, next,
- (RF_AccessStripeMap_t *));
- RF_FREELIST_PRIME(rf_pda_freelist, RF_PDA_INITIAL, next,
- (RF_PhysDiskAddr_t *));
-
return (0);
}
@@ -375,18 +367,17 @@ rf_AllocAccessStripeMapHeader()
{
RF_AccessStripeMapHeader_t *p;
- RF_FREELIST_GET(rf_asmhdr_freelist, p, next, (RF_AccessStripeMapHeader_t *));
+ p = pool_get(&rf_asmhdr_pool, PR_WAITOK);
memset((char *) p, 0, sizeof(RF_AccessStripeMapHeader_t));
return (p);
}
-
void
rf_FreeAccessStripeMapHeader(p)
RF_AccessStripeMapHeader_t *p;
{
- RF_FREELIST_FREE(rf_asmhdr_freelist, p, next);
+ pool_put(&rf_asmhdr_pool, p);
}
RF_PhysDiskAddr_t *
@@ -394,7 +385,7 @@ rf_AllocPhysDiskAddr()
{
RF_PhysDiskAddr_t *p;
- RF_FREELIST_GET(rf_pda_freelist, p, next, (RF_PhysDiskAddr_t *));
+ p = pool_get(&rf_pda_pool, PR_WAITOK);
memset((char *) p, 0, sizeof(RF_PhysDiskAddr_t));
return (p);
@@ -408,9 +399,17 @@ RF_PhysDiskAddr_t *
rf_AllocPDAList(count)
int count;
{
- RF_PhysDiskAddr_t *p = NULL;
+ RF_PhysDiskAddr_t *p, *prev;
+ int i;
+
+ p = NULL;
+ prev = NULL;
+ for (i = 0; i < count; i++) {
+ p = pool_get(&rf_pda_pool, PR_WAITOK);
+ p->next = prev;
+ prev = p;
+ }
- RF_FREELIST_GET_N(rf_pda_freelist, p, next, (RF_PhysDiskAddr_t *), count);
return (p);
}
@@ -419,7 +418,7 @@ void
rf_FreePhysDiskAddr(p)
RF_PhysDiskAddr_t *p;
{
- RF_FREELIST_FREE(rf_pda_freelist, p, next);
+ pool_put(&rf_pda_pool, p);
}
#endif
@@ -429,7 +428,14 @@ rf_FreePDAList(l_start, l_end, count)
* of list */
int count; /* number of elements in list */
{
- RF_FREELIST_FREE_N(rf_pda_freelist, l_start, next, (RF_PhysDiskAddr_t *), count);
+ RF_PhysDiskAddr_t *p, *tmp;
+
+ p=l_start;
+ while (p) {
+ tmp = p->next;
+ pool_put(&rf_pda_pool, p);
+ p = tmp;
+ }
}
/* this is essentially identical to AllocPDAList. I should combine the two.
@@ -441,9 +447,16 @@ RF_AccessStripeMap_t *
rf_AllocASMList(count)
int count;
{
- RF_AccessStripeMap_t *p = NULL;
-
- RF_FREELIST_GET_N(rf_asm_freelist, p, next, (RF_AccessStripeMap_t *), count);
+ RF_AccessStripeMap_t *p, *prev;
+ int i;
+
+ p = NULL;
+ prev = NULL;
+ for (i = 0; i < count; i++) {
+ p = pool_get(&rf_asm_pool, PR_WAITOK);
+ p->next = prev;
+ prev = p;
+ }
return (p);
}
@@ -452,7 +465,14 @@ rf_FreeASMList(l_start, l_end, count)
RF_AccessStripeMap_t *l_start, *l_end;
int count;
{
- RF_FREELIST_FREE_N(rf_asm_freelist, l_start, next, (RF_AccessStripeMap_t *), count);
+ RF_AccessStripeMap_t *p, *tmp;
+
+ p=l_start;
+ while (p) {
+ tmp = p->next;
+ pool_put(&rf_asm_pool, p);
+ p = tmp;
+ }
}
void
diff --git a/sys/dev/raidframe/rf_mcpair.c b/sys/dev/raidframe/rf_mcpair.c
index f6d666a7a3a..561f925bc63 100644
--- a/sys/dev/raidframe/rf_mcpair.c
+++ b/sys/dev/raidframe/rf_mcpair.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_mcpair.c,v 1.8 2002/09/14 17:53:58 oster Exp $ */
+/* $NetBSD: rf_mcpair.c,v 1.9 2003/12/29 03:33:48 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_mcpair.c,v 1.8 2002/09/14 17:53:58 oster Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_mcpair.c,v 1.9 2003/12/29 03:33:48 oster Exp $");
#include <dev/raidframe/raidframevar.h>
@@ -40,13 +40,13 @@ __KERNEL_RCSID(0, "$NetBSD: rf_mcpair.c,v 1.8 2002/09/14 17:53:58 oster Exp $");
#include "rf_threadstuff.h"
#include "rf_mcpair.h"
#include "rf_debugMem.h"
-#include "rf_freelist.h"
+#include "rf_general.h"
#include "rf_shutdown.h"
+#include <sys/pool.h>
#include <sys/proc.h>
-static RF_FreeList_t *rf_mcpair_freelist;
-
+static struct pool rf_mcpair_pool;
#define RF_MAX_FREE_MCPAIR 128
#define RF_MCPAIR_INC 16
#define RF_MCPAIR_INITIAL 24
@@ -89,7 +89,8 @@ static void
rf_ShutdownMCPair(ignored)
void *ignored;
{
- RF_FREELIST_DESTROY_CLEAN(rf_mcpair_freelist, next, (RF_MCPair_t *), clean_mcpair);
+ /* XXX what about the "cleaning" stuff??? Is it even necessary */
+ pool_destroy(&rf_mcpair_pool);
}
int
@@ -98,16 +99,18 @@ rf_ConfigureMCPair(listp)
{
int rc;
- RF_FREELIST_CREATE(rf_mcpair_freelist, RF_MAX_FREE_MCPAIR,
- RF_MCPAIR_INC, sizeof(RF_MCPair_t));
+ pool_init(&rf_mcpair_pool, sizeof(RF_MCPair_t), 0, 0, 0,
+ "rf_mcpair_pl", NULL);
+ pool_sethiwat(&rf_mcpair_pool, RF_MAX_FREE_MCPAIR);
+ pool_prime(&rf_mcpair_pool, RF_MCPAIR_INITIAL);
+
rc = rf_ShutdownCreate(listp, rf_ShutdownMCPair, NULL);
if (rc) {
rf_print_unable_to_add_shutdown(__FILE__, __LINE__, rc);
rf_ShutdownMCPair(NULL);
return (rc);
}
- RF_FREELIST_PRIME_INIT(rf_mcpair_freelist, RF_MCPAIR_INITIAL, next,
- (RF_MCPair_t *), init_mcpair);
+
return (0);
}
@@ -116,7 +119,12 @@ rf_AllocMCPair()
{
RF_MCPair_t *t;
- RF_FREELIST_GET_INIT(rf_mcpair_freelist, t, next, (RF_MCPair_t *), init_mcpair);
+ t = pool_get(&rf_mcpair_pool, PR_WAITOK);
+ if (init_mcpair(t)) {
+ /* some sort of error... */
+ pool_put(&rf_mcpair_pool, t);
+ t = NULL;
+ }
if (t) {
t->flag = 0;
t->next = NULL;
@@ -128,7 +136,8 @@ void
rf_FreeMCPair(t)
RF_MCPair_t *t;
{
- RF_FREELIST_FREE_CLEAN(rf_mcpair_freelist, t, next, clean_mcpair);
+ clean_mcpair(t);
+ pool_put(&rf_mcpair_pool, t);
}
/* the callback function used to wake you up when you use an mcpair to wait for something */
void
diff --git a/sys/dev/raidframe/rf_netbsdkintf.c b/sys/dev/raidframe/rf_netbsdkintf.c
index 49da2455b98..bcb4738e5c1 100644
--- a/sys/dev/raidframe/rf_netbsdkintf.c
+++ b/sys/dev/raidframe/rf_netbsdkintf.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_netbsdkintf.c,v 1.166 2003/12/29 02:38:18 oster Exp $ */
+/* $NetBSD: rf_netbsdkintf.c,v 1.167 2003/12/29 03:33:48 oster Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -146,7 +146,7 @@
***********************************************************/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.166 2003/12/29 02:38:18 oster Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.167 2003/12/29 03:33:48 oster Exp $");
#include <sys/param.h>
#include <sys/errno.h>
@@ -358,7 +358,7 @@ raidattach(num)
/* Make some space for requested number of units... */
- RF_Calloc(raidPtrs, num, sizeof(RF_Raid_t *), (RF_Raid_t **));
+ RF_Malloc(raidPtrs, num * sizeof(RF_Raid_t *), (RF_Raid_t **));
if (raidPtrs == NULL) {
panic("raidPtrs is NULL!!");
}
@@ -411,7 +411,7 @@ raidattach(num)
raidrootdev[raidID].dv_flags = 0;
sprintf(raidrootdev[raidID].dv_xname,"raid%d",raidID);
- RF_Calloc(raidPtrs[raidID], 1, sizeof(RF_Raid_t),
+ RF_Malloc(raidPtrs[raidID], sizeof(RF_Raid_t),
(RF_Raid_t *));
if (raidPtrs[raidID] == NULL) {
printf("WARNING: raidPtrs[%d] is NULL\n", raidID);
diff --git a/sys/dev/raidframe/rf_paritylogging.c b/sys/dev/raidframe/rf_paritylogging.c
index b15bc1c2597..53795db2777 100644
--- a/sys/dev/raidframe/rf_paritylogging.c
+++ b/sys/dev/raidframe/rf_paritylogging.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_paritylogging.c,v 1.16 2003/12/29 02:38:18 oster Exp $ */
+/* $NetBSD: rf_paritylogging.c,v 1.17 2003/12/29 03:33:48 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_paritylogging.c,v 1.16 2003/12/29 02:38:18 oster Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_paritylogging.c,v 1.17 2003/12/29 03:33:48 oster Exp $");
#include "rf_archs.h"
@@ -243,7 +243,7 @@ rf_ConfigureParityLogging(
}
for (i = 0; i < raidPtr->numParityLogs; i++) {
if (i == 0) {
- RF_Calloc(raidPtr->parityLogPool.parityLogs, 1,
+ RF_Malloc(raidPtr->parityLogPool.parityLogs,
sizeof(RF_ParityLog_t), (RF_ParityLog_t *));
if (raidPtr->parityLogPool.parityLogs == NULL) {
RF_Free(raidPtr->parityLogBufferHeap,
@@ -254,7 +254,7 @@ rf_ConfigureParityLogging(
}
l = raidPtr->parityLogPool.parityLogs;
} else {
- RF_Calloc(l->next, 1, sizeof(RF_ParityLog_t),
+ RF_Malloc(l->next, sizeof(RF_ParityLog_t),
(RF_ParityLog_t *));
if (l->next == NULL) {
RF_Free(raidPtr->parityLogBufferHeap,
diff --git a/sys/dev/raidframe/rf_parityloggingdags.c b/sys/dev/raidframe/rf_parityloggingdags.c
index 05048edf09b..b1f1e0bcc4f 100644
--- a/sys/dev/raidframe/rf_parityloggingdags.c
+++ b/sys/dev/raidframe/rf_parityloggingdags.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_parityloggingdags.c,v 1.9 2003/06/23 11:02:01 martin Exp $ */
+/* $NetBSD: rf_parityloggingdags.c,v 1.10 2003/12/29 03:33:48 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_parityloggingdags.c,v 1.9 2003/06/23 11:02:01 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_parityloggingdags.c,v 1.10 2003/12/29 03:33:48 oster Exp $");
#include "rf_archs.h"
#include "opt_raid_diagnostic.h"
@@ -99,7 +99,8 @@ rf_CommonCreateParityLoggingLargeWriteDAG(
/* alloc the Wnd nodes, the xor node, and the Lpo node */
nWndNodes = asmap->numStripeUnitsAccessed;
- RF_CallocAndAdd(nodes, nWndNodes + 6, sizeof(RF_DagNode_t), (RF_DagNode_t *), allocList);
+ RF_MallocAndAdd(nodes, (nWndNodes + 6) * sizeof(RF_DagNode_t),
+ (RF_DagNode_t *), allocList);
i = 0;
wndNodes = &nodes[i];
i += nWndNodes;
@@ -122,7 +123,8 @@ rf_CommonCreateParityLoggingLargeWriteDAG(
rf_MapUnaccessedPortionOfStripe(raidPtr, layoutPtr, asmap, dag_h, new_asm_h, &nRodNodes, &sosBuffer, &eosBuffer, allocList);
if (nRodNodes > 0)
- RF_CallocAndAdd(rodNodes, nRodNodes, sizeof(RF_DagNode_t), (RF_DagNode_t *), allocList);
+ RF_MallocAndAdd(rodNodes, nRodNodes * sizeof(RF_DagNode_t),
+ (RF_DagNode_t *), allocList);
/* begin node initialization */
rf_InitNode(blockNode, rf_wait, RF_FALSE, rf_NullNodeFunc, rf_NullNodeUndoFunc, NULL, nRodNodes + 1, 0, 0, 0, dag_h, "Nil", allocList);
@@ -181,7 +183,8 @@ rf_CommonCreateParityLoggingLargeWriteDAG(
if (((RF_PhysDiskAddr_t *) rodNodes[i].params[0].p)->numSector == raidPtr->Layout.sectorsPerStripeUnit)
break;
if (i == nRodNodes) {
- RF_CallocAndAdd(xorNode->results[0], 1, rf_RaidAddressToByte(raidPtr, raidPtr->Layout.sectorsPerStripeUnit), (void *), allocList);
+ RF_MallocAndAdd(xorNode->results[0],
+ rf_RaidAddressToByte(raidPtr, raidPtr->Layout.sectorsPerStripeUnit), (void *), allocList);
} else {
xorNode->results[0] = rodNodes[i].params[1].p;
}
@@ -368,7 +371,8 @@ rf_CommonCreateParityLoggingSmallWriteDAG(
dag_h->numSuccedents = 1;
/* Step 2. create the nodes */
- RF_CallocAndAdd(nodes, totalNumNodes, sizeof(RF_DagNode_t), (RF_DagNode_t *), allocList);
+ RF_MallocAndAdd(nodes, totalNumNodes * sizeof(RF_DagNode_t),
+ (RF_DagNode_t *), allocList);
i = 0;
blockNode = &nodes[i];
i += 1;
diff --git a/sys/dev/raidframe/rf_parityscan.c b/sys/dev/raidframe/rf_parityscan.c
index 80e2e2cf279..cb67aca7cd5 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.19 2003/12/29 02:38:18 oster Exp $ */
+/* $NetBSD: rf_parityscan.c,v 1.20 2003/12/29 03:33:48 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.19 2003/12/29 02:38:18 oster Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_parityscan.c,v 1.20 2003/12/29 03:33:48 oster Exp $");
#include <dev/raidframe/raidframevar.h>
@@ -211,8 +211,7 @@ rf_VerifyParityBasic(raidPtr, raidAddr, parityPDA, correct_it, flags)
mcpair = rf_AllocMCPair();
rf_MakeAllocList(alloclist);
RF_MallocAndAdd(buf, numbytes * (layoutPtr->numDataCol + layoutPtr->numParityCol), (char *), alloclist);
- RF_CallocAndAdd(pbuf, 1, numbytes, (char *), alloclist); /* use calloc to make
- * sure buffer is zeroed */
+ RF_MallocAndAdd(pbuf, numbytes, (char *), alloclist);
end_p = buf + bytesPerStripe;
rd_dag_h = rf_MakeSimpleDAG(raidPtr, stripeWidth, numbytes, buf, rf_DiskReadFunc, rf_DiskReadUndoFunc,
@@ -407,7 +406,8 @@ rf_MakeSimpleDAG(raidPtr, nNodes, bytesPerSU, databuf, doFunc, undoFunc, name, a
/* create the nodes, the block & unblock nodes, and the terminator
* node */
- RF_CallocAndAdd(nodes, nNodes + 3, sizeof(RF_DagNode_t), (RF_DagNode_t *), alloclist);
+ RF_MallocAndAdd(nodes, (nNodes + 3) * sizeof(RF_DagNode_t),
+ (RF_DagNode_t *), alloclist);
blockNode = &nodes[nNodes];
unblockNode = blockNode + 1;
termNode = unblockNode + 1;
diff --git a/sys/dev/raidframe/rf_psstatus.c b/sys/dev/raidframe/rf_psstatus.c
index 8eba73d5846..4edabc14901 100644
--- a/sys/dev/raidframe/rf_psstatus.c
+++ b/sys/dev/raidframe/rf_psstatus.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_psstatus.c,v 1.15 2003/12/29 02:38:18 oster Exp $ */
+/* $NetBSD: rf_psstatus.c,v 1.16 2003/12/29 03:33:48 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -37,14 +37,13 @@
*****************************************************************************/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_psstatus.c,v 1.15 2003/12/29 02:38:18 oster Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_psstatus.c,v 1.16 2003/12/29 03:33:48 oster Exp $");
#include <dev/raidframe/raidframevar.h>
#include "rf_raid.h"
#include "rf_general.h"
#include "rf_debugprint.h"
-#include "rf_freelist.h"
#include "rf_psstatus.h"
#include "rf_shutdown.h"
@@ -116,7 +115,9 @@ rf_MakeParityStripeStatusTable(raidPtr)
RF_PSStatusHeader_t *pssTable;
int i, j, rc;
- RF_Calloc(pssTable, raidPtr->pssTableSize, sizeof(RF_PSStatusHeader_t), (RF_PSStatusHeader_t *));
+ RF_Malloc(pssTable,
+ raidPtr->pssTableSize * sizeof(RF_PSStatusHeader_t),
+ (RF_PSStatusHeader_t *));
for (i = 0; i < raidPtr->pssTableSize; i++) {
rc = rf_mutex_init(&pssTable[i].mutex);
if (rc) {
@@ -294,8 +295,8 @@ rf_AllocPSStatus(raidPtr)
{
RF_ReconParityStripeStatus_t *p;
- p = pool_get(&raidPtr->pss_pool, PR_NOWAIT);
- p->issued = pool_get(&raidPtr->pss_issued_pool, PR_NOWAIT);
+ p = pool_get(&raidPtr->pss_pool, PR_WAITOK);
+ p->issued = pool_get(&raidPtr->pss_issued_pool, PR_WAITOK);
memset(p->issued, 0, raidPtr->numCol);
p->next = NULL;
/* no need to initialize here b/c the only place we're called from is
diff --git a/sys/dev/raidframe/rf_reconmap.c b/sys/dev/raidframe/rf_reconmap.c
index 942f1512f54..9f2e7a9cdea 100644
--- a/sys/dev/raidframe/rf_reconmap.c
+++ b/sys/dev/raidframe/rf_reconmap.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_reconmap.c,v 1.18 2003/12/29 02:38:18 oster Exp $ */
+/* $NetBSD: rf_reconmap.c,v 1.19 2003/12/29 03:33:48 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -34,7 +34,7 @@
*************************************************************************/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_reconmap.c,v 1.18 2003/12/29 02:38:18 oster Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_reconmap.c,v 1.19 2003/12/29 03:33:48 oster Exp $");
#include "rf_raid.h"
#include <sys/time.h>
@@ -260,7 +260,7 @@ MakeReconMapListElem(
{
RF_ReconMapListElem_t *p;
- p = pool_get(&mapPtr->elem_pool, PR_NOWAIT);
+ p = pool_get(&mapPtr->elem_pool, PR_WAITOK);
if (p == NULL)
return (NULL);
diff --git a/sys/dev/raidframe/rf_reconstruct.c b/sys/dev/raidframe/rf_reconstruct.c
index 5cb1b107f40..7f1e23cedaa 100644
--- a/sys/dev/raidframe/rf_reconstruct.c
+++ b/sys/dev/raidframe/rf_reconstruct.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_reconstruct.c,v 1.57 2003/12/29 02:38:18 oster Exp $ */
+/* $NetBSD: rf_reconstruct.c,v 1.58 2003/12/29 03:33:48 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -33,7 +33,7 @@
************************************************************/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_reconstruct.c,v 1.57 2003/12/29 02:38:18 oster Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_reconstruct.c,v 1.58 2003/12/29 03:33:48 oster Exp $");
#include <sys/time.h>
#include <sys/buf.h>
@@ -57,7 +57,6 @@ __KERNEL_RCSID(0, "$NetBSD: rf_reconstruct.c,v 1.57 2003/12/29 02:38:18 oster Ex
#include "rf_desc.h"
#include "rf_debugprint.h"
#include "rf_general.h"
-#include "rf_freelist.h"
#include "rf_driver.h"
#include "rf_utils.h"
#include "rf_shutdown.h"
@@ -96,7 +95,7 @@ __KERNEL_RCSID(0, "$NetBSD: rf_reconstruct.c,v 1.57 2003/12/29 02:38:18 oster Ex
#endif /* RF_DEBUG_RECON */
-static RF_FreeList_t *rf_recond_freelist;
+static struct pool rf_recond_pool;
#define RF_MAX_FREE_RECOND 4
#define RF_RECOND_INC 1
@@ -139,10 +138,6 @@ struct RF_ReconDoneProc_s {
RF_ReconDoneProc_t *next;
};
-static RF_FreeList_t *rf_rdp_freelist;
-#define RF_MAX_FREE_RDP 4
-#define RF_RDP_INC 1
-
static void
SignalReconDone(RF_Raid_t * raidPtr)
{
@@ -168,8 +163,7 @@ static void
rf_ShutdownReconstruction(ignored)
void *ignored;
{
- RF_FREELIST_DESTROY(rf_recond_freelist, next, (RF_RaidReconDesc_t *));
- RF_FREELIST_DESTROY(rf_rdp_freelist, next, (RF_ReconDoneProc_t *));
+ pool_destroy(&rf_recond_pool);
}
int
@@ -178,16 +172,8 @@ rf_ConfigureReconstruction(listp)
{
int rc;
- RF_FREELIST_CREATE(rf_recond_freelist, RF_MAX_FREE_RECOND,
- RF_RECOND_INC, sizeof(RF_RaidReconDesc_t));
- if (rf_recond_freelist == NULL)
- return (ENOMEM);
- RF_FREELIST_CREATE(rf_rdp_freelist, RF_MAX_FREE_RDP,
- RF_RDP_INC, sizeof(RF_ReconDoneProc_t));
- if (rf_rdp_freelist == NULL) {
- RF_FREELIST_DESTROY(rf_recond_freelist, next, (RF_RaidReconDesc_t *));
- return (ENOMEM);
- }
+ pool_init(&rf_recond_pool, sizeof(RF_RaidReconDesc_t), 0, 0, 0,
+ "rf_recond_pl", NULL);
rc = rf_ShutdownCreate(listp, rf_ShutdownReconstruction, NULL);
if (rc) {
rf_print_unable_to_add_shutdown(__FILE__, __LINE__, rc);
@@ -208,7 +194,7 @@ AllocRaidReconDesc(raidPtr, col, spareDiskPtr, numDisksDone, scol)
RF_RaidReconDesc_t *reconDesc;
- RF_FREELIST_GET(rf_recond_freelist, reconDesc, next, (RF_RaidReconDesc_t *));
+ reconDesc = pool_get(&rf_recond_pool, PR_WAITOK); /* XXX WAITOK?? */
reconDesc->raidPtr = raidPtr;
reconDesc->col = col;
@@ -237,7 +223,7 @@ FreeReconDesc(reconDesc)
#if (RF_RECON_STATS > 0) || defined(KERNEL)
printf("\n");
#endif /* (RF_RECON_STATS > 0) || KERNEL */
- RF_FREELIST_FREE(rf_recond_freelist, reconDesc, next);
+ pool_put(&rf_recond_pool, reconDesc);
}
diff --git a/sys/dev/raidframe/rf_reconutil.c b/sys/dev/raidframe/rf_reconutil.c
index 743b05c3c33..7e440ae210c 100644
--- a/sys/dev/raidframe/rf_reconutil.c
+++ b/sys/dev/raidframe/rf_reconutil.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_reconutil.c,v 1.15 2003/12/29 02:38:18 oster Exp $ */
+/* $NetBSD: rf_reconutil.c,v 1.16 2003/12/29 03:33:48 oster 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.15 2003/12/29 02:38:18 oster Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_reconutil.c,v 1.16 2003/12/29 03:33:48 oster Exp $");
#include <dev/raidframe/raidframevar.h>
@@ -71,10 +71,10 @@ rf_MakeReconControl(reconDesc, fcol, scol)
/* make and zero the global reconstruction structure and the per-disk
* structure */
- RF_Calloc(reconCtrlPtr, 1, sizeof(RF_ReconCtrl_t), (RF_ReconCtrl_t *));
+ RF_Malloc(reconCtrlPtr, sizeof(RF_ReconCtrl_t), (RF_ReconCtrl_t *));
/* note: this zeros the perDiskInfo */
- RF_Calloc(reconCtrlPtr->perDiskInfo, raidPtr->numCol,
+ RF_Malloc(reconCtrlPtr->perDiskInfo, raidPtr->numCol *
sizeof(RF_PerDiskReconCtrl_t), (RF_PerDiskReconCtrl_t *));
reconCtrlPtr->reconDesc = reconDesc;
reconCtrlPtr->fcol = fcol;
diff --git a/sys/dev/raidframe/rf_revent.c b/sys/dev/raidframe/rf_revent.c
index 4ad3c3bda87..2de74d15f7e 100644
--- a/sys/dev/raidframe/rf_revent.c
+++ b/sys/dev/raidframe/rf_revent.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_revent.c,v 1.12 2003/12/29 02:38:18 oster Exp $ */
+/* $NetBSD: rf_revent.c,v 1.13 2003/12/29 03:33:48 oster 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.12 2003/12/29 02:38:18 oster Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_revent.c,v 1.13 2003/12/29 03:33:48 oster Exp $");
#include <sys/errno.h>
@@ -38,11 +38,10 @@ __KERNEL_RCSID(0, "$NetBSD: rf_revent.c,v 1.12 2003/12/29 02:38:18 oster Exp $")
#include "rf_revent.h"
#include "rf_etimer.h"
#include "rf_general.h"
-#include "rf_freelist.h"
#include "rf_desc.h"
#include "rf_shutdown.h"
-static RF_FreeList_t *rf_revent_freelist;
+static struct pool rf_revent_pool;
#define RF_MAX_FREE_REVENT 128
#define RF_REVENT_INC 8
#define RF_REVENT_INITIAL 8
@@ -67,7 +66,7 @@ GetReconEventDesc(RF_RowCol_t col, void *arg, RF_Revent_t type);
static void rf_ShutdownReconEvent(ignored)
void *ignored;
{
- RF_FREELIST_DESTROY(rf_revent_freelist, next, (RF_ReconEvent_t *));
+ pool_destroy(&rf_revent_pool);
}
int
@@ -76,18 +75,18 @@ rf_ConfigureReconEvent(listp)
{
int rc;
- RF_FREELIST_CREATE(rf_revent_freelist, RF_MAX_FREE_REVENT,
- RF_REVENT_INC, sizeof(RF_ReconEvent_t));
- if (rf_revent_freelist == NULL)
- return (ENOMEM);
+ pool_init(&rf_revent_pool, sizeof(RF_ReconEvent_t),
+ 0, 0, 0, "rf_revent_pl", NULL);
+ pool_sethiwat(&rf_revent_pool, RF_MAX_FREE_REVENT);
+ pool_prime(&rf_revent_pool, RF_REVENT_INITIAL);
+
rc = rf_ShutdownCreate(listp, rf_ShutdownReconEvent, NULL);
if (rc) {
rf_print_unable_to_add_shutdown(__FILE__, __LINE__, rc);
rf_ShutdownReconEvent(NULL);
return (rc);
}
- RF_FREELIST_PRIME(rf_revent_freelist, RF_REVENT_INITIAL, next,
- (RF_ReconEvent_t *));
+
return (0);
}
@@ -206,12 +205,13 @@ GetReconEventDesc(col, arg, type)
{
RF_ReconEvent_t *t;
- RF_FREELIST_GET(rf_revent_freelist, t, next, (RF_ReconEvent_t *));
+ t = pool_get(&rf_revent_pool, PR_WAITOK);
if (t == NULL)
return (NULL);
t->col = col;
t->arg = arg;
t->type = type;
+ t->next = NULL;
return (t);
}
@@ -219,5 +219,5 @@ void
rf_FreeReconEventDesc(event)
RF_ReconEvent_t *event;
{
- RF_FREELIST_FREE(rf_revent_freelist, event, next);
+ pool_put(&rf_revent_pool, event);
}
diff --git a/sys/dev/raidframe/rf_shutdown.c b/sys/dev/raidframe/rf_shutdown.c
index 82dbbef4b57..4b2ee30f465 100644
--- a/sys/dev/raidframe/rf_shutdown.c
+++ b/sys/dev/raidframe/rf_shutdown.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_shutdown.c,v 1.13 2002/09/23 03:42:50 oster Exp $ */
+/* $NetBSD: rf_shutdown.c,v 1.14 2003/12/29 03:33:48 oster Exp $ */
/*
* rf_shutdown.c
*/
@@ -34,13 +34,13 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_shutdown.c,v 1.13 2002/09/23 03:42:50 oster Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_shutdown.c,v 1.14 2003/12/29 03:33:48 oster Exp $");
#include <dev/raidframe/raidframevar.h>
#include "rf_archs.h"
#include "rf_shutdown.h"
-#include "rf_freelist.h"
+#include "rf_debugMem.h"
#ifndef RF_DEBUG_SHUTDOWN
diff --git a/sys/dev/raidframe/rf_sstf.c b/sys/dev/raidframe/rf_sstf.c
index 75eb1537023..b96c701ea60 100644
--- a/sys/dev/raidframe/rf_sstf.c
+++ b/sys/dev/raidframe/rf_sstf.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_sstf.c,v 1.9 2002/09/17 03:43:34 oster Exp $ */
+/* $NetBSD: rf_sstf.c,v 1.10 2003/12/29 03:33:48 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -33,7 +33,7 @@
******************************************************************************/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_sstf.c,v 1.9 2002/09/17 03:43:34 oster Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_sstf.c,v 1.10 2003/12/29 03:33:48 oster Exp $");
#include <dev/raidframe/raidframevar.h>
@@ -253,7 +253,7 @@ rf_SstfCreate(sect_per_disk, cl_list, listp)
{
RF_Sstf_t *sstfq;
- RF_CallocAndAdd(sstfq, 1, sizeof(RF_Sstf_t), (RF_Sstf_t *), cl_list);
+ RF_MallocAndAdd(sstfq, sizeof(RF_Sstf_t), (RF_Sstf_t *), cl_list);
sstfq->dir = DIR_EITHER;
sstfq->allow_reverse = 1;
return ((void *) sstfq);
@@ -267,7 +267,7 @@ rf_ScanCreate(sect_per_disk, cl_list, listp)
{
RF_Sstf_t *scanq;
- RF_CallocAndAdd(scanq, 1, sizeof(RF_Sstf_t), (RF_Sstf_t *), cl_list);
+ RF_MallocAndAdd(scanq, sizeof(RF_Sstf_t), (RF_Sstf_t *), cl_list);
scanq->dir = DIR_RIGHT;
scanq->allow_reverse = 1;
return ((void *) scanq);
@@ -281,7 +281,7 @@ rf_CscanCreate(sect_per_disk, cl_list, listp)
{
RF_Sstf_t *cscanq;
- RF_CallocAndAdd(cscanq, 1, sizeof(RF_Sstf_t), (RF_Sstf_t *), cl_list);
+ RF_MallocAndAdd(cscanq, sizeof(RF_Sstf_t), (RF_Sstf_t *), cl_list);
cscanq->dir = DIR_RIGHT;
return ((void *) cscanq);
}
diff --git a/sys/dev/raidframe/rf_stripelocks.c b/sys/dev/raidframe/rf_stripelocks.c
index 07a76cb186f..68f7a611e8e 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.16 2003/04/10 04:10:17 simonb Exp $ */
+/* $NetBSD: rf_stripelocks.c,v 1.17 2003/12/29 03:33:48 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -57,7 +57,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_stripelocks.c,v 1.16 2003/04/10 04:10:17 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_stripelocks.c,v 1.17 2003/12/29 03:33:48 oster Exp $");
#include <dev/raidframe/raidframevar.h>
@@ -66,7 +66,6 @@ __KERNEL_RCSID(0, "$NetBSD: rf_stripelocks.c,v 1.16 2003/04/10 04:10:17 simonb E
#include "rf_alloclist.h"
#include "rf_debugprint.h"
#include "rf_general.h"
-#include "rf_freelist.h"
#include "rf_driver.h"
#include "rf_shutdown.h"
@@ -132,7 +131,7 @@ static void PrintLockedStripes(RF_LockTableEntry_t * lockTable);
) \
)
-static RF_FreeList_t *rf_stripelock_freelist;
+static struct pool rf_stripelock_pool;
#define RF_MAX_FREE_STRIPELOCK 128
#define RF_STRIPELOCK_INC 8
#define RF_STRIPELOCK_INITIAL 32
@@ -145,7 +144,7 @@ static void
rf_ShutdownStripeLockFreeList(ignored)
void *ignored;
{
- RF_FREELIST_DESTROY(rf_stripelock_freelist, next, (RF_StripeLockDesc_t *));
+ pool_destroy(&rf_stripelock_pool);
}
int
@@ -155,16 +154,18 @@ rf_ConfigureStripeLockFreeList(listp)
unsigned mask;
int rc;
- RF_FREELIST_CREATE(rf_stripelock_freelist, RF_MAX_FREE_STRIPELOCK,
- RF_STRIPELOCK_INITIAL, sizeof(RF_StripeLockDesc_t));
+ pool_init(&rf_stripelock_pool, sizeof(RF_StripeLockDesc_t),
+ 0, 0, 0, "rf_stripelock_pl", NULL);
+ pool_sethiwat(&rf_stripelock_pool, RF_MAX_FREE_STRIPELOCK);
+ pool_prime(&rf_stripelock_pool, RF_STRIPELOCK_INITIAL);
+
rc = rf_ShutdownCreate(listp, rf_ShutdownStripeLockFreeList, NULL);
if (rc) {
rf_print_unable_to_add_shutdown(__FILE__, __LINE__, rc);
rf_ShutdownStripeLockFreeList(NULL);
return (rc);
}
- RF_FREELIST_PRIME(rf_stripelock_freelist, RF_STRIPELOCK_INITIAL, next,
- (RF_StripeLockDesc_t *));
+
for (mask = 0x1; mask; mask <<= 1)
if (rf_lockTableSize == mask)
break;
@@ -181,7 +182,9 @@ rf_MakeLockTable()
RF_LockTableEntry_t *lockTable;
int i, rc;
- RF_Calloc(lockTable, ((int) rf_lockTableSize), sizeof(RF_LockTableEntry_t), (RF_LockTableEntry_t *));
+ RF_Malloc(lockTable,
+ ((int) rf_lockTableSize) * sizeof(RF_LockTableEntry_t),
+ (RF_LockTableEntry_t *));
if (lockTable == NULL)
return (NULL);
for (i = 0; i < rf_lockTableSize; i++) {
@@ -627,9 +630,14 @@ AllocStripeLockDesc(RF_StripeNum_t stripeID)
{
RF_StripeLockDesc_t *p;
- RF_FREELIST_GET(rf_stripelock_freelist, p, next, (RF_StripeLockDesc_t *));
+ p = pool_get(&rf_stripelock_pool, PR_WAITOK);
if (p) {
p->stripeID = stripeID;
+ p->granted = NULL;
+ p->waitersH = NULL;
+ p->waitersT = NULL;
+ p->nWriters = 0;
+ p->next = NULL;
}
return (p);
}
@@ -637,7 +645,7 @@ AllocStripeLockDesc(RF_StripeNum_t stripeID)
static void
FreeStripeLockDesc(RF_StripeLockDesc_t * p)
{
- RF_FREELIST_FREE(rf_stripelock_freelist, p, next);
+ pool_put(&rf_stripelock_pool, p);
}
#if RF_DEBUG_STRIPELOCK