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