NetBSD/sys/dev/raidframe/rf_desc.h

100 lines
3.6 KiB
C
Raw Normal View History

/* $NetBSD: rf_desc.h,v 1.14 2004/06/02 22:58:28 drochner Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
*
* Author: Mark Holland
*
* Permission to use, copy, modify and distribute this software and
* its documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*/
#ifndef _RF__RF_DESC_H_
#define _RF__RF_DESC_H_
#include <dev/raidframe/raidframevar.h>
#include "rf_archs.h"
#include "rf_etimer.h"
#include "rf_dag.h"
These changes complete the effective removal of malloc() from all write paths within RAIDframe. They also resolve the "panics with RAID 5 sets with more than 3 components" issue which was present (briefly) in the commits which were previously supposed to address the malloc() issue. With this new code the 5-component RAID 5 set panics are now gone. It is also now also possible to swap to RAID 5. The changes made are: 1) Introduce rf_AllocStripeBuffer() and rf_FreeStripeBuffer() to allocate/free one stripe's worth of space. rf_AllocStripeBuffer() is used in rf_MapUnaccessedPortionOfStripe() where it is not sufficient to allocate memory using just rf_AllocBuffer(). rf_FreeStripeBuffer() is called from rf_FreeRaidAccDesc(), well after the DAG is finished. 2) Add a set of emergency "stripe buffers" to struct RF_Raid_s. Arrange for their initialization in rf_Configure(). In low-memory situations these buffers will be returned by rf_AllocStripeBuffer() and re-populated by rf_FreeStripeBuffer(). 3) Move RF_VoidPointerListElem_t *iobufs from the dagHeader into into struct RF_RaidAccessDesc_s. This is more consistent with the original code, and will not result in items being freed "too early". 4) Add a RF_RaidAccessDesc_t *desc to RF_DagHeader_s so that we have a way to find desc->iobufs. 5) Arrange for desc in the DagHeader to be initialized in InitHdrNode(). 6) Don't cleanup iobufs in rf_FreeDAG() -- the freeing is now delayed until rf_FreeRaidAccDesc() (which is how the original code handled the allocList, and for which there seem to be some subtle, undocumented assumptions). 7) Rename rf_AllocBuffer2() to be rf_AllocBuffer() and remove the former rf_AllocBuffer(). Fix all callers of rf_AllocBuffer(). (This was how it was *supposed* to be after the last time these changes were made, before they were backed out). 8) Remove RF_IOBufHeader and all references to it. 9) Remove desc->cleanupList and all references to it. Fixes PR#20191
2004-04-10 03:10:16 +04:00
#include "rf_layout.h"
struct RF_RaidReconDesc_s {
RF_Raid_t *raidPtr; /* raid device descriptor */
RF_RowCol_t col; /* col of failed disk */
int state; /* how far along the reconstruction operation
* has gotten */
RF_RaidDisk_t *spareDiskPtr; /* describes target disk for recon
* (not used in dist sparing) */
int numDisksDone; /* the number of surviving disks that have
* completed their work */
RF_RowCol_t scol; /* col ID of the spare disk (not used in dist
* sparing) */
/*
* Prevent recon from hogging CPU
*/
RF_Etimer_t recon_exec_timer;
RF_uint64 reconExecTimerRunning;
RF_uint64 reconExecTicks;
RF_uint64 maxReconExecTicks;
#if RF_RECON_STATS > 0
RF_uint64 hsStallCount; /* head sep stall count */
RF_uint64 numReconExecDelays;
RF_uint64 numReconEventWaits;
#endif /* RF_RECON_STATS > 0 */
RF_RaidReconDesc_t *next;
};
struct RF_RaidAccessDesc_s {
RF_Raid_t *raidPtr; /* raid device descriptor */
RF_IoType_t type; /* read or write */
RF_RaidAddr_t raidAddress; /* starting address in raid address
* space */
RF_SectorCount_t numBlocks; /* number of blocks (sectors) to
* transfer */
RF_StripeCount_t numStripes; /* number of stripes involved in
* access */
caddr_t bufPtr; /* pointer to data buffer */
RF_RaidAccessFlags_t flags; /* flags controlling operation */
int state; /* index into states telling how far along the
* RAID operation has gotten */
const RF_AccessState_t *states; /* array of states to be run */
int status; /* pass/fail status of the last operation */
RF_DagList_t *dagList; /* list of dag lists, one list per stripe */
These changes complete the effective removal of malloc() from all write paths within RAIDframe. They also resolve the "panics with RAID 5 sets with more than 3 components" issue which was present (briefly) in the commits which were previously supposed to address the malloc() issue. With this new code the 5-component RAID 5 set panics are now gone. It is also now also possible to swap to RAID 5. The changes made are: 1) Introduce rf_AllocStripeBuffer() and rf_FreeStripeBuffer() to allocate/free one stripe's worth of space. rf_AllocStripeBuffer() is used in rf_MapUnaccessedPortionOfStripe() where it is not sufficient to allocate memory using just rf_AllocBuffer(). rf_FreeStripeBuffer() is called from rf_FreeRaidAccDesc(), well after the DAG is finished. 2) Add a set of emergency "stripe buffers" to struct RF_Raid_s. Arrange for their initialization in rf_Configure(). In low-memory situations these buffers will be returned by rf_AllocStripeBuffer() and re-populated by rf_FreeStripeBuffer(). 3) Move RF_VoidPointerListElem_t *iobufs from the dagHeader into into struct RF_RaidAccessDesc_s. This is more consistent with the original code, and will not result in items being freed "too early". 4) Add a RF_RaidAccessDesc_t *desc to RF_DagHeader_s so that we have a way to find desc->iobufs. 5) Arrange for desc in the DagHeader to be initialized in InitHdrNode(). 6) Don't cleanup iobufs in rf_FreeDAG() -- the freeing is now delayed until rf_FreeRaidAccDesc() (which is how the original code handled the allocList, and for which there seem to be some subtle, undocumented assumptions). 7) Rename rf_AllocBuffer2() to be rf_AllocBuffer() and remove the former rf_AllocBuffer(). Fix all callers of rf_AllocBuffer(). (This was how it was *supposed* to be after the last time these changes were made, before they were backed out). 8) Remove RF_IOBufHeader and all references to it. 9) Remove desc->cleanupList and all references to it. Fixes PR#20191
2004-04-10 03:10:16 +04:00
RF_VoidPointerListElem_t *iobufs; /* iobufs that need to be cleaned
up at the end of this IO */
RF_VoidPointerListElem_t *stripebufs; /* stripe buffers that need to
be cleaned up at the end of
this IO */
RF_AccessStripeMapHeader_t *asmap; /* the asm for this I/O */
void *bp; /* buf pointer for this RAID acc. ignored
* outside the kernel */
RF_AccTraceEntry_t tracerec; /* perf monitoring information for a
* user access (not for dag stats) */
void (*callbackFunc) (RF_CBParam_t); /* callback function for this
* I/O */
void *callbackArg; /* arg to give to callback func */
RF_RaidAccessDesc_t *next;
int async_flag;
RF_Etimer_t timer; /* used for timing this access */
};
#endif /* !_RF__RF_DESC_H_ */