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