1 1.32 andvar /* $NetBSD: rf_reconstruct.h,v 1.32 2023/05/27 21:38:06 andvar 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.23 christos RF_Raid_t *raidPtr; /* void *to avoid recursive includes */ 51 1.23 christos void *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.32 andvar * RF_REVENT_FORCEDREADONE- a forced-reconstruction 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.14 oster RF_REVENT_FORCEDREADDONE, 90 1.14 oster RF_REVENT_READ_FAILED, 91 1.14 oster RF_REVENT_WRITE_FAILED, 92 1.14 oster RF_REVENT_FORCEDREAD_FAILED 93 1.3 oster } RF_Revent_t; 94 1.1 oster 95 1.1 oster struct RF_ReconEvent_s { 96 1.3 oster RF_Revent_t type; /* what kind of event has occurred */ 97 1.3 oster RF_RowCol_t col; /* row ID is implicit in the queue in which 98 1.3 oster * the event is placed */ 99 1.3 oster void *arg; /* a generic argument */ 100 1.3 oster RF_ReconEvent_t *next; 101 1.1 oster }; 102 1.1 oster /* 103 1.1 oster * Reconstruction control information maintained per-disk 104 1.1 oster * (for surviving disks) 105 1.1 oster */ 106 1.1 oster struct RF_PerDiskReconCtrl_s { 107 1.3 oster RF_ReconCtrl_t *reconCtrl; 108 1.11 oster RF_RowCol_t col; /* to make this structure self-identifying */ 109 1.3 oster RF_StripeNum_t curPSID; /* the next parity stripe ID to check on this 110 1.3 oster * disk */ 111 1.3 oster RF_HeadSepLimit_t headSepCounter; /* counter used to control 112 1.3 oster * maximum head separation */ 113 1.3 oster RF_SectorNum_t diskOffset; /* the offset into the indicated disk 114 1.3 oster * of the current PU */ 115 1.3 oster RF_ReconUnitNum_t ru_count; /* this counts off the recon units 116 1.3 oster * within each parity unit */ 117 1.3 oster RF_ReconBuffer_t *rbuf; /* the recon buffer assigned to this disk */ 118 1.1 oster }; 119 1.1 oster /* main reconstruction control structure */ 120 1.1 oster struct RF_ReconCtrl_s { 121 1.3 oster RF_RaidReconDesc_t *reconDesc; 122 1.3 oster RF_RowCol_t fcol; /* which column has failed */ 123 1.3 oster RF_PerDiskReconCtrl_t *perDiskInfo; /* information maintained 124 1.3 oster * per-disk */ 125 1.3 oster RF_ReconMap_t *reconMap;/* map of what has/has not been reconstructed */ 126 1.10 oster RF_RowCol_t spareCol; /* which of the spare disks we're using */ 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.21 oster RF_ReconUnitCount_t numRUsComplete; /* number of Reconstruction Units done */ 131 1.21 oster RF_ReconUnitCount_t numRUsTotal; /* total number of Reconstruction Units */ 132 1.19 oster int error; /* non-0 indicates that an error has 133 1.31 andvar occurred during reconstruction, and 134 1.19 oster the reconstruction is in the process of 135 1.19 oster bailing out. */ 136 1.3 oster 137 1.3 oster /* reconstruction event queue */ 138 1.3 oster RF_ReconEvent_t *eventQueue; /* queue of pending reconstruction 139 1.3 oster * events */ 140 1.27 mrg rf_declare_mutex2(eq_mutex); /* mutex for locking event */ 141 1.27 mrg rf_declare_cond2(eq_cv); /* queue */ 142 1.3 oster int eq_count; /* debug only */ 143 1.3 oster 144 1.3 oster /* reconstruction buffer management */ 145 1.28 mrg rf_declare_mutex2(rb_mutex); /* mutex/cv for messing */ 146 1.28 mrg rf_declare_cond2(rb_cv); /* around with recon buffers */ 147 1.17 oster int rb_lock; /* 1 if someone is mucking 148 1.17 oster with recon buffers, 149 1.17 oster 0 otherwise */ 150 1.19 oster int pending_writes; /* number of writes which 151 1.19 oster have not completed */ 152 1.3 oster RF_ReconBuffer_t *floatingRbufs; /* available floating 153 1.3 oster * reconstruction buffers */ 154 1.3 oster RF_ReconBuffer_t *committedRbufs; /* recon buffers that have 155 1.3 oster * been committed to some 156 1.3 oster * waiting disk */ 157 1.3 oster RF_ReconBuffer_t *fullBufferList; /* full buffers waiting to be 158 1.3 oster * written out */ 159 1.29 christos RF_CallbackValueDesc_t *bufferWaitList; /* disks that are currently 160 1.3 oster * blocked waiting for buffers */ 161 1.3 oster 162 1.3 oster /* parity stripe status table */ 163 1.3 oster RF_PSStatusHeader_t *pssTable; /* stores the reconstruction status of 164 1.3 oster * active parity stripes */ 165 1.3 oster 166 1.3 oster /* maximum-head separation control */ 167 1.3 oster RF_HeadSepLimit_t minHeadSepCounter; /* the minimum hs counter over 168 1.3 oster * all disks */ 169 1.29 christos RF_CallbackValueDesc_t *headSepCBList; /* list of callbacks to be 170 1.3 oster * done as minPSID advances */ 171 1.3 oster 172 1.3 oster /* performance monitoring */ 173 1.3 oster struct timeval starttime; /* recon start time */ 174 1.1 oster }; 175 1.1 oster /* the default priority for reconstruction accesses */ 176 1.1 oster #define RF_IO_RECON_PRIORITY RF_IO_LOW_PRIORITY 177 1.1 oster 178 1.30 oster int rf_ConfigureReconstruction(RF_ShutdownList_t **, RF_Raid_t *, RF_Config_t *); 179 1.16 oster int rf_ReconstructFailedDisk(RF_Raid_t *, RF_RowCol_t); 180 1.16 oster int rf_ReconstructFailedDiskBasic(RF_Raid_t *, RF_RowCol_t); 181 1.16 oster int rf_ReconstructInPlace(RF_Raid_t *, RF_RowCol_t); 182 1.16 oster int rf_ContinueReconstructFailedDisk(RF_RaidReconDesc_t *); 183 1.16 oster int rf_ForceOrBlockRecon(RF_Raid_t *, RF_AccessStripeMap_t *, 184 1.29 christos void (*cbFunc) (void *), void *); 185 1.16 oster int rf_UnblockRecon(RF_Raid_t *, RF_AccessStripeMap_t *); 186 1.24 oster void rf_WakeupHeadSepCBWaiters(RF_Raid_t *); 187 1.1 oster 188 1.15 oster extern struct pool rf_reconbuffer_pool; 189 1.15 oster 190 1.3 oster #endif /* !_RF__RF_RECONSTRUCT_H_ */ 191