1 /* $NetBSD: rf_raid0.c,v 1.14 2006/10/12 01:31:52 christos Exp $ */
3 * Copyright (c) 1995 Carnegie-Mellon University.
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.
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.
18 * Carnegie Mellon requests users of this software to return to
20 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
21 * School of Computer Science
22 * Carnegie Mellon University
23 * Pittsburgh PA 15213-3890
25 * any improvements or extensions that they make and grant Carnegie the
26 * rights to redistribute these changes.
29 /***************************************
31 * rf_raid0.c -- implements RAID Level 0
33 ***************************************/
35 #include <sys/cdefs.h>
36 __KERNEL_RCSID(0, "$NetBSD: rf_raid0.c,v 1.14 2006/10/12 01:31:52 christos Exp $");
38 #include <dev/raidframe/raidframevar.h>
43 #include "rf_dagffrd.h"
44 #include "rf_dagffwr.h"
45 #include "rf_dagutils.h"
46 #include "rf_dagfuncs.h"
47 #include "rf_general.h"
48 #include "rf_parityscan.h"
50 typedef struct RF_Raid0ConfigInfo_s
{
51 RF_RowCol_t
*stripeIdentifier
;
52 } RF_Raid0ConfigInfo_t
;
55 rf_ConfigureRAID0(RF_ShutdownList_t
**listp
, RF_Raid_t
*raidPtr
,
58 RF_RaidLayout_t
*layoutPtr
= &raidPtr
->Layout
;
59 RF_Raid0ConfigInfo_t
*info
;
62 /* create a RAID level 0 configuration structure */
63 RF_MallocAndAdd(info
, sizeof(RF_Raid0ConfigInfo_t
), (RF_Raid0ConfigInfo_t
*), raidPtr
->cleanupList
);
66 layoutPtr
->layoutSpecificInfo
= (void *) info
;
68 RF_MallocAndAdd(info
->stripeIdentifier
, raidPtr
->numCol
* sizeof(RF_RowCol_t
), (RF_RowCol_t
*), raidPtr
->cleanupList
);
69 if (info
->stripeIdentifier
== NULL
)
71 for (i
= 0; i
< raidPtr
->numCol
; i
++)
72 info
->stripeIdentifier
[i
] = i
;
74 raidPtr
->totalSectors
= layoutPtr
->stripeUnitsPerDisk
* raidPtr
->numCol
* layoutPtr
->sectorsPerStripeUnit
;
75 layoutPtr
->numStripe
= layoutPtr
->stripeUnitsPerDisk
;
76 layoutPtr
->dataSectorsPerStripe
= raidPtr
->numCol
* layoutPtr
->sectorsPerStripeUnit
;
77 layoutPtr
->numDataCol
= raidPtr
->numCol
;
78 layoutPtr
->numParityCol
= 0;
83 rf_MapSectorRAID0(RF_Raid_t
*raidPtr
, RF_RaidAddr_t raidSector
,
84 RF_RowCol_t
*col
, RF_SectorNum_t
*diskSector
, int remap
)
86 RF_StripeNum_t SUID
= raidSector
/ raidPtr
->Layout
.sectorsPerStripeUnit
;
87 *col
= SUID
% raidPtr
->numCol
;
88 *diskSector
= (SUID
/ raidPtr
->numCol
) * raidPtr
->Layout
.sectorsPerStripeUnit
+
89 (raidSector
% raidPtr
->Layout
.sectorsPerStripeUnit
);
93 rf_MapParityRAID0(RF_Raid_t
*raidPtr
,
94 RF_RaidAddr_t raidSector
, RF_RowCol_t
*col
,
95 RF_SectorNum_t
*diskSector
, int remap
)
102 rf_IdentifyStripeRAID0(RF_Raid_t
*raidPtr
, RF_RaidAddr_t addr
,
103 RF_RowCol_t
**diskids
)
105 RF_Raid0ConfigInfo_t
*info
;
107 info
= raidPtr
->Layout
.layoutSpecificInfo
;
108 *diskids
= info
->stripeIdentifier
;
112 rf_MapSIDToPSIDRAID0(RF_RaidLayout_t
*layoutPtr
,
113 RF_StripeNum_t stripeID
, RF_StripeNum_t
*psID
, RF_ReconUnitNum_t
*which_ru
)
123 RF_AccessStripeMap_t
* asmap
,
124 RF_VoidFuncPtr
* createFunc
)
126 if (raidPtr
->numFailures
> 0) {
130 *createFunc
= ((type
== RF_IO_TYPE_READ
) ?
131 (RF_VoidFuncPtr
) rf_CreateFaultFreeReadDAG
: (RF_VoidFuncPtr
) rf_CreateRAID0WriteDAG
);
135 rf_VerifyParityRAID0(RF_Raid_t
*raidPtr
,
136 RF_RaidAddr_t raidAddr
, RF_PhysDiskAddr_t
*parityPDA
,
137 int correct_it
, RF_RaidAccessFlags_t flags
)
140 * No parity is always okay.
142 return (RF_PARITY_OKAY
);