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