diff options
| author | oster <oster@NetBSD.org> | 2002-10-11 02:10:08 +0000 |
|---|---|---|
| committer | oster <oster@NetBSD.org> | 2002-10-11 02:10:08 +0000 |
| commit | 9401ec32c011791abef2ced99543b667e73301f9 (patch) | |
| tree | d7d7e658db8cab1336e85473f62c644d6b2a4a5c /sys/dev/raidframe | |
| parent | 18084f090a9efb9074cdc4b93f12d2df4a7b2145 (diff) | |
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. :(
Diffstat (limited to 'sys/dev/raidframe')
| -rw-r--r-- | sys/dev/raidframe/rf_psstatus.c | 52 | ||||
| -rw-r--r-- | sys/dev/raidframe/rf_raid.h | 5 |
2 files changed, 20 insertions, 37 deletions
diff --git a/sys/dev/raidframe/rf_psstatus.c b/sys/dev/raidframe/rf_psstatus.c index 6cc6537396f..bb2a5514d14 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.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 diff --git a/sys/dev/raidframe/rf_raid.h b/sys/dev/raidframe/rf_raid.h index 473aca767b1..b9f9ca56112 100644 --- a/sys/dev/raidframe/rf_raid.h +++ b/sys/dev/raidframe/rf_raid.h @@ -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 |
