poolify the allocation of Parity Stripe Status structures.
XXX: Current code may have problems if kernel memory is completely depleted. This is, unfortunately, not the only chunk of RAIDframe code to have this problem, and will have to be dealt with. :(
This commit is contained in:
parent
18084f090a
commit
9401ec32c0
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: rf_psstatus.c,v 1.10 2002/09/19 22:52:52 oster Exp $ */
|
||||
/* $NetBSD: rf_psstatus.c,v 1.11 2002/10/11 02:10:09 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.10 2002/09/19 22:52:52 oster Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: rf_psstatus.c,v 1.11 2002/10/11 02:10:09 oster Exp $");
|
||||
|
||||
#include <dev/raidframe/raidframevar.h>
|
||||
|
||||
@ -66,36 +66,16 @@ RealPrintPSStatusTable(RF_Raid_t * raidPtr,
|
||||
#define RF_PSS_INC 8
|
||||
#define RF_PSS_INITIAL 4
|
||||
|
||||
static int init_pss(RF_ReconParityStripeStatus_t *, RF_Raid_t *);
|
||||
static void clean_pss(RF_ReconParityStripeStatus_t *, RF_Raid_t *);
|
||||
static void rf_ShutdownPSStatus(void *);
|
||||
|
||||
static int
|
||||
init_pss(p, raidPtr)
|
||||
RF_ReconParityStripeStatus_t *p;
|
||||
RF_Raid_t *raidPtr;
|
||||
{
|
||||
RF_Calloc(p->issued, raidPtr->numCol, sizeof(char), (char *));
|
||||
if (p->issued == NULL)
|
||||
return (ENOMEM);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static void
|
||||
clean_pss(p, raidPtr)
|
||||
RF_ReconParityStripeStatus_t *p;
|
||||
RF_Raid_t *raidPtr;
|
||||
{
|
||||
RF_Free(p->issued, raidPtr->numCol * sizeof(char));
|
||||
}
|
||||
|
||||
static void
|
||||
rf_ShutdownPSStatus(arg)
|
||||
void *arg;
|
||||
{
|
||||
RF_Raid_t *raidPtr = (RF_Raid_t *) arg;
|
||||
|
||||
RF_FREELIST_DESTROY_CLEAN_ARG(raidPtr->pss_freelist, next, (RF_ReconParityStripeStatus_t *), clean_pss, raidPtr);
|
||||
pool_destroy(&raidPtr->pss_pool);
|
||||
pool_destroy(&raidPtr->pss_issued_pool);
|
||||
}
|
||||
|
||||
int
|
||||
@ -107,18 +87,20 @@ rf_ConfigurePSStatus(
|
||||
int rc;
|
||||
|
||||
raidPtr->pssTableSize = RF_PSS_DEFAULT_TABLESIZE;
|
||||
RF_FREELIST_CREATE(raidPtr->pss_freelist, RF_MAX_FREE_PSS,
|
||||
RF_PSS_INC, sizeof(RF_ReconParityStripeStatus_t));
|
||||
if (raidPtr->pss_freelist == NULL)
|
||||
return (ENOMEM);
|
||||
pool_init(&raidPtr->pss_pool, sizeof(RF_ReconParityStripeStatus_t), 0,
|
||||
0, RF_PSS_INITIAL, "raidpsspl", NULL);
|
||||
pool_init(&raidPtr->pss_issued_pool,
|
||||
raidPtr->numCol * sizeof(char), 0,
|
||||
0, RF_PSS_INITIAL, "raidpssissuedpl", NULL);
|
||||
rc = rf_ShutdownCreate(listp, rf_ShutdownPSStatus, raidPtr);
|
||||
if (rc) {
|
||||
rf_print_unable_to_add_shutdown(__FILE__, __LINE__, rc);
|
||||
rf_ShutdownPSStatus(raidPtr);
|
||||
return (rc);
|
||||
}
|
||||
RF_FREELIST_PRIME_INIT_ARG(raidPtr->pss_freelist, RF_PSS_INITIAL, next,
|
||||
(RF_ReconParityStripeStatus_t *), init_pss, raidPtr);
|
||||
pool_sethiwat(&raidPtr->pss_pool, RF_MAX_FREE_PSS);
|
||||
pool_sethiwat(&raidPtr->pss_issued_pool, RF_MAX_FREE_PSS);
|
||||
|
||||
return (0);
|
||||
}
|
||||
/*****************************************************************************************
|
||||
@ -311,10 +293,9 @@ rf_AllocPSStatus(raidPtr)
|
||||
{
|
||||
RF_ReconParityStripeStatus_t *p;
|
||||
|
||||
RF_FREELIST_GET_INIT_ARG(raidPtr->pss_freelist, p, next, (RF_ReconParityStripeStatus_t *), init_pss, raidPtr);
|
||||
if (p) {
|
||||
memset(p->issued, 0, raidPtr->numCol);
|
||||
}
|
||||
p = pool_get(&raidPtr->pss_pool, PR_NOWAIT);
|
||||
p->issued = pool_get(&raidPtr->pss_issued_pool, PR_NOWAIT);
|
||||
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 */
|
||||
@ -330,7 +311,8 @@ rf_FreePSStatus(raidPtr, p)
|
||||
RF_ASSERT(p->blockWaitList == NULL);
|
||||
RF_ASSERT(p->bufWaitList == NULL);
|
||||
|
||||
RF_FREELIST_FREE_CLEAN_ARG(raidPtr->pss_freelist, p, next, clean_pss, raidPtr);
|
||||
pool_put(&raidPtr->pss_issued_pool, p->issued);
|
||||
pool_put(&raidPtr->pss_pool, p);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: rf_raid.h,v 1.15 2002/10/04 20:05:14 oster Exp $ */
|
||||
/* $NetBSD: rf_raid.h,v 1.16 2002/10/11 02:10:08 oster Exp $ */
|
||||
/*
|
||||
* Copyright (c) 1995 Carnegie-Mellon University.
|
||||
* All rights reserved.
|
||||
@ -229,8 +229,9 @@ struct RF_Raid_s {
|
||||
/*
|
||||
* PSS (Parity Stripe Status) stuff
|
||||
*/
|
||||
RF_FreeList_t *pss_freelist;
|
||||
long pssTableSize;
|
||||
struct pool pss_pool;
|
||||
struct pool pss_issued_pool;
|
||||
|
||||
/*
|
||||
* Reconstruction stuff
|
||||
|
Loading…
Reference in New Issue
Block a user