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