Home | History | Annotate | Line # | Download | only in raidframe
rf_reconstruct.h revision 1.13
      1  1.13  oster /*	$NetBSD: rf_reconstruct.h,v 1.13 2004/01/01 19:32:55 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.13  oster 	RF_RowCol_t 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 	RF_ReconBuffer_t *next;	/* used for buffer management */
     63   1.3  oster 	void   *arg;		/* generic field for general use */
     64   1.3  oster 	RF_RowCol_t spRow, spCol;	/* spare disk to which this buf should
     65   1.3  oster 					 * be written */
     66   1.3  oster 	/* if dist sparing off, always identifies the replacement disk */
     67   1.3  oster 	RF_SectorNum_t spOffset;/* offset into the spare disk */
     68   1.3  oster 	/* if dist sparing off, identical to failedDiskSectorOffset */
     69   1.3  oster 	RF_ReconParityStripeStatus_t *pssPtr;	/* debug- pss associated with
     70   1.3  oster 						 * issue-pending write */
     71   1.1  oster };
     72   1.1  oster /* a reconstruction event descriptor.  The event types currently are:
     73   1.1  oster  *    RF_REVENT_READDONE    -- a read operation has completed
     74   1.1  oster  *    RF_REVENT_WRITEDONE   -- a write operation has completed
     75   1.1  oster  *    RF_REVENT_BUFREADY    -- the buffer manager has produced a full buffer
     76   1.1  oster  *    RF_REVENT_BLOCKCLEAR  -- a reconstruction blockage has been cleared
     77   1.1  oster  *    RF_REVENT_BUFCLEAR    -- the buffer manager has released a process blocked on submission
     78   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
     79   1.1  oster  *    RF_REVENT_FORCEDREADONE- a forced-reconstructoin read operation has completed
     80   1.1  oster  */
     81   1.1  oster typedef enum RF_Revent_e {
     82   1.1  oster 	RF_REVENT_READDONE,
     83   1.1  oster 	RF_REVENT_WRITEDONE,
     84   1.1  oster 	RF_REVENT_BUFREADY,
     85   1.1  oster 	RF_REVENT_BLOCKCLEAR,
     86   1.1  oster 	RF_REVENT_BUFCLEAR,
     87   1.1  oster 	RF_REVENT_HEADSEPCLEAR,
     88   1.1  oster 	RF_REVENT_SKIP,
     89   1.1  oster 	RF_REVENT_FORCEDREADDONE
     90   1.3  oster }       RF_Revent_t;
     91   1.1  oster 
     92   1.1  oster struct RF_ReconEvent_s {
     93   1.3  oster 	RF_Revent_t type;	/* what kind of event has occurred */
     94   1.3  oster 	RF_RowCol_t col;	/* row ID is implicit in the queue in which
     95   1.3  oster 				 * the event is placed */
     96   1.3  oster 	void   *arg;		/* a generic argument */
     97   1.3  oster 	RF_ReconEvent_t *next;
     98   1.1  oster };
     99   1.1  oster /*
    100   1.1  oster  * Reconstruction control information maintained per-disk
    101   1.1  oster  * (for surviving disks)
    102   1.1  oster  */
    103   1.1  oster struct RF_PerDiskReconCtrl_s {
    104   1.3  oster 	RF_ReconCtrl_t *reconCtrl;
    105  1.11  oster 	RF_RowCol_t col;	/* to make this structure self-identifying */
    106   1.3  oster 	RF_StripeNum_t curPSID;	/* the next parity stripe ID to check on this
    107   1.3  oster 				 * disk */
    108   1.3  oster 	RF_HeadSepLimit_t headSepCounter;	/* counter used to control
    109   1.3  oster 						 * maximum head separation */
    110   1.3  oster 	RF_SectorNum_t diskOffset;	/* the offset into the indicated disk
    111   1.3  oster 					 * of the current PU */
    112   1.3  oster 	RF_ReconUnitNum_t ru_count;	/* this counts off the recon units
    113   1.3  oster 					 * within each parity unit */
    114   1.3  oster 	RF_ReconBuffer_t *rbuf;	/* the recon buffer assigned to this disk */
    115   1.1  oster };
    116   1.1  oster /* main reconstruction control structure */
    117   1.1  oster struct RF_ReconCtrl_s {
    118   1.3  oster 	RF_RaidReconDesc_t *reconDesc;
    119   1.3  oster 	RF_RowCol_t fcol;	/* which column has failed */
    120   1.3  oster 	RF_PerDiskReconCtrl_t *perDiskInfo;	/* information maintained
    121   1.3  oster 						 * per-disk */
    122   1.3  oster 	RF_ReconMap_t *reconMap;/* map of what has/has not been reconstructed */
    123  1.10  oster 	RF_RowCol_t spareCol;   /* which of the spare disks we're using */
    124   1.3  oster 	RF_StripeNum_t lastPSID;/* the ID of the last parity stripe we want
    125   1.3  oster 				 * reconstructed */
    126   1.3  oster 	int     percentComplete;/* percentage completion of reconstruction */
    127   1.5  oster 	int     numRUsComplete; /* number of Reconstruction Units done */
    128   1.5  oster 	int     numRUsTotal;    /* total number of Reconstruction Units */
    129   1.3  oster 
    130   1.3  oster 	/* reconstruction event queue */
    131   1.3  oster 	RF_ReconEvent_t *eventQueue;	/* queue of pending reconstruction
    132   1.3  oster 					 * events */
    133   1.3  oster 	        RF_DECLARE_MUTEX(eq_mutex)	/* mutex for locking event
    134   1.3  oster 						 * queue */
    135   1.3  oster 	int     eq_count;	/* debug only */
    136   1.3  oster 
    137   1.3  oster 	/* reconstruction buffer management */
    138   1.3  oster 	        RF_DECLARE_MUTEX(rb_mutex)	/* mutex for messing around
    139   1.3  oster 						 * with recon buffers */
    140   1.3  oster 	RF_ReconBuffer_t *floatingRbufs;	/* available floating
    141   1.3  oster 						 * reconstruction buffers */
    142   1.3  oster 	RF_ReconBuffer_t *committedRbufs;	/* recon buffers that have
    143   1.3  oster 						 * been committed to some
    144   1.3  oster 						 * waiting disk */
    145   1.3  oster 	RF_ReconBuffer_t *fullBufferList;	/* full buffers waiting to be
    146   1.3  oster 						 * written out */
    147   1.3  oster 	RF_CallbackDesc_t *bufferWaitList;	/* disks that are currently
    148   1.3  oster 						 * blocked waiting for buffers */
    149   1.3  oster 
    150   1.3  oster 	/* parity stripe status table */
    151   1.3  oster 	RF_PSStatusHeader_t *pssTable;	/* stores the reconstruction status of
    152   1.3  oster 					 * active parity stripes */
    153   1.3  oster 
    154   1.3  oster 	/* maximum-head separation control */
    155   1.3  oster 	RF_HeadSepLimit_t minHeadSepCounter;	/* the minimum hs counter over
    156   1.3  oster 						 * all disks */
    157   1.3  oster 	RF_CallbackDesc_t *headSepCBList;	/* list of callbacks to be
    158   1.3  oster 						 * done as minPSID advances */
    159   1.3  oster 
    160   1.3  oster 	/* performance monitoring */
    161   1.3  oster 	struct timeval starttime;	/* recon start time */
    162   1.3  oster 
    163   1.3  oster 	void    (*continueFunc) (void *);	/* function to call when io
    164   1.3  oster 						 * returns */
    165   1.3  oster 	void   *continueArg;	/* argument for Func */
    166   1.1  oster };
    167   1.1  oster /* the default priority for reconstruction accesses */
    168   1.1  oster #define RF_IO_RECON_PRIORITY RF_IO_LOW_PRIORITY
    169   1.1  oster 
    170   1.3  oster int     rf_ConfigureReconstruction(RF_ShutdownList_t ** listp);
    171   1.1  oster 
    172   1.3  oster int
    173  1.10  oster rf_ReconstructFailedDisk(RF_Raid_t * raidPtr, RF_RowCol_t col);
    174   1.1  oster 
    175   1.3  oster int
    176  1.10  oster rf_ReconstructFailedDiskBasic(RF_Raid_t * raidPtr, RF_RowCol_t col);
    177   1.4  oster 
    178   1.4  oster int
    179  1.10  oster rf_ReconstructInPlace(RF_Raid_t * raidPtr,RF_RowCol_t col);
    180   1.1  oster 
    181   1.3  oster int     rf_ContinueReconstructFailedDisk(RF_RaidReconDesc_t * reconDesc);
    182   1.1  oster 
    183   1.3  oster int
    184   1.3  oster rf_ForceOrBlockRecon(RF_Raid_t * raidPtr, RF_AccessStripeMap_t * asmap,
    185   1.3  oster     void (*cbFunc) (RF_Raid_t *, void *), void *cbArg);
    186   1.1  oster 
    187   1.3  oster 	int     rf_UnblockRecon(RF_Raid_t * raidPtr, RF_AccessStripeMap_t * asmap);
    188   1.1  oster 
    189   1.3  oster #endif				/* !_RF__RF_RECONSTRUCT_H_ */
    190