summaryrefslogtreecommitdiffstats
path: root/sys/dev/raidframe/rf_evenodd_dags.c
blob: e644504a65ff4f0f69d59c14c4b9f40931d9e658 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
/*	$FreeBSD$ */
/*	$NetBSD: rf_evenodd_dags.c,v 1.2 1999/02/05 00:06:11 oster Exp $	*/
/*
 * rf_evenodd_dags.c
 */
/*
 * Copyright (c) 1996 Carnegie-Mellon University.
 * All rights reserved.
 *
 * Author: Chang-Ming Wu
 *
 * Permission to use, copy, modify and distribute this software and
 * its documentation is hereby granted, provided that both the copyright
 * notice and this permission notice appear in all copies of the
 * software, derivative works or modified versions, and any portions
 * thereof, and that both notices appear in supporting documentation.
 *
 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
 * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
 *
 * Carnegie Mellon requests users of this software to return to
 *
 *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
 *  School of Computer Science
 *  Carnegie Mellon University
 *  Pittsburgh PA 15213-3890
 *
 * any improvements or extensions that they make and grant Carnegie the
 * rights to redistribute these changes.
 */

#include <dev/raidframe/rf_archs.h>

#if RF_INCLUDE_EVENODD > 0

#include <dev/raidframe/rf_types.h>
#include <dev/raidframe/rf_raid.h>
#include <dev/raidframe/rf_dag.h>
#include <dev/raidframe/rf_dagfuncs.h>
#include <dev/raidframe/rf_dagutils.h>
#include <dev/raidframe/rf_etimer.h>
#include <dev/raidframe/rf_acctrace.h>
#include <dev/raidframe/rf_general.h>
#include <dev/raidframe/rf_evenodd_dags.h>
#include <dev/raidframe/rf_evenodd.h>
#include <dev/raidframe/rf_evenodd_dagfuncs.h>
#include <dev/raidframe/rf_pq.h>
#include <dev/raidframe/rf_dagdegrd.h>
#include <dev/raidframe/rf_dagdegwr.h>
#include <dev/raidframe/rf_dagffwr.h>


/*
 * Lost one data.
 * Use P to reconstruct missing data.
 */
RF_CREATE_DAG_FUNC_DECL(rf_EO_100_CreateReadDAG)
{
	rf_CreateDegradedReadDAG(raidPtr, asmap, dag_h, bp, flags, allocList, &rf_eoPRecoveryFuncs);
}
/*
 * Lost data + E.
 * Use P to reconstruct missing data.
 */
RF_CREATE_DAG_FUNC_DECL(rf_EO_101_CreateReadDAG)
{
	rf_CreateDegradedReadDAG(raidPtr, asmap, dag_h, bp, flags, allocList, &rf_eoPRecoveryFuncs);
}
/*
 * Lost data + P.
 * Make E look like P, and use Eor for Xor, and we can
 * use degraded read DAG.
 */
RF_CREATE_DAG_FUNC_DECL(rf_EO_110_CreateReadDAG)
{
	RF_PhysDiskAddr_t *temp;
	/* swap P and E pointers to fake out the DegradedReadDAG code */
	temp = asmap->parityInfo;
	asmap->parityInfo = asmap->qInfo;
	asmap->qInfo = temp;
	rf_CreateDegradedReadDAG(raidPtr, asmap, dag_h, bp, flags, allocList, &rf_eoERecoveryFuncs);
}
/*
 * Lost two data.
 */
RF_CREATE_DAG_FUNC_DECL(rf_EOCreateDoubleDegradedReadDAG)
{
	rf_EO_DoubleDegRead(raidPtr, asmap, dag_h, bp, flags, allocList);
}
/*
 * Lost two data.
 */
RF_CREATE_DAG_FUNC_DECL(rf_EO_200_CreateReadDAG)
{
	rf_EOCreateDoubleDegradedReadDAG(raidPtr, asmap, dag_h, bp, flags, allocList);
}
RF_CREATE_DAG_FUNC_DECL(rf_EO_100_CreateWriteDAG)
{
	if (asmap->numStripeUnitsAccessed != 1 &&
	    asmap->failedPDAs[0]->numSector != raidPtr->Layout.sectorsPerStripeUnit)
		RF_PANIC();
	rf_CommonCreateSimpleDegradedWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, 2, (int (*) (RF_DagNode_t *)) rf_Degraded_100_EOFunc, RF_TRUE);
}
/*
 * E is dead. Small write.
 */
