rf_pqdeg.c revision 1.2 1 /* $NetBSD: rf_pqdeg.c,v 1.2 1999/01/26 02:34:00 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 "rf_types.h"
34 #include "rf_raid.h"
35 #include "rf_dag.h"
36 #include "rf_dagutils.h"
37 #include "rf_dagfuncs.h"
38 #include "rf_dagffrd.h"
39 #include "rf_dagffwr.h"
40 #include "rf_dagdegrd.h"
41 #include "rf_dagdegwr.h"
42 #include "rf_threadid.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
76 /* Reads double failure */
77
78 /*
79 Q is lost, but not parity
80 so we can a raid 5 reconstruct read.
81 */
82
83 RF_CREATE_DAG_FUNC_DECL(rf_PQ_101_CreateReadDAG)
84 {
85 rf_CreateDegradedReadDAG(raidPtr, asmap, dag_h, bp, flags, allocList, &rf_pRecoveryFuncs);
86 }
87
88 /*
89 parity is lost, so we need to
90 do a reconstruct read and recompute
91 the data with Q.
92 */
93
94 RF_CREATE_DAG_FUNC_DECL(rf_PQ_110_CreateReadDAG)
95 {
96 RF_PhysDiskAddr_t *temp;
97 /* swap P and Q pointers to fake out the DegradedReadDAG code */
98 temp = asmap->parityInfo; asmap->parityInfo = asmap->qInfo; asmap->qInfo = temp;
99 rf_CreateDegradedReadDAG(raidPtr, asmap, dag_h, bp, flags, allocList, &rf_qRecoveryFuncs);
100 }
101
102 /*
103 Two data units are dead in this stripe, so we will need read
104 both P and Q to reconstruct the data. Note that only
105 one data unit we are reading may actually be missing.
106 */
107 RF_CREATE_DAG_FUNC_DECL(rf_CreateDoubleDegradedReadDAG)
108 {
109 rf_PQ_DoubleDegRead(raidPtr, asmap, dag_h, bp, flags, allocList);
110 }
111
112 RF_CREATE_DAG_FUNC_DECL(rf_PQ_200_CreateReadDAG)
113 {
114 rf_CreateDoubleDegradedReadDAG(raidPtr, asmap, dag_h, bp, flags, allocList);
115 }
116
117 /* Writes, single failure */
118
119 RF_CREATE_DAG_FUNC_DECL(rf_PQ_100_CreateWriteDAG)
120 {
121 if (asmap->numStripeUnitsAccessed != 1 &&
122 asmap->failedPDAs[0]->numSector != raidPtr->Layout.sectorsPerStripeUnit)
123 RF_PANIC();
124 rf_CommonCreateSimpleDegradedWriteDAG(raidPtr, asmap, dag_h, bp, flags,
125 allocList, 2, (int (*)())rf_Degraded_100_PQFunc, RF_FALSE);
126 }
127
128 /* Dead P - act like a RAID 5 small write with parity = Q */
129 RF_CREATE_DAG_FUNC_DECL(rf_PQ_010_CreateSmallWriteDAG)
130 {
131 RF_PhysDiskAddr_t *temp;
132 /* swap P and Q pointers to fake out the DegradedReadDAG code */
133 temp = asmap->parityInfo; asmap->parityInfo = asmap->qInfo; asmap->qInfo = temp;
134 rf_CommonCreateSmallWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, &rf_qFuncs, NULL);
135 }
136
137 /* Dead Q - act like a RAID 5 small write */
138 RF_CREATE_DAG_FUNC_DECL(rf_PQ_001_CreateSmallWriteDAG)
139 {
140 rf_CommonCreateSmallWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, &rf_pFuncs, NULL);
141 }
142
143 /* Dead P - act like a RAID 5 large write but for Q */
144 RF_CREATE_DAG_FUNC_DECL(rf_PQ_010_CreateLargeWriteDAG)
145 {
146 RF_PhysDiskAddr_t *temp;
147 /* swap P and Q pointers to fake out the code */
148 temp = asmap->parityInfo; asmap->parityInfo = asmap->qInfo; asmap->qInfo = temp;
149 rf_CommonCreateLargeWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, 1, rf_RegularQFunc, RF_FALSE);
150 }
151
152 /* Dead Q - act like a RAID 5 large write */
153 RF_CREATE_DAG_FUNC_DECL(rf_PQ_001_CreateLargeWriteDAG)
154 {
155 rf_CommonCreateLargeWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, 1, rf_RegularPFunc, RF_FALSE);
156 }
157
158
159 /*
160 * writes, double failure
161 */
162
163 /*
164 * Lost P & Q - do a nonredundant write
165 */
166 RF_CREATE_DAG_FUNC_DECL(rf_PQ_011_CreateWriteDAG)
167 {
168 rf_CreateNonRedundantWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList,
169 RF_IO_TYPE_WRITE);
170 }
171
172 /*
173 In the two cases below,
174 A nasty case arises when the write a (strict) portion of a failed stripe unit
175 and parts of another su. For now, we do not support this.
176 */
177
178 /*
179 Lost Data and P - do a Q write.
180 */
181 RF_CREATE_DAG_FUNC_DECL(rf_PQ_110_CreateWriteDAG)
182 {
183 RF_PhysDiskAddr_t *temp;
184
185 if (asmap->numStripeUnitsAccessed != 1 &&
186 asmap->failedPDAs[0]->numSector != raidPtr->Layout.sectorsPerStripeUnit)
187 {
188 RF_PANIC();
189 }
190 /* swap P and Q to fake out parity code */
191 temp = asmap->parityInfo;
192 asmap->parityInfo = asmap->qInfo;
193 asmap->qInfo = temp;
194 rf_CommonCreateSimpleDegradedWriteDAG(raidPtr, asmap, dag_h, bp, flags,
195 allocList,1, (int (*)())rf_PQ_DegradedWriteQFunc, RF_FALSE);
196 /* is the regular Q func the right one to call? */
197 }
198
199 /*
200 Lost Data and Q - do degraded mode P write
201 */
202 RF_CREATE_DAG_FUNC_DECL(rf_PQ_101_CreateWriteDAG)
203 {
204 if (asmap->numStripeUnitsAccessed != 1 &&
205 asmap->failedPDAs[0]->numSector != raidPtr->Layout.sectorsPerStripeUnit)
206 RF_PANIC();
207 rf_CommonCreateSimpleDegradedWriteDAG(raidPtr, asmap, dag_h, bp, flags,
208 allocList,1, rf_RecoveryXorFunc, RF_FALSE);
209 }
210
211 #endif /* (RF_INCLUDE_DECL_PQ > 0) || (RF_INCLUDE_RAID6 > 0) */
212