summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authoroster <oster@NetBSD.org>2004-03-03 00:45:20 +0000
committeroster <oster@NetBSD.org>2004-03-03 00:45:20 +0000
commitb3eae139ebdb18e085ce4d8df8a08940836f75f3 (patch)
tree05b21e0fb72ca14b88a5414dca15244b89b6cd49 /sys/dev
parent65e1a3b11271a2d8bdfd3b6969afb554dfe660d8 (diff)
- cleanup memory allocation in rf_AllocPSStatus()
- change function signature of rf_LookupRUStatus(). The last argument is now a pointer to a new PSS, in case one is needed. Rather than having rf_LookupRUStatus() allocate a new PSS, we pre-allocate one beforehand, where necessary, just in case. - change callers of rf_lookupRUStatus() to deal with the new way of calling rf_lookupRUStatus(). [no improvement or worsening of parity rebuild/initialization performance.]
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/raidframe/rf_psstatus.c15
-rw-r--r--sys/dev/raidframe/rf_psstatus.h5
-rw-r--r--sys/dev/raidframe/rf_raid1.c9
-rw-r--r--sys/dev/raidframe/rf_reconbuffer.c8
-rw-r--r--sys/dev/raidframe/rf_reconstruct.c36
5 files changed, 41 insertions, 32 deletions
diff --git a/sys/dev/raidframe/rf_psstatus.c b/sys/dev/raidframe/rf_psstatus.c
index 61f09ee4b20..29b4dd0e94e 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.21 2004/02/29 04:03:50 oster Exp $ */
+/* $NetBSD: rf_psstatus.c,v 1.22 2004/03/03 00:45:20 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -37,7 +37,7 @@
*****************************************************************************/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_psstatus.c,v 1.21 2004/02/29 04:03:50 oster Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_psstatus.c,v 1.22 2004/03/03 00:45:20 oster Exp $");
#include <dev/raidframe/raidframevar.h>
@@ -147,20 +147,18 @@ rf_FreeParityStripeStatusTable(RF_Raid_t *raidPtr,
RF_ReconParityStripeStatus_t *
rf_LookupRUStatus(RF_Raid_t *raidPtr, RF_PSStatusHeader_t *pssTable,
RF_StripeNum_t psID, RF_ReconUnitNum_t which_ru,
- RF_PSSFlags_t flags, int *created)
+ RF_PSSFlags_t flags, RF_ReconParityStripeStatus_t *newpssPtr)
{
RF_PSStatusHeader_t *hdr = &pssTable[RF_HASH_PSID(raidPtr, psID)];
RF_ReconParityStripeStatus_t *p, *pssPtr = hdr->chain;
- *created = 0;
for (p = pssPtr; p; p = p->next) {
if (p->parityStripeID == psID && p->which_ru == which_ru)
break;
}
if (!p && (flags & RF_PSS_CREATE)) {
- Dprintf2("PSS: creating pss for psid %ld ru %d\n", psID, which_ru);
- p = rf_AllocPSStatus(raidPtr);
+ p = newpssPtr;
p->next = hdr->chain;
hdr->chain = p;
@@ -174,7 +172,6 @@ rf_LookupRUStatus(RF_Raid_t *raidPtr, RF_PSStatusHeader_t *pssTable,
p->procWaitList = NULL;
p->blockWaitList = NULL;
p->bufWaitList = NULL;
- *created = 1;
} else
if (p) { /* we didn't create, but we want to specify
* some new status */
@@ -270,11 +267,9 @@ rf_AllocPSStatus(RF_Raid_t *raidPtr)
RF_ReconParityStripeStatus_t *p;
p = pool_get(&raidPtr->pss_pool, PR_WAITOK);
+ memset(p, 0, sizeof(RF_ReconParityStripeStatus_t));
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
- * the above Lookup */
return (p);
}
diff --git a/sys/dev/raidframe/rf_psstatus.h b/sys/dev/raidframe/rf_psstatus.h
index 190e300671d..1b4f480bb54 100644
--- a/sys/dev/raidframe/rf_psstatus.h
+++ b/sys/dev/raidframe/rf_psstatus.h
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_psstatus.h,v 1.5 2003/12/29 02:38:18 oster Exp $ */
+/* $NetBSD: rf_psstatus.h,v 1.6 2004/03/03 00:45:20 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -118,7 +118,8 @@ rf_FreeParityStripeStatusTable(RF_Raid_t * raidPtr,
RF_ReconParityStripeStatus_t *
rf_LookupRUStatus(RF_Raid_t * raidPtr,
RF_PSStatusHeader_t * pssTable, RF_StripeNum_t psID,
- RF_ReconUnitNum_t which_ru, RF_PSSFlags_t flags, int *created);
+ RF_ReconUnitNum_t which_ru, RF_PSSFlags_t flags,
+ RF_ReconParityStripeStatus_t *newpssPtr);
void
rf_PSStatusDelete(RF_Raid_t * raidPtr, RF_PSStatusHeader_t * pssTable,
RF_ReconParityStripeStatus_t * pssPtr);
diff --git a/sys/dev/raidframe/rf_raid1.c b/sys/dev/raidframe/rf_raid1.c
index fe48d1b9cf5..cab6c63047e 100644
--- a/sys/dev/raidframe/rf_raid1.c
+++ b/sys/dev/raidframe/rf_raid1.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_raid1.c,v 1.20 2004/03/02 15:47:35 oster Exp $ */
+/* $NetBSD: rf_raid1.c,v 1.21 2004/03/03 00:45:20 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -33,7 +33,7 @@
*****************************************************************************/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_raid1.c,v 1.20 2004/03/02 15:47:35 oster Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_raid1.c,v 1.21 2004/03/03 00:45:20 oster Exp $");
#include "rf_raid.h"
#include "rf_raid1.h"
@@ -543,14 +543,13 @@ rf_SubmitReconBufferRAID1(RF_ReconBuffer_t *rbuf, int keep_it,
{
RF_ReconParityStripeStatus_t *pssPtr;
RF_ReconCtrl_t *reconCtrlPtr;
- int retcode, created;
+ int retcode;
RF_CallbackDesc_t *cb, *p;
RF_ReconBuffer_t *t;
RF_Raid_t *raidPtr;
caddr_t ta;
retcode = 0;
- created = 0;
raidPtr = rbuf->raidPtr;
reconCtrlPtr = raidPtr->reconControl;
@@ -579,7 +578,7 @@ rf_SubmitReconBufferRAID1(RF_ReconBuffer_t *rbuf, int keep_it,
RF_LOCK_MUTEX(reconCtrlPtr->rb_mutex);
pssPtr = rf_LookupRUStatus(raidPtr, reconCtrlPtr->pssTable,
- rbuf->parityStripeID, rbuf->which_ru, RF_PSS_NONE, &created);
+ rbuf->parityStripeID, rbuf->which_ru, RF_PSS_NONE, NULL);
RF_ASSERT(pssPtr); /* if it didn't exist, we wouldn't have gotten
* an rbuf for it */
diff --git a/sys/dev/raidframe/rf_reconbuffer.c b/sys/dev/raidframe/rf_reconbuffer.c
index 45a48695633..1d701d4b8db 100644
--- a/sys/dev/raidframe/rf_reconbuffer.c
+++ b/sys/dev/raidframe/rf_reconbuffer.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_reconbuffer.c,v 1.18 2004/03/01 23:30:58 oster Exp $ */
+/* $NetBSD: rf_reconbuffer.c,v 1.19 2004/03/03 00:45:20 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -33,7 +33,7 @@
***************************************************/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_reconbuffer.c,v 1.18 2004/03/01 23:30:58 oster Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_reconbuffer.c,v 1.19 2004/03/03 00:45:20 oster Exp $");
#include "rf_raid.h"
#include "rf_reconbuffer.h"
@@ -127,7 +127,7 @@ rf_SubmitReconBufferBasic(RF_ReconBuffer_t *rbuf, int keep_it,
* pointers */
caddr_t ta; /* temporary data buffer pointer */
RF_CallbackDesc_t *cb, *p;
- int retcode = 0, created = 0;
+ int retcode = 0;
RF_Etimer_t timer;
@@ -142,7 +142,7 @@ rf_SubmitReconBufferBasic(RF_ReconBuffer_t *rbuf, int keep_it,
RF_LOCK_MUTEX(reconCtrlPtr->rb_mutex);
- pssPtr = rf_LookupRUStatus(raidPtr, reconCtrlPtr->pssTable, rbuf->parityStripeID, rbuf->which_ru, RF_PSS_NONE, &created);
+ pssPtr = rf_LookupRUStatus(raidPtr, reconCtrlPtr->pssTable, rbuf->parityStripeID, rbuf->which_ru, RF_PSS_NONE, NULL);
RF_ASSERT(pssPtr); /* if it didn't exist, we wouldn't have gotten
* an rbuf for it */
diff --git a/sys/dev/raidframe/rf_reconstruct.c b/sys/dev/raidframe/rf_reconstruct.c
index e6f47178883..4220c36a033 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.67 2004/03/01 23:30:58 oster Exp $ */
+/* $NetBSD: rf_reconstruct.c,v 1.68 2004/03/03 00:45:20 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.67 2004/03/01 23:30:58 oster Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_reconstruct.c,v 1.68 2004/03/03 00:45:20 oster Exp $");
#include <sys/time.h>
#include <sys/buf.h>
@@ -973,15 +973,23 @@ TryToRead(RF_Raid_t *raidPtr, RF_RowCol_t col)
RF_StripeNum_t psid = ctrl->curPSID;
RF_ReconUnitNum_t which_ru = ctrl->ru_count;
RF_DiskQueueData_t *req;
- int status, created = 0;
- RF_ReconParityStripeStatus_t *pssPtr;
+ int status;
+ RF_ReconParityStripeStatus_t *pssPtr, *newpssPtr;
/* if the current disk is too far ahead of the others, issue a
* head-separation wait and return */
if (CheckHeadSeparation(raidPtr, ctrl, col, ctrl->headSepCounter, which_ru))
return (0);
+
+ /* allocate a new PSS in case we need it */
+ newpssPtr = rf_AllocPSStatus(raidPtr);
+
RF_LOCK_PSS_MUTEX(raidPtr, psid);
- pssPtr = rf_LookupRUStatus(raidPtr, raidPtr->reconControl->pssTable, psid, which_ru, RF_PSS_CREATE, &created);
+ pssPtr = rf_LookupRUStatus(raidPtr, raidPtr->reconControl->pssTable, psid, which_ru, RF_PSS_CREATE, newpssPtr);
+
+ if (pssPtr != newpssPtr) {
+ rf_FreePSStatus(raidPtr, newpssPtr);
+ }
/* if recon is blocked on the indicated parity stripe, issue a
* block-wait request and return. this also must mark the indicated RU
@@ -1004,7 +1012,7 @@ TryToRead(RF_Raid_t *raidPtr, RF_RowCol_t col)
* have just created a bogus status entry, which we need to delete. */
if (rf_CheckRUReconstructed(raidPtr->reconControl->reconMap, ctrl->rbuf->failedDiskSectorOffset)) {
Dprintf2("RECON: Skipping psid %ld ru %d: prior recon after stall\n", psid, which_ru);
- if (created)
+ if (pssPtr == newpssPtr)
rf_PSStatusDelete(raidPtr, raidPtr->reconControl->pssTable, pssPtr);
rf_CauseReconEvent(raidPtr, col, NULL, RF_REVENT_SKIP);
goto out;
@@ -1435,7 +1443,7 @@ rf_ForceOrBlockRecon(RF_Raid_t *raidPtr, RF_AccessStripeMap_t *asmap,
RF_StripeNum_t stripeID = asmap->stripeID; /* the stripe ID we're
* forcing recon on */
RF_SectorCount_t sectorsPerRU = raidPtr->Layout.sectorsPerStripeUnit * raidPtr->Layout.SUsPerRU; /* num sects in one RU */
- RF_ReconParityStripeStatus_t *pssPtr; /* a pointer to the parity
+ RF_ReconParityStripeStatus_t *pssPtr, *newpssPtr; /* a pointer to the parity
* stripe status structure */
RF_StripeNum_t psid; /* parity stripe id */
RF_SectorNum_t offset, fd_offset; /* disk offset, failed-disk
@@ -1446,13 +1454,20 @@ rf_ForceOrBlockRecon(RF_Raid_t *raidPtr, RF_AccessStripeMap_t *asmap,
RF_ReconBuffer_t *new_rbuf; /* ptr to newly allocated rbufs */
RF_DiskQueueData_t *req;/* disk I/O req to be enqueued */
RF_CallbackDesc_t *cb;
- int created = 0, nPromoted;
+ int nPromoted;
psid = rf_MapStripeIDToParityStripeID(&raidPtr->Layout, stripeID, &which_ru);
+ /* allocate a new PSS in case we need it */
+ newpssPtr = rf_AllocPSStatus(raidPtr);
+
RF_LOCK_PSS_MUTEX(raidPtr, psid);
- pssPtr = rf_LookupRUStatus(raidPtr, raidPtr->reconControl->pssTable, psid, which_ru, RF_PSS_CREATE | RF_PSS_RECON_BLOCKED, &created);
+ pssPtr = rf_LookupRUStatus(raidPtr, raidPtr->reconControl->pssTable, psid, which_ru, RF_PSS_CREATE | RF_PSS_RECON_BLOCKED, newpssPtr);
+
+ if (pssPtr != newpssPtr) {
+ rf_FreePSStatus(raidPtr, newpssPtr);
+ }
/* if recon is not ongoing on this PS, just return */
if (!(pssPtr->flags & RF_PSS_UNDER_RECON)) {
@@ -1557,12 +1572,11 @@ rf_UnblockRecon(RF_Raid_t *raidPtr, RF_AccessStripeMap_t *asmap)
RF_ReconParityStripeStatus_t *pssPtr;
RF_ReconUnitNum_t which_ru;
RF_StripeNum_t psid;
- int created = 0;
RF_CallbackDesc_t *cb;
psid = rf_MapStripeIDToParityStripeID(&raidPtr->Layout, stripeID, &which_ru);
RF_LOCK_PSS_MUTEX(raidPtr, psid);
- pssPtr = rf_LookupRUStatus(raidPtr, raidPtr->reconControl->pssTable, psid, which_ru, RF_PSS_NONE, &created);
+ pssPtr = rf_LookupRUStatus(raidPtr, raidPtr->reconControl->pssTable, psid, which_ru, RF_PSS_NONE, NULL);
/* When recon is forced, the pss desc can get deleted before we get
* back to unblock recon. But, this can _only_ happen when recon is