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