rf_evenodd_dags.c revision 1.2.20.1 1 /* $NetBSD: rf_evenodd_dags.c,v 1.2.20.1 2001/10/22 20:41:36 nathanw Exp $ */
2 /*
3 * rf_evenodd_dags.c
4 */
5 /*
6 * Copyright (c) 1996 Carnegie-Mellon University.
7 * All rights reserved.
8 *
9 * Author: Chang-Ming Wu
10 *
11 * Permission to use, copy, modify and distribute this software and
12 * its documentation is hereby granted, provided that both the copyright
13 * notice and this permission notice appear in all copies of the
14 * software, derivative works or modified versions, and any portions
15 * thereof, and that both notices appear in supporting documentation.
16 *
17 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
18 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
19 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
20 *
21 * Carnegie Mellon requests users of this software to return to
22 *
23 * Software Distribution Coordinator or Software.Distribution (at) CS.CMU.EDU
24 * School of Computer Science
25 * Carnegie Mellon University
26 * Pittsburgh PA 15213-3890
27 *
28 * any improvements or extensions that they make and grant Carnegie the
29 * rights to redistribute these changes.
30 */
31
32 #include "rf_archs.h"
33
34 #if RF_INCLUDE_EVENODD > 0
35
36 #include <dev/raidframe/raidframevar.h>
37
38 #include "rf_raid.h"
39 #include "rf_dag.h"
40 #include "rf_dagfuncs.h"
41 #include "rf_dagutils.h"
42 #include "rf_etimer.h"
43 #include "rf_acctrace.h"
44 #include "rf_general.h"
45 #include "rf_evenodd_dags.h"
46 #include "rf_evenodd.h"
47 #include "rf_evenodd_dagfuncs.h"
48 #include "rf_pq.h"
49 #include "rf_dagdegrd.h"
50 #include "rf_dagdegwr.h"
51 #include "rf_dagffwr.h"
52
53
54 /*
55 * Lost one data.
56 * Use P to reconstruct missing data.
57 */
58 RF_CREATE_DAG_FUNC_DECL(rf_EO_100_CreateReadDAG)
59 {
60 rf_CreateDegradedReadDAG(raidPtr, asmap, dag_h, bp, flags, allocList, &rf_eoPRecoveryFuncs);
61 }
62 /*
63 * Lost data + E.
64 * Use P to reconstruct missing data.
65 */
66 RF_CREATE_DAG_FUNC_DECL(rf_EO_101_CreateReadDAG)
67 {
68 rf_CreateDegradedReadDAG(raidPtr, asmap, dag_h, bp, flags, allocList, &rf_eoPRecoveryFuncs);
69 }
70 /*
71 * Lost data + P.
72 * Make E look like P, and use Eor for Xor, and we can
73 * use degraded read DAG.
74 */
75 RF_CREATE_DAG_FUNC_DECL(rf_EO_110_CreateReadDAG)
76 {
77 RF_PhysDiskAddr_t *temp;
78 /* swap P and E pointers to fake out the DegradedReadDAG code */
79 temp = asmap->parityInfo;
80 asmap->parityInfo = asmap->qInfo;
81 asmap->qInfo = temp;
82 rf_CreateDegradedReadDAG(raidPtr, asmap, dag_h, bp, flags, allocList, &rf_eoERecoveryFuncs);
83 }
84 /*
85 * Lost two data.
86 */
87 RF_CREATE_DAG_FUNC_DECL(rf_EOCreateDoubleDegradedReadDAG)
88 {
89 rf_EO_DoubleDegRead(raidPtr, asmap, dag_h, bp, flags, allocList);
90 }
91 /*
92 * Lost two data.
93 */
94 RF_CREATE_DAG_FUNC_DECL(rf_EO_200_CreateReadDAG)
95 {
96 rf_EOCreateDoubleDegradedReadDAG(raidPtr, asmap, dag_h, bp, flags, allocList);
97 }
98 RF_CREATE_DAG_FUNC_DECL(rf_EO_100_CreateWriteDAG)
99 {
100 if (asmap->numStripeUnitsAccessed != 1 &&
101 asmap->failedPDAs[0]->numSector != raidPtr->Layout.sectorsPerStripeUnit)
102 RF_PANIC();
103 rf_CommonCreateSimpleDegradedWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, 2, (int (*) (RF_DagNode_t *)) rf_Degraded_100_EOFunc, RF_TRUE);
104 }
105 /*
106 * E is dead. Small write.
107 */
108 RF_CREATE_DAG_FUNC_DECL(rf_EO_001_CreateSmallWriteDAG)
109 {
110 rf_CommonCreateSmallWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, &rf_EOSmallWritePFuncs, NULL);
111 }
112 /*
113 * E is dead. Large write.
114 */
115 RF_CREATE_DAG_FUNC_DECL(rf_EO_001_CreateLargeWriteDAG)
116 {
117 rf_CommonCreateLargeWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, 1, rf_RegularPFunc, RF_TRUE);
118 }
119 /*
120 * P is dead. Small write.
121 * Swap E + P, use single-degraded stuff.
122 */
123 RF_CREATE_DAG_FUNC_DECL(rf_EO_010_CreateSmallWriteDAG)
124 {
125 RF_PhysDiskAddr_t *temp;
126 /* swap P and E pointers to fake out the DegradedReadDAG code */
127 temp = asmap->parityInfo;
128 asmap->parityInfo = asmap->qInfo;
129 asmap->qInfo = temp;
130 rf_CommonCreateSmallWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, &rf_EOSmallWriteEFuncs, NULL);
131 }
132 /*
133 * P is dead. Large write.
134 * Swap E + P, use single-degraded stuff.
135 */
136 RF_CREATE_DAG_FUNC_DECL(rf_EO_010_CreateLargeWriteDAG)
137 {
138 RF_PhysDiskAddr_t *temp;
139 /* swap P and E pointers to fake out the code */
140 temp = asmap->parityInfo;
141 asmap->parityInfo = asmap->qInfo;
142 asmap->qInfo = temp;
143 rf_CommonCreateLargeWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, 1, rf_RegularEFunc, RF_FALSE);
144 }
145 RF_CREATE_DAG_FUNC_DECL(rf_EO_011_CreateWriteDAG)
146 {
147 rf_CreateNonRedundantWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList,
148 RF_IO_TYPE_WRITE);
149 }
150 RF_CREATE_DAG_FUNC_DECL(rf_EO_110_CreateWriteDAG)
151 {
152 RF_PhysDiskAddr_t *temp;
153
154 if (asmap->numStripeUnitsAccessed != 1 &&
155 asmap->failedPDAs[0]->numSector != raidPtr->Layout.sectorsPerStripeUnit) {
156 RF_PANIC();
157 }
158 /* swap P and E to fake out parity code */
159 temp = asmap->parityInfo;
160 asmap->parityInfo = asmap->qInfo;
161 asmap->qInfo = temp;
162 rf_CommonCreateSimpleDegradedWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, 1, (int (*) (RF_DagNode_t *)) rf_EO_DegradedWriteEFunc, RF_FALSE);
163 /* is the regular E func the right one to call? */
164 }
165 RF_CREATE_DAG_FUNC_DECL(rf_EO_101_CreateWriteDAG)
166 {
167 if (asmap->numStripeUnitsAccessed != 1 &&
168 asmap->failedPDAs[0]->numSector != raidPtr->Layout.sectorsPerStripeUnit)
169 RF_PANIC();
170 rf_CommonCreateSimpleDegradedWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, 1, rf_RecoveryXorFunc, RF_TRUE);
171 }
172 RF_CREATE_DAG_FUNC_DECL(rf_EO_DoubleDegRead)
173 {
174 rf_DoubleDegRead(raidPtr, asmap, dag_h, bp, flags, allocList,
175 "Re", "EvenOddRecovery", rf_EvenOddDoubleRecoveryFunc);
176 }
177 RF_CREATE_DAG_FUNC_DECL(rf_EOCreateSmallWriteDAG)
178 {
179 rf_CommonCreateSmallWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, &rf_pFuncs, &rf_EOSmallWriteEFuncs);
180 }
181 RF_CREATE_DAG_FUNC_DECL(rf_EOCreateLargeWriteDAG)
182 {
183 rf_CommonCreateLargeWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, 2, rf_RegularPEFunc, RF_FALSE);
184 }
185 RF_CREATE_DAG_FUNC_DECL(rf_EO_200_CreateWriteDAG)
186 {
187 rf_DoubleDegSmallWrite(raidPtr, asmap, dag_h, bp, flags, allocList, "Re", "We", "EOWrDDRecovery", rf_EOWriteDoubleRecoveryFunc);
188 }
189 #endif /* RF_INCLUDE_EVENODD > 0 */
190