1 /* $NetBSD: rf_evenodd_dags.c,v 1.2 1999/02/05 00:06:11 oster Exp $ */ 2 /* 3 * rf_evenodd_dags.c 4 */ 5 /* 6 * Copyright (c) 1996 Carnegie-Mellon University. 7 * All rights reserved. 8 * 9 * Author: Chang-Ming Wu 10 * 11 * Permission to use, copy, modify and distribute this software and 12 * its documentation is hereby granted, provided that both the copyright 13 * notice and this permission notice appear in all copies of the 14 * software, derivative works or modified versions, and any portions 15 * thereof, and that both notices appear in supporting documentation. 16 * 17 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 18 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND 19 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 20 * 21 * Carnegie Mellon requests users of this software to return to 22 * 23 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 24 * School of Computer Science 25 * Carnegie Mellon University 26 * Pittsburgh PA 15213-3890 27 * 28 * any improvements or extensions that they make and grant Carnegie the 29 * rights to redistribute these changes. 30 */ 31 32 #include "rf_archs.h" 33 34 #if RF_INCLUDE_EVENODD > 0 35 36 #include "rf_types.h" 37 #include "rf_raid.h" 38 #include "rf_dag.h" 39 #include "rf_dagfuncs.h" 40 #include "rf_dagutils.h" 41 #include "rf_etimer.h" 42 #include "rf_acctrace.h" 43 #include "rf_general.h" 44 #include "rf_evenodd_dags.h" 45 #include "rf_evenodd.h" 46 #include "rf_evenodd_dagfuncs.h" 47 #include "rf_pq.h" 48 #include "rf_dagdegrd.h" 49 #include "rf_dagdegwr.h" 50 #include "rf_dagffwr.h" 51 52 53 /* 54 * Lost one data. 55 * Use P to reconstruct missing data. 56 */ 57 RF_CREATE_DAG_FUNC_DECL(rf_EO_100_CreateReadDAG) 58 { 59 rf_CreateDegradedReadDAG(raidPtr, asmap, dag_h, bp, flags, allocList, &rf_eoPRecoveryFuncs); 60 } 61 /* 62 * Lost data + E. 63 * Use P to reconstruct missing data. 64 */ 65 RF_CREATE_DAG_FUNC_DECL(rf_EO_101_CreateReadDAG) 66 { 67 rf_CreateDegradedReadDAG(raidPtr, asmap, dag_h, bp, flags, allocList, &rf_eoPRecoveryFuncs); 68 } 69 /* 70 * Lost data + P. 71 * Make E look like P, and use Eor for Xor, and we can 72 * use degraded read DAG. 73 */ 74 RF_CREATE_DAG_FUNC_DECL(rf_EO_110_CreateReadDAG) 75 { 76 RF_PhysDiskAddr_t *temp; 77 /* swap P and E pointers to fake out the DegradedReadDAG code */ 78 temp = asmap->parityInfo; 79 asmap->parityInfo = asmap->qInfo; 80 asmap->qInfo = temp; 81 rf_CreateDegradedReadDAG(raidPtr, asmap, dag_h, bp, flags, allocList, &rf_eoERecoveryFuncs); 82 } 83 /* 84 * Lost two data. 85 */ 86 RF_CREATE_DAG_FUNC_DECL(rf_EOCreateDoubleDegradedReadDAG) 87 { 88 rf_EO_DoubleDegRead(raidPtr, asmap, dag_h, bp, flags, allocList); 89 } 90 /* 91 * Lost two data. 92 */ 93 RF_CREATE_DAG_FUNC_DECL(rf_EO_200_CreateReadDAG) 94 { 95 rf_EOCreateDoubleDegradedReadDAG(raidPtr, asmap, dag_h, bp, flags, allocList); 96 } 97 RF_CREATE_DAG_FUNC_DECL(rf_EO_100_CreateWriteDAG) 98 { 99 if (asmap->numStripeUnitsAccessed != 1 && 100 asmap->failedPDAs[0]->numSector != raidPtr->Layout.sectorsPerStripeUnit) 101 RF_PANIC(); 102 rf_CommonCreateSimpleDegradedWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, 2, (int (*) (RF_DagNode_t *)) rf_Degraded_100_EOFunc, RF_TRUE); 103 } 104 /* 105 * E is dead. Small write. 106 */ 107 RF_CREATE_DAG_FUNC_DECL(rf_EO_001_CreateSmallWriteDAG) 108 { 109 rf_CommonCreateSmallWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, &rf_EOSmallWritePFuncs, NULL); 110 } 111 /* 112 * E is dead. Large write. 113 */ 114 RF_CREATE_DAG_FUNC_DECL(rf_EO_001_CreateLargeWriteDAG) 115 { 116 rf_CommonCreateLargeWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, 1, rf_RegularPFunc, RF_TRUE); 117 } 118 /* 119 * P is dead. Small write. 120 * Swap E + P, use single-degraded stuff. 121 */ 122 RF_CREATE_DAG_FUNC_DECL(rf_EO_010_CreateSmallWriteDAG) 123 { 124 RF_PhysDiskAddr_t *temp; 125 /* swap P and E pointers to fake out the DegradedReadDAG code */ 126 temp = asmap->parityInfo; 127 asmap->parityInfo = asmap->qInfo; 128 asmap->qInfo = temp; 129 rf_CommonCreateSmallWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, &rf_EOSmallWriteEFuncs, NULL); 130 } 131 /* 132 * P is dead. Large write. 133 * Swap E + P, use single-degraded stuff. 134 */ 135 RF_CREATE_DAG_FUNC_DECL(rf_EO_010_CreateLargeWriteDAG) 136 { 137 RF_PhysDiskAddr_t *temp; 138 /* swap P and E pointers to fake out the code */ 139 temp = asmap->parityInfo; 140 asmap->parityInfo = asmap->qInfo; 141 asmap->qInfo = temp; 142 rf_CommonCreateLargeWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, 1, rf_RegularEFunc, RF_FALSE); 143 } 144 RF_CREATE_DAG_FUNC_DECL(rf_EO_011_CreateWriteDAG) 145 { 146 rf_CreateNonRedundantWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, 147 RF_IO_TYPE_WRITE); 148 } 149 RF_CREATE_DAG_FUNC_DECL(rf_EO_110_CreateWriteDAG) 150 { 151 RF_PhysDiskAddr_t *temp; 152 153 if (asmap->numStripeUnitsAccessed != 1 && 154 asmap->failedPDAs[0]->numSector != raidPtr->Layout.sectorsPerStripeUnit) { 155 RF_PANIC(); 156 } 157 /* swap P and E to fake out parity code */ 158 temp = asmap->parityInfo; 159 asmap->parityInfo = asmap->qInfo; 160 asmap->qInfo = temp; 161 rf_CommonCreateSimpleDegradedWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, 1, (int (*) (RF_DagNode_t *)) rf_EO_DegradedWriteEFunc, RF_FALSE); 162 /* is the regular E func the right one to call? */ 163 } 164 RF_CREATE_DAG_FUNC_DECL(rf_EO_101_CreateWriteDAG) 165 { 166 if (asmap->numStripeUnitsAccessed != 1 && 167 asmap->failedPDAs[0]->numSector != raidPtr->Layout.sectorsPerStripeUnit) 168 RF_PANIC(); 169 rf_CommonCreateSimpleDegradedWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, 1, rf_RecoveryXorFunc, RF_TRUE); 170 } 171 RF_CREATE_DAG_FUNC_DECL(rf_EO_DoubleDegRead) 172 { 173 rf_DoubleDegRead(raidPtr, asmap, dag_h, bp, flags, allocList, 174 "Re", "EvenOddRecovery", rf_EvenOddDoubleRecoveryFunc); 175 } 176 RF_CREATE_DAG_FUNC_DECL(rf_EOCreateSmallWriteDAG) 177 { 178 rf_CommonCreateSmallWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, &rf_pFuncs, &rf_EOSmallWriteEFuncs); 179 } 180 RF_CREATE_DAG_FUNC_DECL(rf_EOCreateLargeWriteDAG) 181 { 182 rf_CommonCreateLargeWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, 2, rf_RegularPEFunc, RF_FALSE); 183 } 184 RF_CREATE_DAG_FUNC_DECL(rf_EO_200_CreateWriteDAG) 185 { 186 rf_DoubleDegSmallWrite(raidPtr, asmap, dag_h, bp, flags, allocList, "Re", "We", "EOWrDDRecovery", rf_EOWriteDoubleRecoveryFunc); 187 } 188 #endif /* RF_INCLUDE_EVENODD > 0 */ 189