RF_CREATE_DAG_FUNC_DECL(rf_EO_001_CreateSmallWriteDAG)
{
	rf_CommonCreateSmallWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, &rf_EOSmallWritePFuncs, NULL);
}
/*
 * E is dead. Large write.
 */
RF_CREATE_DAG_FUNC_DECL(rf_EO_001_CreateLargeWriteDAG)
{
	rf_CommonCreateLargeWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, 1, rf_RegularPFunc, RF_TRUE);
}
/*
 * P is dead. Small write.
 * Swap E + P, use single-degraded stuff.
 */
RF_CREATE_DAG_FUNC_DECL(rf_EO_010_CreateSmallWriteDAG)
{
	RF_PhysDiskAddr_t *temp;
	/* swap P and E pointers to fake out the DegradedReadDAG code */
	temp = asmap->parityInfo;
	asmap->parityInfo = asmap->qInfo;
	asmap->qInfo = temp;
	rf_CommonCreateSmallWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, &rf_EOSmallWriteEFuncs, NULL);
}
/*
 * P is dead. Large write.
 * Swap E + P, use single-degraded stuff.
 */
RF_CREATE_DAG_FUNC_DECL(rf_EO_010_CreateLargeWriteDAG)
{
	RF_PhysDiskAddr_t *temp;
	/* swap P and E pointers to fake out the code */
	temp = asmap->parityInfo;
	asmap->parityInfo = asmap->qInfo;
	asmap->qInfo = temp;
	rf_CommonCreateLargeWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, 1, rf_RegularEFunc, RF_FALSE);
}
RF_CREATE_DAG_FUNC_DECL(rf_EO_011_CreateWriteDAG)
{
	rf_CreateNonRedundantWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList,
	    RF_IO_TYPE_WRITE);
}
RF_CREATE_DAG_FUNC_DECL(rf_EO_110_CreateWriteDAG)
{
	RF_PhysDiskAddr_t *temp;

	if (asmap->numStripeUnitsAccessed != 1 &&
	    asmap->failedPDAs[0]->numSector != raidPtr->Layout.sectorsPerStripeUnit) {
		RF_PANIC();
	}
	/* swap P and E to fake out parity code */
	temp = asmap->parityInfo;
	asmap->parityInfo = asmap->qInfo;
	asmap->qInfo = temp;
	rf_CommonCreateSimpleDegradedWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, 1, (int (*) (RF_DagNode_t *)) rf_EO_DegradedWriteEFunc, RF_FALSE);
	/* is the regular E func the right one to call? */
}
RF_CREATE_DAG_FUNC_DECL(rf_EO_101_CreateWriteDAG)
{
	if (asmap->numStripeUnitsAccessed != 1 &&
	    asmap->failedPDAs[0]->numSector != raidPtr->Layout.sectorsPerStripeUnit)
		RF_PANIC();
	rf_CommonCreateSimpleDegradedWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, 1, rf_RecoveryXorFunc, RF_TRUE);
}
RF_CREATE_DAG_FUNC_DECL(rf_EO_DoubleDegRead)
{
	rf_DoubleDegRead(raidPtr, asmap, dag_h, bp, flags, allocList,
	    "Re", "EvenOddRecovery", rf_EvenOddDoubleRecoveryFunc);
}
RF_CREATE_DAG_FUNC_DECL(rf_EOCreateSmallWriteDAG)
{
	rf_CommonCreateSmallWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, &rf_pFuncs, &rf_EOSmallWriteEFuncs);
}
RF_CREATE_DAG_FUNC_DECL(rf_EOCreateLargeWriteDAG)
{
	rf_CommonCreateLargeWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, 2, rf_RegularPEFunc, RF_FALSE);
}
RF_CREATE_DAG_FUNC_DECL(rf_EO_200_CreateWriteDAG)
{
	rf_DoubleDegSmallWrite(raidPtr, asmap, dag_h, bp, flags, allocList, "Re", "We", "EOWrDDRecovery", rf_EOWriteDoubleRecoveryFunc);
}
#endif				/* RF_INCLUDE_EVENODD > 0 */
OpenPOWER on IntegriCloud