rf_pqdeg.c revision 1.6 1 /* $NetBSD: rf_pqdeg.c,v 1.6 2001/10/04 15:58:55 oster Exp $ */
2 /*
3 * Copyright (c) 1995 Carnegie-Mellon University.
4 * All rights reserved.
5 *
6 * Author: Daniel Stodolsky
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 (at) 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 #include "rf_archs.h"
30
31 #if (RF_INCLUDE_DECL_PQ > 0) || (RF_INCLUDE_RAID6 > 0)
32
33 #include <dev/raidframe/raidframevar.h>
34
35 #include "rf_raid.h"
36 #include "rf_dag.h"
37 #include "rf_dagutils.h"
38 #include "rf_dagfuncs.h"
39 #include "rf_dagffrd.h"
40 #include "rf_dagffwr.h"
41 #include "rf_dagdegrd.h"
42 #include "rf_dagdegwr.h"
43 #include "rf_etimer.h"
44 #include "rf_pqdeg.h"
45 #include "rf_general.h"
46 #include "rf_pqdegdags.h"
47 #include "rf_pq.h"
48
49 /*
50 Degraded mode dag functions for P+Q calculations.
51
52 The following nomenclature is used.
53
54 PQ_<D><P><Q>_Create{Large,Small}<Write|Read>DAG
55
56 where <D><P><Q> are single digits representing the number of failed
57 data units <D> (0,1,2), parity units <P> (0,1), and Q units <Q>, effecting
58 the I/O. The reads have only PQ_<D><P><Q>_CreateReadDAG variants, while
59 the single fault writes have both large and small write versions. (Single fault
60 PQ is equivalent to normal mode raid 5 in many aspects.
61
62 Some versions degenerate into the same case, and are grouped together below.
63 */
64
65 /* Reads, single failure
66
67 we have parity, so we can do a raid 5
68 reconstruct read.
69 */
70
71 RF_CREATE_DAG_FUNC_DECL(rf_PQ_100_CreateReadDAG)
72 {
73 rf_CreateDegradedReadDAG(raidPtr, asmap, dag_h, bp, flags, allocList, &rf_pRecoveryFuncs);
74 }
75 /* Reads double failure */
76
77 /*
78 Q is lost, but not parity
79 so we can a raid 5 reconstruct read.
80 */
81
82 RF_CREATE_DAG_FUNC_DECL(rf_PQ_101_CreateReadDAG)
83 {
84 rf_CreateDegradedReadDAG(raidPtr, asmap, dag_h, bp, flags, allocList, &rf_pRecoveryFuncs);
85 }
86 /*
87 parity is lost, so we need to
88 do a reconstruct read and recompute
89 the data with Q.
90 */
91
92 RF_CREATE_DAG_FUNC_DECL(rf_PQ_110_CreateReadDAG)
93 {
94 RF_PhysDiskAddr_t *temp;
95 /* swap P and Q pointers to fake out the DegradedReadDAG code */
96 temp = asmap->parityInfo;
97 asmap->parityInfo = asmap->qInfo;
98 asmap->qInfo = temp;
99 rf_CreateDegradedReadDAG(raidPtr, asmap, dag_h, bp, flags, allocList, &rf_qRecoveryFuncs);
100 }
101 /*
102 Two data units are dead in this stripe, so we will need read
103 both P and Q to reconstruct the data. Note that only
104 one data unit we are reading may actually be missing.
105 */
106 RF_CREATE_DAG_FUNC_DECL(rf_CreateDoubleDegradedReadDAG);
107 RF_CREATE_DAG_FUNC_DECL(rf_CreateDoubleDegradedReadDAG)
108 {
109 rf_PQ_DoubleDegRead(raidPtr, asmap, dag_h, bp, flags, allocList);
110 }
111 RF_CREATE_DAG_FUNC_DECL(rf_PQ_200_CreateReadDAG);
112 RF_CREATE_DAG_FUNC_DECL(rf_PQ_200_CreateReadDAG)
113 {
114 rf_CreateDoubleDegradedReadDAG(raidPtr, asmap, dag_h, bp, flags, allocList);
115 }
116 /* Writes, single failure */
117
118 RF_CREATE_DAG_FUNC_DECL(rf_PQ_100_CreateWriteDAG);
119 RF_CREATE_DAG_FUNC_DECL(rf_PQ_100_CreateWriteDAG)
120 {
121 if (asmap->numStripeUnitsAccessed != 1 &&
122 asmap->failedPDAs[0]->numSector !=
123 raidPtr->Layout.sectorsPerStripeUnit)
124 RF_PANIC();
125 rf_CommonCreateSimpleDegradedWriteDAG(raidPtr, asmap, dag_h, bp,
126 flags, allocList, 2,
127 (int (*) (RF_DagNode_t *)) rf_Degraded_100_PQFunc,
128 RF_FALSE);
129 }
130 /* Dead P - act like a RAID 5 small write with parity = Q */
131 RF_CREATE_DAG_FUNC_DECL(rf_PQ_010_CreateSmallWriteDAG)
132 {
133 RF_PhysDiskAddr_t *temp;
134 /* swap P and Q pointers to fake out the DegradedReadDAG code */
135 temp = asmap->parityInfo;
136 asmap->parityInfo = asmap->qInfo;
137 asmap->qInfo = temp;
138 rf_CommonCreateSmallWriteDAG(raidPtr, asmap, dag_h, bp, flags,
139 allocList, &rf_qFuncs, NULL);
140 }
141 /* Dead Q - act like a RAID 5 small write */
142 RF_CREATE_DAG_FUNC_DECL(rf_PQ_001_CreateSmallWriteDAG)
143 {
144 rf_CommonCreateSmallWriteDAG(raidPtr, asmap, dag_h, bp, flags,
145 allocList, &rf_pFuncs, NULL);
146 }
147 /* Dead P - act like a RAID 5 large write but for Q */
148 RF_CREATE_DAG_FUNC_DECL(rf_PQ_010_CreateLargeWriteDAG)
149 {
150 RF_PhysDiskAddr_t *temp;
151 /* swap P and Q pointers to fake out the code */
152 temp = asmap->parityInfo;
153 asmap->parityInfo = asmap->qInfo;
154 asmap->qInfo = temp;
155 rf_CommonCreateLargeWriteDAG(raidPtr, asmap, dag_h, bp, flags,
156 allocList, 1, rf_RegularQFunc, RF_FALSE);
157 }
158 /* Dead Q - act like a RAID 5 large write */
159 RF_CREATE_DAG_FUNC_DECL(rf_PQ_001_CreateLargeWriteDAG)
160 {
161 rf_CommonCreateLargeWriteDAG(raidPtr, asmap, dag_h, bp, flags,
162 allocList, 1, rf_RegularPFunc, RF_FALSE);
163 }
164
165
166 /*
167 * writes, double failure
168 */
169
170 /*
171 * Lost P & Q - do a nonredundant write
172 */
173 RF_CREATE_DAG_FUNC_DECL(rf_PQ_011_CreateWriteDAG)
174 {
175 rf_CreateNonRedundantWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList,
176 RF_IO_TYPE_WRITE);
177 }
178 /*
179 In the two cases below,
180 A nasty case arises when the write a (strict) portion of a failed stripe unit
181 and parts of another su. For now, we do not support this.
182 */
183
184 /*
185 Lost Data and P - do a Q write.
186 */
187 RF_CREATE_DAG_FUNC_DECL(rf_PQ_110_CreateWriteDAG)
188 {
189 RF_PhysDiskAddr_t *temp;
190
191 if (asmap->numStripeUnitsAccessed != 1 &&
192 asmap->failedPDAs[0]->numSector != raidPtr->Layout.sectorsPerStripeUnit) {
193 RF_PANIC();
194 }
195 /* swap P and Q to fake out parity code */
196 temp = asmap->parityInfo;
197 asmap->parityInfo = asmap->qInfo;
198 asmap->qInfo = temp;
199 rf_CommonCreateSimpleDegradedWriteDAG(raidPtr, asmap, dag_h, bp, flags,
200 allocList, 1,
201 (int (*) (RF_DagNode_t *)) rf_PQ_DegradedWriteQFunc,
202 RF_FALSE);
203 /* is the regular Q func the right one to call? */
204 }
205 /*
206 Lost Data and Q - do degraded mode P write
207 */
208 RF_CREATE_DAG_FUNC_DECL(rf_PQ_101_CreateWriteDAG)
209 {
210 if (asmap->numStripeUnitsAccessed != 1 &&
211 asmap->failedPDAs[0]->numSector != raidPtr->Layout.sectorsPerStripeUnit)
212 RF_PANIC();
213 rf_CommonCreateSimpleDegradedWriteDAG(raidPtr, asmap, dag_h, bp, flags,
214 allocList, 1, rf_RecoveryXorFunc, RF_FALSE);
215 }
216 #endif /* (RF_INCLUDE_DECL_PQ > 0) ||
217 * (RF_INCLUDE_RAID6 > 0) */
218