summaryrefslogtreecommitdiff
path: root/sys/dev/raidframe
diff options
context:
space:
mode:
authoroster <oster@NetBSD.org>2004-03-19 15:16:18 +0000
committeroster <oster@NetBSD.org>2004-03-19 15:16:18 +0000
commitb2c52e1175eac9a52a1598c990b557c22c458f84 (patch)
tree253fc2a2370a7ac5ae5758bc67fc823c8af64d43 /sys/dev/raidframe
parentd085bb26a1f12cec74f8382a8d09e92dcaeca07c (diff)
Take care of six more mallocs:
- Pull rf_FreePhysDiskAddr() out from under a #ifdef, since we're now going to use it. - Add a pda_cleanup_list into the DAG header. Use it in rf_FreeDAG() to cleanup any PDA's that get allocated but have no "easy" way of being located and freed when the DAG completes. - numStripeUnitsAccessed is a per-stripe value, and has a maximum value equal to the number of colums (thus limited by RF_MAXCOL). Use this knowledge to set a high-bound on overlappingPDAs, and stuff it on the stack instead of malloc'ing it all the time! This costs us a whopping 40 bytes on the stack, but saves a malloc() and a free().
Diffstat (limited to 'sys/dev/raidframe')
-rw-r--r--sys/dev/raidframe/rf_dag.h4
-rw-r--r--sys/dev/raidframe/rf_dagdegrd.c19
-rw-r--r--sys/dev/raidframe/rf_dagdegwr.c19
-rw-r--r--sys/dev/raidframe/rf_dagutils.c12
-rw-r--r--sys/dev/raidframe/rf_map.c6
5 files changed, 38 insertions, 22 deletions
diff --git a/sys/dev/raidframe/rf_dag.h b/sys/dev/raidframe/rf_dag.h
index 0cfa3960914..2a6dbbaf1d7 100644
--- a/sys/dev/raidframe/rf_dag.h
+++ b/sys/dev/raidframe/rf_dag.h
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_dag.h,v 1.12 2004/03/18 16:40:05 oster Exp $ */
+/* $NetBSD: rf_dag.h,v 1.13 2004/03/19 15:16:18 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -170,6 +170,8 @@ struct RF_DagHeader_s {
void *cbArg; /* argument for cbFunc */
char *creator; /* name of function used to create this dag */
RF_DagNode_t *nodes; /* linked list of nodes used in this DAG */
+ RF_PhysDiskAddr_t *pda_cleanup_list; /* for PDAs that can't get
+ cleaned up any other way... */
RF_Raid_t *raidPtr; /* the descriptor for the RAID device this DAG
* is for */
void *bp; /* the bp for this I/O passed down from the
diff --git a/sys/dev/raidframe/rf_dagdegrd.c b/sys/dev/raidframe/rf_dagdegrd.c
index 460de7eda52..a75ae355ae9 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.20 2004/03/18 16:40:05 oster Exp $ */
+/* $NetBSD: rf_dagdegrd.c,v 1.21 2004/03/19 15:16:18 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.20 2004/03/18 16:40:05 oster Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_dagdegrd.c,v 1.21 2004/03/19 15:16:18 oster Exp $");
#include <dev/raidframe/raidframevar.h>
@@ -45,6 +45,7 @@ __KERNEL_RCSID(0, "$NetBSD: rf_dagdegrd.c,v 1.20 2004/03/18 16:40:05 oster Exp $
#include "rf_debugMem.h"
#include "rf_general.h"
#include "rf_dagdegrd.h"
+#include "rf_map.h"
/******************************************************************************
@@ -271,7 +272,7 @@ rf_CreateDegradedReadDAG(RF_Raid_t *raidPtr, RF_AccessStripeMap_t *asmap,
int j, paramNum;
RF_SectorCount_t sectorsPerSU;
RF_ReconUnitNum_t which_ru;
- char *overlappingPDAs;/* a temporary array of flags */
+ char overlappingPDAs[RF_MAXCOL];/* a temporary array of flags */
RF_AccessStripeMapHeader_t *new_asm_h[2];
RF_PhysDiskAddr_t *pda, *parityPDA;
RF_StripeNum_t parityStripeID;
@@ -301,7 +302,7 @@ rf_CreateDegradedReadDAG(RF_Raid_t *raidPtr, RF_AccessStripeMap_t *asmap,
*/
/* overlappingPDAs array must be zero'd */
- RF_Malloc(overlappingPDAs, asmap->numStripeUnitsAccessed * sizeof(char), (char *));
+ memset(overlappingPDAs, 0, RF_MAXCOL);
rf_GenerateFailedAccessASMs(raidPtr, asmap, failedPDA, dag_h, new_asm_h, &nXorBufs,
&rpBuf, overlappingPDAs, allocList);
@@ -421,7 +422,9 @@ rf_CreateDegradedReadDAG(RF_Raid_t *raidPtr, RF_AccessStripeMap_t *asmap,
}
}
/* make a PDA for the parity unit */
- RF_MallocAndAdd(parityPDA, sizeof(RF_PhysDiskAddr_t), (RF_PhysDiskAddr_t *), allocList);
+ parityPDA = rf_AllocPhysDiskAddr();
+ parityPDA->next = dag_h->pda_cleanup_list;
+ dag_h->pda_cleanup_list = parityPDA;
parityPDA->col = asmap->parityInfo->col;
parityPDA->startSector = ((asmap->parityInfo->startSector / sectorsPerSU)
* sectorsPerSU) + (failedPDA->startSector % sectorsPerSU);
@@ -452,15 +455,17 @@ rf_CreateDegradedReadDAG(RF_Raid_t *raidPtr, RF_AccessStripeMap_t *asmap,
/* any Rud nodes that overlap the failed access need to be
* xored in */
if (overlappingPDAs[i]) {
- RF_MallocAndAdd(pda, sizeof(RF_PhysDiskAddr_t), (RF_PhysDiskAddr_t *), allocList);
+ pda = rf_AllocPhysDiskAddr();
memcpy((char *) pda, (char *) tmprudNode->params[0].p, sizeof(RF_PhysDiskAddr_t));
+ /* add it into the pda_cleanup_list *after* the copy, TYVM */
+ pda->next = dag_h->pda_cleanup_list;
+ dag_h->pda_cleanup_list = pda;
rf_RangeRestrictPDA(raidPtr, failedPDA, pda, RF_RESTRICT_DOBUFFER, 0);
xorNode->params[paramNum++].p = pda;
xorNode->params[paramNum++].p = pda->bufPtr;
}
tmprudNode = tmprudNode->list_next;
}
- RF_Free(overlappingPDAs, asmap->numStripeUnitsAccessed * sizeof(char));
/* install parity pda as last set of params to be xor'd */
xorNode->params[paramNum++].p = parityPDA;
diff --git a/sys/dev/raidframe/rf_dagdegwr.c b/sys/dev/raidframe/rf_dagdegwr.c
index a775b00ac5d..afb7f87108e 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.18 2004/03/18 16:40:05 oster Exp $ */
+/* $NetBSD: rf_dagdegwr.c,v 1.19 2004/03/19 15:16:18 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.18 2004/03/18 16:40:05 oster Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_dagdegwr.c,v 1.19 2004/03/19 15:16:18 oster Exp $");
#include <dev/raidframe/raidframevar.h>
@@ -45,6 +45,7 @@ __KERNEL_RCSID(0, "$NetBSD: rf_dagdegwr.c,v 1.18 2004/03/18 16:40:05 oster Exp $
#include "rf_debugMem.h"
#include "rf_general.h"
#include "rf_dagdegwr.h"
+#include "rf_map.h"
/******************************************************************************
@@ -169,7 +170,7 @@ rf_CommonCreateSimpleDegradedWriteDAG(RF_Raid_t *raidPtr,
RF_ReconUnitNum_t which_ru;
char *xorTargetBuf = NULL; /* the target buffer for the XOR
* operation */
- char *overlappingPDAs;/* a temporary array of flags */
+ char overlappingPDAs[RF_MAXCOL];/* a temporary array of flags */
RF_AccessStripeMapHeader_t *new_asm_h[2];
RF_PhysDiskAddr_t *pda, *parityPDA;
RF_StripeNum_t parityStripeID;
@@ -197,7 +198,7 @@ rf_CommonCreateSimpleDegradedWriteDAG(RF_Raid_t *raidPtr,
* we need in order to recover the lost data.
*/
/* overlappingPDAs array must be zero'd */
- RF_Malloc(overlappingPDAs, asmap->numStripeUnitsAccessed * sizeof(char), (char *));
+ memset(overlappingPDAs, 0, RF_MAXCOL);
rf_GenerateFailedAccessASMs(raidPtr, asmap, failedPDA, dag_h, new_asm_h,
&nXorBufs, NULL, overlappingPDAs, allocList);
@@ -358,7 +359,9 @@ rf_CommonCreateSimpleDegradedWriteDAG(RF_Raid_t *raidPtr,
* asmap->parityInfo describes the failed unit and the copy can also
* be avoided. */
- RF_MallocAndAdd(parityPDA, sizeof(RF_PhysDiskAddr_t), (RF_PhysDiskAddr_t *), allocList);
+ parityPDA = rf_AllocPhysDiskAddr();
+ parityPDA->next = dag_h->pda_cleanup_list;
+ dag_h->pda_cleanup_list = parityPDA;
parityPDA->col = asmap->parityInfo->col;
parityPDA->startSector = ((asmap->parityInfo->startSector / sectorsPerSU)
* sectorsPerSU) + (failedPDA->startSector % sectorsPerSU);
@@ -435,15 +438,17 @@ rf_CommonCreateSimpleDegradedWriteDAG(RF_Raid_t *raidPtr,
/* any Wnd nodes that overlap the failed access need to be
* xored in */
if (overlappingPDAs[i]) {
- RF_MallocAndAdd(pda, sizeof(RF_PhysDiskAddr_t), (RF_PhysDiskAddr_t *), allocList);
+ pda = rf_AllocPhysDiskAddr();
memcpy((char *) pda, (char *) tmpwndNode->params[0].p, sizeof(RF_PhysDiskAddr_t));
+ /* add it into the pda_cleanup_list *after* the copy, TYVM */
+ pda->next = dag_h->pda_cleanup_list;
+ dag_h->pda_cleanup_list = pda;
rf_RangeRestrictPDA(raidPtr, failedPDA, pda, RF_RESTRICT_DOBUFFER, 0);
xorNode->params[paramNum++].p = pda;
xorNode->params[paramNum++].p = pda->bufPtr;
}
tmpwndNode = tmpwndNode->list_next;
}
- RF_Free(overlappingPDAs, asmap->numStripeUnitsAccessed * sizeof(char));
/*
* Install the failed PDA into the xor param list so that the
diff --git a/sys/dev/raidframe/rf_dagutils.c b/sys/dev/raidframe/rf_dagutils.c
index 505aa29a192..71b06e51785 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.38 2004/03/18 16:40:05 oster Exp $ */
+/* $NetBSD: rf_dagutils.c,v 1.39 2004/03/19 15:16:18 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.38 2004/03/18 16:40:05 oster Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_dagutils.c,v 1.39 2004/03/19 15:16:18 oster Exp $");
#include <dev/raidframe/raidframevar.h>
@@ -155,6 +155,7 @@ void
rf_FreeDAG(RF_DagHeader_t *dag_h)
{
RF_AccessStripeMapHeader_t *asmap, *t_asmap;
+ RF_PhysDiskAddr_t *pda;
RF_DagNode_t *tmpnode;
RF_DagHeader_t *nextDag;
@@ -166,7 +167,12 @@ rf_FreeDAG(RF_DagHeader_t *dag_h)
asmap = asmap->next;
rf_FreeAccessStripeMap(t_asmap);
}
- while(dag_h->nodes) {
+ while (dag_h->pda_cleanup_list) {
+ pda = dag_h->pda_cleanup_list;
+ dag_h->pda_cleanup_list = dag_h->pda_cleanup_list->next;
+ rf_FreePhysDiskAddr(pda);
+ }
+ while (dag_h->nodes) {
tmpnode = dag_h->nodes;
dag_h->nodes = dag_h->nodes->list_next;
rf_FreeDAGNode(tmpnode);
diff --git a/sys/dev/raidframe/rf_map.c b/sys/dev/raidframe/rf_map.c
index cbaa07c545b..c40f557e632 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.35 2004/03/19 02:57:34 oster Exp $ */
+/* $NetBSD: rf_map.c,v 1.36 2004/03/19 15:16:18 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.35 2004/03/19 02:57:34 oster Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_map.c,v 1.36 2004/03/19 15:16:18 oster Exp $");
#include <dev/raidframe/raidframevar.h>
@@ -471,13 +471,11 @@ rf_AllocPDAList(int count)
return (p);
}
-#if RF_INCLUDE_PARITYLOGGING > 0
void
rf_FreePhysDiskAddr(RF_PhysDiskAddr_t *p)
{
pool_put(&rf_pools.pda, p);
}
-#endif
static void
rf_FreePDAList(RF_PhysDiskAddr_t *pda_list)