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