1 /* $NetBSD: rf_evenodd_dags.c,v 1.3 2001/10/04 15:58:53 oster Exp $ */
6 * Copyright (c) 1996 Carnegie-Mellon University.
9 * Author: Chang-Ming Wu
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.
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.
21 * Carnegie Mellon requests users of this software to return to
23 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
24 * School of Computer Science
25 * Carnegie Mellon University
26 * Pittsburgh PA 15213-3890
28 * any improvements or extensions that they make and grant Carnegie the
29 * rights to redistribute these changes.
32 #include <sys/cdefs.h>
33 __KERNEL_RCSID(0, "$NetBSD$");
37 #if RF_INCLUDE_EVENODD > 0
39 #include <dev/raidframe/raidframevar.h>
43 #include "rf_dagfuncs.h"
44 #include "rf_dagutils.h"
45 #include "rf_etimer.h"
46 #include "rf_acctrace.h"
47 #include "rf_general.h"
48 #include "rf_evenodd_dags.h"
49 #include "rf_evenodd.h"
50 #include "rf_evenodd_dagfuncs.h"
52 #include "rf_dagdegrd.h"
53 #include "rf_dagdegwr.h"
54 #include "rf_dagffwr.h"
59 * Use P to reconstruct missing data.
61 RF_CREATE_DAG_FUNC_DECL(rf_EO_100_CreateReadDAG
)
63 rf_CreateDegradedReadDAG(raidPtr
, asmap
, dag_h
, bp
, flags
, allocList
, &rf_eoPRecoveryFuncs
);
67 * Use P to reconstruct missing data.
69 RF_CREATE_DAG_FUNC_DECL(rf_EO_101_CreateReadDAG
)
71 rf_CreateDegradedReadDAG(raidPtr
, asmap
, dag_h
, bp
, flags
, allocList
, &rf_eoPRecoveryFuncs
);
75 * Make E look like P, and use Eor for Xor, and we can
76 * use degraded read DAG.
78 RF_CREATE_DAG_FUNC_DECL(rf_EO_110_CreateReadDAG
)
80 RF_PhysDiskAddr_t
*temp
;
81 /* swap P and E pointers to fake out the DegradedReadDAG code */
82 temp
= asmap
->parityInfo
;
83 asmap
->parityInfo
= asmap
->qInfo
;
85 rf_CreateDegradedReadDAG(raidPtr
, asmap
, dag_h
, bp
, flags
, allocList
, &rf_eoERecoveryFuncs
);
90 RF_CREATE_DAG_FUNC_DECL(rf_EOCreateDoubleDegradedReadDAG
)
92 rf_EO_DoubleDegRead(raidPtr
, asmap
, dag_h
, bp
, flags
, allocList
);
97 RF_CREATE_DAG_FUNC_DECL(rf_EO_200_CreateReadDAG
)
99 rf_EOCreateDoubleDegradedReadDAG(raidPtr
, asmap
, dag_h
, bp
, flags
, allocList
);
101 RF_CREATE_DAG_FUNC_DECL(rf_EO_100_CreateWriteDAG
)
103 if (asmap
->numStripeUnitsAccessed
!= 1 &&
104 asmap
->failedPDAs
[0]->numSector
!= raidPtr
->Layout
.sectorsPerStripeUnit
)
106 rf_CommonCreateSimpleDegradedWriteDAG(raidPtr
, asmap
, dag_h
, bp
, flags
, allocList
, 2, (int (*) (RF_DagNode_t
*)) rf_Degraded_100_EOFunc
, RF_TRUE
);
109 * E is dead. Small write.
111 RF_CREATE_DAG_FUNC_DECL(rf_EO_001_CreateSmallWriteDAG
)
113 rf_CommonCreateSmallWriteDAG(raidPtr
, asmap
, dag_h
, bp
, flags
, allocList
, &rf_EOSmallWritePFuncs
, NULL
);
116 * E is dead. Large write.
118 RF_CREATE_DAG_FUNC_DECL(rf_EO_001_CreateLargeWriteDAG
)
120 rf_CommonCreateLargeWriteDAG(raidPtr
, asmap
, dag_h
, bp
, flags
, allocList
, 1, rf_RegularPFunc
, RF_TRUE
);
123 * P is dead. Small write.
124 * Swap E + P, use single-degraded stuff.
126 RF_CREATE_DAG_FUNC_DECL(rf_EO_010_CreateSmallWriteDAG
)
128 RF_PhysDiskAddr_t
*temp
;
129 /* swap P and E pointers to fake out the DegradedReadDAG code */
130 temp
= asmap
->parityInfo
;
131 asmap
->parityInfo
= asmap
->qInfo
;
133 rf_CommonCreateSmallWriteDAG(raidPtr
, asmap
, dag_h
, bp
, flags
, allocList
, &rf_EOSmallWriteEFuncs
, NULL
);
136 * P is dead. Large write.
137 * Swap E + P, use single-degraded stuff.
139 RF_CREATE_DAG_FUNC_DECL(rf_EO_010_CreateLargeWriteDAG
)
141 RF_PhysDiskAddr_t
*temp
;
142 /* swap P and E pointers to fake out the code */
143 temp
= asmap
->parityInfo
;
144 asmap
->parityInfo
= asmap
->qInfo
;
146 rf_CommonCreateLargeWriteDAG(raidPtr
, asmap
, dag_h
, bp
, flags
, allocList
, 1, rf_RegularEFunc
, RF_FALSE
);
148 RF_CREATE_DAG_FUNC_DECL(rf_EO_011_CreateWriteDAG
)
150 rf_CreateNonRedundantWriteDAG(raidPtr
, asmap
, dag_h
, bp
, flags
, allocList
,
153 RF_CREATE_DAG_FUNC_DECL(rf_EO_110_CreateWriteDAG
)
155 RF_PhysDiskAddr_t
*temp
;
157 if (asmap
->numStripeUnitsAccessed
!= 1 &&
158 asmap
->failedPDAs
[0]->numSector
!= raidPtr
->Layout
.sectorsPerStripeUnit
) {
161 /* swap P and E to fake out parity code */
162 temp
= asmap
->parityInfo
;
163 asmap
->parityInfo
= asmap
->qInfo
;
165 rf_CommonCreateSimpleDegradedWriteDAG(raidPtr
, asmap
, dag_h
, bp
, flags
, allocList
, 1, (int (*) (RF_DagNode_t
*)) rf_EO_DegradedWriteEFunc
, RF_FALSE
);
166 /* is the regular E func the right one to call? */
168 RF_CREATE_DAG_FUNC_DECL(rf_EO_101_CreateWriteDAG
)
170 if (asmap
->numStripeUnitsAccessed
!= 1 &&
171 asmap
->failedPDAs
[0]->numSector
!= raidPtr
->Layout
.sectorsPerStripeUnit
)
173 rf_CommonCreateSimpleDegradedWriteDAG(raidPtr
, asmap
, dag_h
, bp
, flags
, allocList
, 1, rf_RecoveryXorFunc
, RF_TRUE
);
175 RF_CREATE_DAG_FUNC_DECL(rf_EO_DoubleDegRead
)
177 rf_DoubleDegRead(raidPtr
, asmap
, dag_h
, bp
, flags
, allocList
,
178 "Re", "EvenOddRecovery", rf_EvenOddDoubleRecoveryFunc
);
180 RF_CREATE_DAG_FUNC_DECL(rf_EOCreateSmallWriteDAG
)
182 rf_CommonCreateSmallWriteDAG(raidPtr
, asmap
, dag_h
, bp
, flags
, allocList
, &rf_pFuncs
, &rf_EOSmallWriteEFuncs
);
184 RF_CREATE_DAG_FUNC_DECL(rf_EOCreateLargeWriteDAG
)
186 rf_CommonCreateLargeWriteDAG(raidPtr
, asmap
, dag_h
, bp
, flags
, allocList
, 2, rf_RegularPEFunc
, RF_FALSE
);
188 RF_CREATE_DAG_FUNC_DECL(rf_EO_200_CreateWriteDAG
)
190 rf_DoubleDegSmallWrite(raidPtr
, asmap
, dag_h
, bp
, flags
, allocList
, "Re", "We", "EOWrDDRecovery", rf_EOWriteDoubleRecoveryFunc
);
192 #endif /* RF_INCLUDE_EVENODD > 0 */