rf_raid4.c revision 1.3.8.1 1 /* $NetBSD: rf_raid4.c,v 1.3.8.1 2000/11/20 11:42:58 bouyer Exp $ */
2 /*
3 * Copyright (c) 1995 Carnegie-Mellon University.
4 * All rights reserved.
5 *
6 * Author: Rachad Youssef
7 *
8 * Permission to use, copy, modify and distribute this software and
9 * its documentation is hereby granted, provided that both the copyright
10 * notice and this permission notice appear in all copies of the
11 * software, derivative works or modified versions, and any portions
12 * thereof, and that both notices appear in supporting documentation.
13 *
14 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
15 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
16 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
17 *
18 * Carnegie Mellon requests users of this software to return to
19 *
20 * Software Distribution Coordinator or Software.Distribution (at) CS.CMU.EDU
21 * School of Computer Science
22 * Carnegie Mellon University
23 * Pittsburgh PA 15213-3890
24 *
25 * any improvements or extensions that they make and grant Carnegie the
26 * rights to redistribute these changes.
27 */
28
29 /***************************************
30 *
31 * rf_raid4.c -- implements RAID Level 4
32 *
33 ***************************************/
34
35 #include "rf_raid.h"
36 #include "rf_dag.h"
37 #include "rf_dagutils.h"
38 #include "rf_dagfuncs.h"
39 #include "rf_dagffrd.h"
40 #include "rf_dagffwr.h"
41 #include "rf_dagdegrd.h"
42 #include "rf_dagdegwr.h"
43 #include "rf_raid4.h"
44 #include "rf_general.h"
45
46 typedef struct RF_Raid4ConfigInfo_s {
47 RF_RowCol_t *stripeIdentifier; /* filled in at config time & used by
48 * IdentifyStripe */
49 } RF_Raid4ConfigInfo_t;
50
51
52
53 int
54 rf_ConfigureRAID4(
55 RF_ShutdownList_t ** listp,
56 RF_Raid_t * raidPtr,
57 RF_Config_t * cfgPtr)
58 {
59 RF_RaidLayout_t *layoutPtr = &raidPtr->Layout;
60 RF_Raid4ConfigInfo_t *info;
61 int i;
62
63 /* create a RAID level 4 configuration structure ... */
64 RF_MallocAndAdd(info, sizeof(RF_Raid4ConfigInfo_t), (RF_Raid4ConfigInfo_t *), raidPtr->cleanupList);
65 if (info == NULL)
66 return (ENOMEM);
67 layoutPtr->layoutSpecificInfo = (void *) info;
68
69 /* ... and fill it in. */
70 RF_MallocAndAdd(info->stripeIdentifier, raidPtr->numCol * sizeof(RF_RowCol_t), (RF_RowCol_t *), raidPtr->cleanupList);
71 if (info->stripeIdentifier == NULL)
72 return (ENOMEM);
73 for (i = 0; i < raidPtr->numCol; i++)
74 info->stripeIdentifier[i] = i;
75
76 RF_ASSERT(raidPtr->numRow == 1);
77
78 /* fill in the remaining layout parameters */
79 layoutPtr->numStripe = layoutPtr->stripeUnitsPerDisk;
80 layoutPtr->bytesPerStripeUnit = layoutPtr->sectorsPerStripeUnit << raidPtr->logBytesPerSector;
81 layoutPtr->numDataCol = raidPtr->numCol - 1;
82 layoutPtr->dataSectorsPerStripe = layoutPtr->numDataCol * layoutPtr->sectorsPerStripeUnit;
83 layoutPtr->numParityCol = 1;
84 raidPtr->totalSectors = layoutPtr->stripeUnitsPerDisk * layoutPtr->numDataCol * layoutPtr->sectorsPerStripeUnit;
85
86 return (0);
87 }
88
89 int
90 rf_GetDefaultNumFloatingReconBuffersRAID4(RF_Raid_t * raidPtr)
91 {
92 return (20);
93 }
94
95 RF_HeadSepLimit_t
96 rf_GetDefaultHeadSepLimitRAID4(RF_Raid_t * raidPtr)
97 {
98 return (20);
99 }
100
101 void
102 rf_MapSectorRAID4(
103 RF_Raid_t * raidPtr,
104 RF_RaidAddr_t raidSector,
105 RF_RowCol_t * row,
106 RF_RowCol_t * col,
107 RF_SectorNum_t * diskSector,
108 int remap)
109 {
110 RF_StripeNum_t SUID = raidSector / raidPtr->Layout.sectorsPerStripeUnit;
111 *row = 0;
112 *col = SUID % raidPtr->Layout.numDataCol;
113 *diskSector = (SUID / (raidPtr->Layout.numDataCol)) * raidPtr->Layout.sectorsPerStripeUnit +
114 (raidSector % raidPtr->Layout.sectorsPerStripeUnit);
115 }
116
117 void
118 rf_MapParityRAID4(
119 RF_Raid_t * raidPtr,
120 RF_RaidAddr_t raidSector,
121 RF_RowCol_t * row,
122 RF_RowCol_t * col,
123 RF_SectorNum_t * diskSector,
124 int remap)
125 {
126 RF_StripeNum_t SUID = raidSector / raidPtr->Layout.sectorsPerStripeUnit;
127
128 *row = 0;
129 *col = raidPtr->Layout.numDataCol;
130 *diskSector = (SUID / (raidPtr->Layout.numDataCol)) * raidPtr->Layout.sectorsPerStripeUnit +
131 (raidSector % raidPtr->Layout.sectorsPerStripeUnit);
132 }
133
134 void
135 rf_IdentifyStripeRAID4(
136 RF_Raid_t * raidPtr,
137 RF_RaidAddr_t addr,
138 RF_RowCol_t ** diskids,
139 RF_RowCol_t * outRow)
140 {
141 RF_Raid4ConfigInfo_t *info = raidPtr->Layout.layoutSpecificInfo;
142
143 *outRow = 0;
144 *diskids = info->stripeIdentifier;
145 }
146
147 void
148 rf_MapSIDToPSIDRAID4(
149 RF_RaidLayout_t * layoutPtr,
150 RF_StripeNum_t stripeID,
151 RF_StripeNum_t * psID,
152 RF_ReconUnitNum_t * which_ru)
153 {
154 *which_ru = 0;
155 *psID = stripeID;
156 }
157