rf_raid0.c revision 1.12 1 1.12 perry /* $NetBSD: rf_raid0.c,v 1.12 2005/02/27 00:27:45 perry Exp $ */
2 1.1 oster /*
3 1.1 oster * Copyright (c) 1995 Carnegie-Mellon University.
4 1.1 oster * All rights reserved.
5 1.1 oster *
6 1.1 oster * Author: Mark Holland
7 1.1 oster *
8 1.1 oster * Permission to use, copy, modify and distribute this software and
9 1.1 oster * its documentation is hereby granted, provided that both the copyright
10 1.1 oster * notice and this permission notice appear in all copies of the
11 1.1 oster * software, derivative works or modified versions, and any portions
12 1.1 oster * thereof, and that both notices appear in supporting documentation.
13 1.1 oster *
14 1.1 oster * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
15 1.1 oster * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
16 1.1 oster * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
17 1.1 oster *
18 1.1 oster * Carnegie Mellon requests users of this software to return to
19 1.1 oster *
20 1.1 oster * Software Distribution Coordinator or Software.Distribution (at) CS.CMU.EDU
21 1.1 oster * School of Computer Science
22 1.1 oster * Carnegie Mellon University
23 1.1 oster * Pittsburgh PA 15213-3890
24 1.1 oster *
25 1.1 oster * any improvements or extensions that they make and grant Carnegie the
26 1.1 oster * rights to redistribute these changes.
27 1.1 oster */
28 1.1 oster
29 1.1 oster /***************************************
30 1.1 oster *
31 1.1 oster * rf_raid0.c -- implements RAID Level 0
32 1.1 oster *
33 1.1 oster ***************************************/
34 1.6 lukem
35 1.6 lukem #include <sys/cdefs.h>
36 1.12 perry __KERNEL_RCSID(0, "$NetBSD: rf_raid0.c,v 1.12 2005/02/27 00:27:45 perry Exp $");
37 1.1 oster
38 1.5 oster #include <dev/raidframe/raidframevar.h>
39 1.5 oster
40 1.1 oster #include "rf_raid.h"
41 1.1 oster #include "rf_raid0.h"
42 1.1 oster #include "rf_dag.h"
43 1.1 oster #include "rf_dagffrd.h"
44 1.1 oster #include "rf_dagffwr.h"
45 1.1 oster #include "rf_dagutils.h"
46 1.1 oster #include "rf_dagfuncs.h"
47 1.1 oster #include "rf_general.h"
48 1.1 oster #include "rf_parityscan.h"
49 1.1 oster
50 1.1 oster typedef struct RF_Raid0ConfigInfo_s {
51 1.3 oster RF_RowCol_t *stripeIdentifier;
52 1.3 oster } RF_Raid0ConfigInfo_t;
53 1.1 oster
54 1.12 perry int
55 1.9 oster rf_ConfigureRAID0(RF_ShutdownList_t **listp, RF_Raid_t *raidPtr,
56 1.9 oster RF_Config_t *cfgPtr)
57 1.3 oster {
58 1.3 oster RF_RaidLayout_t *layoutPtr = &raidPtr->Layout;
59 1.3 oster RF_Raid0ConfigInfo_t *info;
60 1.3 oster RF_RowCol_t i;
61 1.3 oster
62 1.3 oster /* create a RAID level 0 configuration structure */
63 1.3 oster RF_MallocAndAdd(info, sizeof(RF_Raid0ConfigInfo_t), (RF_Raid0ConfigInfo_t *), raidPtr->cleanupList);
64 1.3 oster if (info == NULL)
65 1.3 oster return (ENOMEM);
66 1.3 oster layoutPtr->layoutSpecificInfo = (void *) info;
67 1.3 oster
68 1.3 oster RF_MallocAndAdd(info->stripeIdentifier, raidPtr->numCol * sizeof(RF_RowCol_t), (RF_RowCol_t *), raidPtr->cleanupList);
69 1.3 oster if (info->stripeIdentifier == NULL)
70 1.3 oster return (ENOMEM);
71 1.3 oster for (i = 0; i < raidPtr->numCol; i++)
72 1.3 oster info->stripeIdentifier[i] = i;
73 1.3 oster
74 1.3 oster raidPtr->totalSectors = layoutPtr->stripeUnitsPerDisk * raidPtr->numCol * layoutPtr->sectorsPerStripeUnit;
75 1.3 oster layoutPtr->numStripe = layoutPtr->stripeUnitsPerDisk;
76 1.3 oster layoutPtr->dataSectorsPerStripe = raidPtr->numCol * layoutPtr->sectorsPerStripeUnit;
77 1.3 oster layoutPtr->numDataCol = raidPtr->numCol;
78 1.3 oster layoutPtr->numParityCol = 0;
79 1.3 oster return (0);
80 1.3 oster }
81 1.3 oster
82 1.12 perry void
83 1.9 oster rf_MapSectorRAID0(RF_Raid_t *raidPtr, RF_RaidAddr_t raidSector,
84 1.9 oster RF_RowCol_t *col, RF_SectorNum_t *diskSector, int remap)
85 1.3 oster {
86 1.3 oster RF_StripeNum_t SUID = raidSector / raidPtr->Layout.sectorsPerStripeUnit;
87 1.3 oster *col = SUID % raidPtr->numCol;
88 1.3 oster *diskSector = (SUID / raidPtr->numCol) * raidPtr->Layout.sectorsPerStripeUnit +
89 1.3 oster (raidSector % raidPtr->Layout.sectorsPerStripeUnit);
90 1.3 oster }
91 1.3 oster
92 1.12 perry void
93 1.9 oster rf_MapParityRAID0(RF_Raid_t *raidPtr, RF_RaidAddr_t raidSector,
94 1.9 oster RF_RowCol_t *col, RF_SectorNum_t *diskSector, int remap)
95 1.3 oster {
96 1.8 oster *col = 0;
97 1.3 oster *diskSector = 0;
98 1.3 oster }
99 1.3 oster
100 1.12 perry void
101 1.9 oster rf_IdentifyStripeRAID0(RF_Raid_t *raidPtr, RF_RaidAddr_t addr,
102 1.9 oster RF_RowCol_t **diskids)
103 1.3 oster {
104 1.3 oster RF_Raid0ConfigInfo_t *info;
105 1.3 oster
106 1.3 oster info = raidPtr->Layout.layoutSpecificInfo;
107 1.3 oster *diskids = info->stripeIdentifier;
108 1.3 oster }
109 1.3 oster
110 1.12 perry void
111 1.9 oster rf_MapSIDToPSIDRAID0(RF_RaidLayout_t *layoutPtr, RF_StripeNum_t stripeID,
112 1.9 oster RF_StripeNum_t *psID, RF_ReconUnitNum_t *which_ru)
113 1.3 oster {
114 1.3 oster *which_ru = 0;
115 1.3 oster *psID = stripeID;
116 1.3 oster }
117 1.3 oster
118 1.12 perry void
119 1.3 oster rf_RAID0DagSelect(
120 1.3 oster RF_Raid_t * raidPtr,
121 1.3 oster RF_IoType_t type,
122 1.3 oster RF_AccessStripeMap_t * asmap,
123 1.3 oster RF_VoidFuncPtr * createFunc)
124 1.3 oster {
125 1.10 oster if (raidPtr->numFailures > 0) {
126 1.10 oster *createFunc = NULL;
127 1.10 oster return;
128 1.10 oster }
129 1.3 oster *createFunc = ((type == RF_IO_TYPE_READ) ?
130 1.3 oster (RF_VoidFuncPtr) rf_CreateFaultFreeReadDAG : (RF_VoidFuncPtr) rf_CreateRAID0WriteDAG);
131 1.3 oster }
132 1.3 oster
133 1.12 perry int
134 1.9 oster rf_VerifyParityRAID0(RF_Raid_t *raidPtr, RF_RaidAddr_t raidAddr,
135 1.9 oster RF_PhysDiskAddr_t *parityPDA, int correct_it,
136 1.9 oster RF_RaidAccessFlags_t flags)
137 1.3 oster {
138 1.3 oster /*
139 1.3 oster * No parity is always okay.
140 1.3 oster */
141 1.3 oster return (RF_PARITY_OKAY);
142 1.1 oster }
143