1 | /* $NetBSD: rf_evenodd_dags.c,v 1.4 2001/11/13 07:11:14 lukem 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 <sys/cdefs.h> |
33 | __KERNEL_RCSID(0, "$NetBSD: rf_evenodd_dags.c,v 1.4 2001/11/13 07:11:14 lukem Exp $" ); |
34 | |
35 | #include "rf_archs.h" |
36 | |
37 | #if RF_INCLUDE_EVENODD > 0 |
38 | |
39 | #include <dev/raidframe/raidframevar.h> |
40 | |
41 | #include "rf_raid.h" |
42 | #include "rf_dag.h" |
43 | #include "rf_dagfuncs.h" |
44 | #include "rf_dagutils.h" |
45 | #include "rf_etimer.h" |
46 | #include "rf_acctrace.h" |
47 | #include "rf_general.h" |
48 | #include "rf_evenodd_dags.h" |
49 | #include "rf_evenodd.h" |
50 | #include "rf_evenodd_dagfuncs.h" |
51 | #include "rf_pq.h" |
52 | #include "rf_dagdegrd.h" |
53 | #include "rf_dagdegwr.h" |
54 | #include "rf_dagffwr.h" |
55 | |
56 | |
57 | /* |
58 | * Lost one data. |
59 | * Use P to reconstruct missing data. |
60 | */ |
61 | RF_CREATE_DAG_FUNC_DECL(rf_EO_100_CreateReadDAG) |
62 | { |
63 | rf_CreateDegradedReadDAG(raidPtr, asmap, dag_h, bp, flags, allocList, &rf_eoPRecoveryFuncs); |
64 | } |
65 | /* |
66 | * Lost data + E. |
67 | * Use P to reconstruct missing data. |
68 | */ |
69 | RF_CREATE_DAG_FUNC_DECL(rf_EO_101_CreateReadDAG) |
70 | { |
71 | rf_CreateDegradedReadDAG(raidPtr, asmap, dag_h, bp, flags, allocList, &rf_eoPRecoveryFuncs); |
72 | } |
73 | /* |
74 | * Lost data + P. |
75 | * Make E look like P, and use Eor for Xor, and we can |
76 | * use degraded read DAG. |
77 | */ |
78 | RF_CREATE_DAG_FUNC_DECL(rf_EO_110_CreateReadDAG) |
79 | { |
80 | RF_PhysDiskAddr_t *temp; |
81 | /* swap P and E pointers to fake out the DegradedReadDAG code */ |
82 | temp = asmap->parityInfo; |
83 | asmap->parityInfo = asmap->qInfo; |
84 | asmap->qInfo = temp; |
85 | rf_CreateDegradedReadDAG(raidPtr, asmap, dag_h, bp, flags, allocList, &rf_eoERecoveryFuncs); |
86 | } |
87 | /* |
88 | * Lost two data. |
89 | */ |
90 | RF_CREATE_DAG_FUNC_DECL(rf_EOCreateDoubleDegradedReadDAG) |
91 | { |
92 | rf_EO_DoubleDegRead(raidPtr, asmap, dag_h, bp, flags, allocList); |
93 | } |
94 | /* |
95 | * Lost two data. |
96 | */ |
97 | RF_CREATE_DAG_FUNC_DECL(rf_EO_200_CreateReadDAG) |
98 | { |
99 | rf_EOCreateDoubleDegradedReadDAG(raidPtr, asmap, dag_h, bp, flags, allocList); |
100 | } |
101 | RF_CREATE_DAG_FUNC_DECL(rf_EO_100_CreateWriteDAG) |
102 | { |
103 | if (asmap->numStripeUnitsAccessed != 1 && |
104 | asmap->failedPDAs[0]->numSector != raidPtr->Layout.sectorsPerStripeUnit) |
105 | RF_PANIC(); |
106 | rf_CommonCreateSimpleDegradedWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, 2, (int (*) (RF_DagNode_t *)) rf_Degraded_100_EOFunc, RF_TRUE); |
107 | } |
108 | /* |
109 | * E is dead. Small write. |
110 | */ |
111 | RF_CREATE_DAG_FUNC_DECL(rf_EO_001_CreateSmallWriteDAG) |
112 | { |
113 | rf_CommonCreateSmallWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, &rf_EOSmallWritePFuncs, NULL); |
114 | } |
115 | /* |
116 | * E is dead. Large write. |
117 | */ |
118 | RF_CREATE_DAG_FUNC_DECL(rf_EO_001_CreateLargeWriteDAG) |
119 | { |
120 | rf_CommonCreateLargeWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, 1, rf_RegularPFunc, RF_TRUE); |
121 | } |
122 | /* |
123 | * P is dead. Small write. |
124 | * Swap E + P, use single-degraded stuff. |
125 | */ |
126 | RF_CREATE_DAG_FUNC_DECL(rf_EO_010_CreateSmallWriteDAG) |
127 | { |
128 | RF_PhysDiskAddr_t *temp; |
129 | /* swap P and E pointers to fake out the DegradedReadDAG code */ |
130 | temp = asmap->parityInfo; |
131 | asmap->parityInfo = asmap->qInfo; |
132 | asmap->qInfo = temp; |
133 | rf_CommonCreateSmallWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, &rf_EOSmallWriteEFuncs, NULL); |
134 | } |
135 | /* |
136 | * P is dead. Large write. |
137 | * Swap E + P, use single-degraded stuff. |
138 | */ |
139 | RF_CREATE_DAG_FUNC_DECL(rf_EO_010_CreateLargeWriteDAG) |
140 | { |
141 | RF_PhysDiskAddr_t *temp; |
142 | /* swap P and E pointers to fake out the code */ |
143 | temp = asmap->parityInfo; |
144 | asmap->parityInfo = asmap->qInfo; |
145 | asmap->qInfo = temp; |
146 | rf_CommonCreateLargeWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, 1, rf_RegularEFunc, RF_FALSE); |
147 | } |
148 | RF_CREATE_DAG_FUNC_DECL(rf_EO_011_CreateWriteDAG) |
149 | { |
150 | rf_CreateNonRedundantWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, |
151 | RF_IO_TYPE_WRITE); |
152 | } |
153 | RF_CREATE_DAG_FUNC_DECL(rf_EO_110_CreateWriteDAG) |
154 | { |
155 | RF_PhysDiskAddr_t *temp; |
156 | |
157 | if (asmap->numStripeUnitsAccessed != 1 && |
158 | asmap->failedPDAs[0]->numSector != raidPtr->Layout.sectorsPerStripeUnit) { |
159 | RF_PANIC(); |
160 | } |
161 | /* swap P and E to fake out parity code */ |
162 | temp = asmap->parityInfo; |
163 | asmap->parityInfo = asmap->qInfo; |
164 | asmap->qInfo = temp; |
165 | rf_CommonCreateSimpleDegradedWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, 1, (int (*) (RF_DagNode_t *)) rf_EO_DegradedWriteEFunc, RF_FALSE); |
166 | /* is the regular E func the right one to call? */ |
167 | } |
168 | RF_CREATE_DAG_FUNC_DECL(rf_EO_101_CreateWriteDAG) |
169 | { |
170 | if (asmap->numStripeUnitsAccessed != 1 && |
171 | asmap->failedPDAs[0]->numSector != raidPtr->Layout.sectorsPerStripeUnit) |
172 | RF_PANIC(); |
173 | rf_CommonCreateSimpleDegradedWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, 1, rf_RecoveryXorFunc, RF_TRUE); |
174 | } |
175 | RF_CREATE_DAG_FUNC_DECL(rf_EO_DoubleDegRead) |
176 | { |
177 | rf_DoubleDegRead(raidPtr, asmap, dag_h, bp, flags, allocList, |
178 | "Re" , "EvenOddRecovery" , rf_EvenOddDoubleRecoveryFunc); |
179 | } |
180 | RF_CREATE_DAG_FUNC_DECL(rf_EOCreateSmallWriteDAG) |
181 | { |
182 | rf_CommonCreateSmallWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, &rf_pFuncs, &rf_EOSmallWriteEFuncs); |
183 | } |
184 | RF_CREATE_DAG_FUNC_DECL(rf_EOCreateLargeWriteDAG) |
185 | { |
186 | rf_CommonCreateLargeWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, 2, rf_RegularPEFunc, RF_FALSE); |
187 | } |
188 | RF_CREATE_DAG_FUNC_DECL(rf_EO_200_CreateWriteDAG) |
189 | { |
190 | rf_DoubleDegSmallWrite(raidPtr, asmap, dag_h, bp, flags, allocList, "Re" , "We" , "EOWrDDRecovery" , rf_EOWriteDoubleRecoveryFunc); |
191 | } |
192 | #endif /* RF_INCLUDE_EVENODD > 0 */ |
193 | |