Home | History | Annotate | Line # | Download | only in raidframe
rf_reconstruct.h revision 1.6
      1  1.6  oster /*	$NetBSD: rf_reconstruct.h,v 1.6 2001/10/04 15:58:56 oster Exp $	*/
      2  1.1  oster /*
      3  1.1  oster  * Copyright (c) 1995 Carnegie-Mellon University.
      4  1.1  oster  * All rights reserved.
      5  1.1  oster  *
      6  1.1  oster  * Author: Mark Holland
      7  1.1  oster  *
      8  1.1  oster  * Permission to use, copy, modify and distribute this software and
      9  1.1  oster  * its documentation is hereby granted, provided that both the copyright
     10  1.1  oster  * notice and this permission notice appear in all copies of the
     11  1.1  oster  * software, derivative works or modified versions, and any portions
     12  1.1  oster  * thereof, and that both notices appear in supporting documentation.
     13  1.1  oster  *
     14  1.1  oster  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     15  1.1  oster  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
     16  1.1  oster  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     17  1.1  oster  *
     18  1.1  oster  * Carnegie Mellon requests users of this software to return to
     19  1.1  oster  *
     20  1.1  oster  *  Software Distribution Coordinator  or  Software.Distribution (at) CS.CMU.EDU
     21  1.1  oster  *  School of Computer Science
     22  1.1  oster  *  Carnegie Mellon University
     23  1.1  oster  *  Pittsburgh PA 15213-3890
     24  1.1  oster  *
     25  1.1  oster  * any improvements or extensions that they make and grant Carnegie the
     26  1.1  oster  * rights to redistribute these changes.
     27  1.1  oster  */
     28  1.1  oster 
     29  1.1  oster /*********************************************************
     30  1.1  oster  * rf_reconstruct.h -- header file for reconstruction code
     31  1.1  oster  *********************************************************/
     32  1.1  oster 
     33  1.1  oster #ifndef _RF__RF_RECONSTRUCT_H_
     34  1.1  oster #define _RF__RF_RECONSTRUCT_H_
     35  1.1  oster 
     36  1.6  oster #include <dev/raidframe/raidframevar.h>
     37  1.1  oster #include <sys/time.h>
     38  1.1  oster #include "rf_reconmap.h"
     39  1.1  oster #include "rf_psstatus.h"
     40  1.1  oster 
     41  1.1  oster /* reconstruction configuration information */
     42  1.1  oster struct RF_ReconConfig_s {
     43  1.3  oster 	unsigned numFloatingReconBufs;	/* number of floating recon bufs to
     44  1.3  oster 					 * use */
     45  1.3  oster 	RF_HeadSepLimit_t headSepLimit;	/* how far apart the heads are allow
     46  1.3  oster 					 * to become, in parity stripes */
     47  1.1  oster };
     48  1.1  oster /* a reconstruction buffer */
     49  1.1  oster struct RF_ReconBuffer_s {
     50  1.3  oster 	RF_Raid_t *raidPtr;	/* void * to avoid recursive includes */
     51  1.3  oster 	caddr_t buffer;		/* points to the data */
     52  1.3  oster 	RF_StripeNum_t parityStripeID;	/* the parity stripe that this data
     53  1.3  oster 					 * relates to */
     54  1.3  oster 	int     which_ru;	/* which reconstruction unit within the PSS */
     55  1.3  oster 	RF_SectorNum_t failedDiskSectorOffset;	/* the offset into the failed
     56  1.3  oster 						 * disk */
     57  1.3  oster 	RF_RowCol_t row, col;	/* which disk this buffer belongs to or is
     58  1.3  oster 				 * targeted at */
     59  1.3  oster 	RF_StripeCount_t count;	/* counts the # of SUs installed so far */
     60  1.3  oster 	int     priority;	/* used to force hi priority recon */
     61  1.3  oster 	RF_RbufType_t type;	/* FORCED or FLOATING */
     62  1.3  oster 	char   *arrived;	/* [x] = 1/0 if SU from disk x has/hasn't
     63  1.3  oster 				 * arrived */
     64  1.3  oster 	RF_ReconBuffer_t *next;	/* used for buffer management */
     65  1.3  oster 	void   *arg;		/* generic field for general use */
     66  1.3  oster 	RF_RowCol_t spRow, spCol;	/* spare disk to which this buf should
     67  1.3  oster 					 * be written */
     68  1.3  oster 	/* if dist sparing off, always identifies the replacement disk */
     69  1.3  oster 	RF_SectorNum_t spOffset;/* offset into the spare disk */
     70  1.3  oster 	/* if dist sparing off, identical to failedDiskSectorOffset */
     71  1.3  oster 	RF_ReconParityStripeStatus_t *pssPtr;	/* debug- pss associated with
     72  1.3  oster 						 * issue-pending write */
     73  1.1  oster };
     74  1.1  oster /* a reconstruction event descriptor.  The event types currently are:
     75  1.1  oster  *    RF_REVENT_READDONE    -- a read operation has completed
     76  1.1  oster  *    RF_REVENT_WRITEDONE   -- a write operation has completed
     77  1.1  oster  *    RF_REVENT_BUFREADY    -- the buffer manager has produced a full buffer
     78  1.1  oster  *    RF_REVENT_BLOCKCLEAR  -- a reconstruction blockage has been cleared
     79  1.1  oster  *    RF_REVENT_BUFCLEAR    -- the buffer manager has released a process blocked on submission
     80  1.1  oster  *    RF_REVENT_SKIP        -- we need to skip the current RU and go on to the next one, typ. b/c we found recon forced
     81  1.1  oster  *    RF_REVENT_FORCEDREADONE- a forced-reconstructoin read operation has completed
     82  1.1  oster  */
     83  1.1  oster typedef enum RF_Revent_e {
     84  1.1  oster 	RF_REVENT_READDONE,
     85  1.1  oster 	RF_REVENT_WRITEDONE,
     86  1.1  oster 	RF_REVENT_BUFREADY,
     87  1.1  oster 	RF_REVENT_BLOCKCLEAR,
     88  1.1  oster 	RF_REVENT_BUFCLEAR,
     89  1.1  oster 	RF_REVENT_HEADSEPCLEAR,
     90  1.1  oster 	RF_REVENT_SKIP,
     91  1.1  oster 	RF_REVENT_FORCEDREADDONE
     92  1.3  oster }       RF_Revent_t;
     93  1.1  oster 
     94  1.1  oster struct RF_ReconEvent_s {
     95  1.3  oster 	RF_Revent_t type;	/* what kind of event has occurred */
     96  1.3  oster 	RF_RowCol_t col;	/* row ID is implicit in the queue in which
     97  1.3  oster 				 * the event is placed */
     98  1.3  oster 	void   *arg;		/* a generic argument */
     99  1.3  oster 	RF_ReconEvent_t *next;
    100  1.1  oster };
    101  1.1  oster /*
    102  1.1  oster  * Reconstruction control information maintained per-disk
    103  1.1  oster  * (for surviving disks)
    104  1.1  oster  */
    105  1.1  oster struct RF_PerDiskReconCtrl_s {
    106  1.3  oster 	RF_ReconCtrl_t *reconCtrl;
    107  1.3  oster 	RF_RowCol_t row, col;	/* to make this structure self-identifying */
    108  1.3  oster 	RF_StripeNum_t curPSID;	/* the next parity stripe ID to check on this
    109  1.3  oster 				 * disk */
    110  1.3  oster 	RF_HeadSepLimit_t headSepCounter;	/* counter used to control
    111  1.3  oster 						 * maximum head separation */
    112  1.3  oster 	RF_SectorNum_t diskOffset;	/* the offset into the indicated disk
    113  1.3  oster 					 * of the current PU */
    114  1.3  oster 	RF_ReconUnitNum_t ru_count;	/* this counts off the recon units
    115  1.3  oster 					 * within each parity unit */
    116  1.3  oster 	RF_ReconBuffer_t *rbuf;	/* the recon buffer assigned to this disk */
    117  1.1  oster };
    118  1.1  oster /* main reconstruction control structure */
    119  1.1  oster struct RF_ReconCtrl_s {
    120  1.3  oster 	RF_RaidReconDesc_t *reconDesc;
    121  1.3  oster 	RF_RowCol_t fcol;	/* which column has failed */
    122  1.3  oster 	RF_PerDiskReconCtrl_t *perDiskInfo;	/* information maintained
    123  1.3  oster 						 * per-disk */
    124  1.3  oster 	RF_ReconMap_t *reconMap;/* map of what has/has not been reconstructed */
    125  1.3  oster 	RF_RowCol_t spareRow;	/* which of the spare disks we're using */
    126  1.3  oster 	RF_RowCol_t spareCol;
    127  1.3  oster 	RF_StripeNum_t lastPSID;/* the ID of the last parity stripe we want
    128  1.3  oster 				 * reconstructed */
    129  1.3  oster 	int     percentComplete;/* percentage completion of reconstruction */
    130  1.5  oster 	int     numRUsComplete; /* number of Reconstruction Units done */
    131  1.5  oster 	int     numRUsTotal;    /* total number of Reconstruction Units */
    132  1.3  oster 
    133  1.3  oster 	/* reconstruction event queue */
    134  1.3  oster 	RF_ReconEvent_t *eventQueue;	/* queue of pending reconstruction
    135  1.3  oster 					 * events */
    136  1.3  oster 	        RF_DECLARE_MUTEX(eq_mutex)	/* mutex for locking event
    137  1.3  oster 						 * queue */
    138  1.3  oster 	        RF_DECLARE_COND(eq_cond)	/* condition variable for
    139  1.3  oster 						 * signalling recon events */
    140  1.3  oster 	int     eq_count;	/* debug only */
    141  1.3  oster 
    142  1.3  oster 	/* reconstruction buffer management */
    143  1.3  oster 	        RF_DECLARE_MUTEX(rb_mutex)	/* mutex for messing around
    144  1.3  oster 						 * with recon buffers */
    145  1.3  oster 	RF_ReconBuffer_t *floatingRbufs;	/* available floating
    146  1.3  oster 						 * reconstruction buffers */
    147  1.3  oster 	RF_ReconBuffer_t *committedRbufs;	/* recon buffers that have
    148  1.3  oster 						 * been committed to some
    149  1.3  oster 						 * waiting disk */
    150  1.3  oster 	RF_ReconBuffer_t *fullBufferList;	/* full buffers waiting to be
    151  1.3  oster 						 * written out */
    152  1.3  oster 	RF_ReconBuffer_t *priorityList;	/* full buffers that have been
    153  1.3  oster 					 * elevated to higher priority */
    154  1.3  oster 	RF_CallbackDesc_t *bufferWaitList;	/* disks that are currently
    155  1.3  oster 						 * blocked waiting for buffers */
    156  1.3  oster 
    157  1.3  oster 	/* parity stripe status table */
    158  1.3  oster 	RF_PSStatusHeader_t *pssTable;	/* stores the reconstruction status of
    159  1.3  oster 					 * active parity stripes */
    160  1.3  oster 
    161  1.3  oster 	/* maximum-head separation control */
    162  1.3  oster 	RF_HeadSepLimit_t minHeadSepCounter;	/* the minimum hs counter over
    163  1.3  oster 						 * all disks */
    164  1.3  oster 	RF_CallbackDesc_t *headSepCBList;	/* list of callbacks to be
    165  1.3  oster 						 * done as minPSID advances */
    166  1.3  oster 
    167  1.3  oster 	/* performance monitoring */
    168  1.3  oster 	struct timeval starttime;	/* recon start time */
    169  1.3  oster 
    170  1.3  oster 	void    (*continueFunc) (void *);	/* function to call when io
    171  1.3  oster 						 * returns */
    172  1.3  oster 	void   *continueArg;	/* argument for Func */
    173  1.1  oster };
    174  1.1  oster /* the default priority for reconstruction accesses */
    175  1.1  oster #define RF_IO_RECON_PRIORITY RF_IO_LOW_PRIORITY
    176  1.1  oster 
    177  1.3  oster int     rf_ConfigureReconstruction(RF_ShutdownList_t ** listp);
    178  1.1  oster 
    179  1.3  oster int
    180  1.3  oster rf_ReconstructFailedDisk(RF_Raid_t * raidPtr, RF_RowCol_t row,
    181  1.3  oster     RF_RowCol_t col);
    182  1.1  oster 
    183  1.3  oster int
    184  1.3  oster rf_ReconstructFailedDiskBasic(RF_Raid_t * raidPtr, RF_RowCol_t row,
    185  1.3  oster     RF_RowCol_t col);
    186  1.4  oster 
    187  1.4  oster int
    188  1.4  oster rf_ReconstructInPlace(RF_Raid_t * raidPtr, RF_RowCol_t row, RF_RowCol_t col);
    189  1.1  oster 
    190  1.3  oster int     rf_ContinueReconstructFailedDisk(RF_RaidReconDesc_t * reconDesc);
    191  1.1  oster 
    192  1.3  oster int
    193  1.3  oster rf_ForceOrBlockRecon(RF_Raid_t * raidPtr, RF_AccessStripeMap_t * asmap,
    194  1.3  oster     void (*cbFunc) (RF_Raid_t *, void *), void *cbArg);
    195  1.1  oster 
    196  1.3  oster 	int     rf_UnblockRecon(RF_Raid_t * raidPtr, RF_AccessStripeMap_t * asmap);
    197  1.1  oster 
    198  1.3  oster 	int     rf_RegisterReconDoneProc(RF_Raid_t * raidPtr, void (*proc) (RF_Raid_t *, void *), void *arg,
    199  1.3  oster             RF_ReconDoneProc_t ** handlep);
    200  1.1  oster 
    201  1.3  oster #endif				/* !_RF__RF_RECONSTRUCT_H_ */
    202