1 /* $NetBSD: rf_raid4.c,v 1.11 2006/10/12 01:31:52 christos Exp $ */
3 * Copyright (c) 1995 Carnegie-Mellon University.
6 * Author: Rachad Youssef
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_raid4.c -- implements RAID Level 4
33 ***************************************/
35 #include <sys/cdefs.h>
36 __KERNEL_RCSID(0, "$NetBSD: rf_raid4.c,v 1.11 2006/10/12 01:31:52 christos Exp $");
40 #include "rf_dagutils.h"
41 #include "rf_dagfuncs.h"
42 #include "rf_dagffrd.h"
43 #include "rf_dagffwr.h"
44 #include "rf_dagdegrd.h"
45 #include "rf_dagdegwr.h"
47 #include "rf_general.h"
49 typedef struct RF_Raid4ConfigInfo_s
{
50 RF_RowCol_t
*stripeIdentifier
; /* filled in at config time & used by
52 } RF_Raid4ConfigInfo_t
;
57 rf_ConfigureRAID4(RF_ShutdownList_t
**listp
, RF_Raid_t
*raidPtr
,
60 RF_RaidLayout_t
*layoutPtr
= &raidPtr
->Layout
;
61 RF_Raid4ConfigInfo_t
*info
;
64 /* create a RAID level 4 configuration structure ... */
65 RF_MallocAndAdd(info
, sizeof(RF_Raid4ConfigInfo_t
), (RF_Raid4ConfigInfo_t
*), raidPtr
->cleanupList
);
68 layoutPtr
->layoutSpecificInfo
= (void *) info
;
70 /* ... and fill it in. */
71 RF_MallocAndAdd(info
->stripeIdentifier
, raidPtr
->numCol
* sizeof(RF_RowCol_t
), (RF_RowCol_t
*), raidPtr
->cleanupList
);
72 if (info
->stripeIdentifier
== NULL
)
74 for (i
= 0; i
< raidPtr
->numCol
; i
++)
75 info
->stripeIdentifier
[i
] = i
;
77 /* fill in the remaining layout parameters */
78 layoutPtr
->numStripe
= layoutPtr
->stripeUnitsPerDisk
;
79 layoutPtr
->numDataCol
= raidPtr
->numCol
- 1;
80 layoutPtr
->dataSectorsPerStripe
= layoutPtr
->numDataCol
* layoutPtr
->sectorsPerStripeUnit
;
81 layoutPtr
->numParityCol
= 1;
82 raidPtr
->totalSectors
= layoutPtr
->stripeUnitsPerDisk
* layoutPtr
->numDataCol
* layoutPtr
->sectorsPerStripeUnit
;
88 rf_GetDefaultNumFloatingReconBuffersRAID4(RF_Raid_t
*raidPtr
)
94 rf_GetDefaultHeadSepLimitRAID4(RF_Raid_t
*raidPtr
)
100 rf_MapSectorRAID4(RF_Raid_t
*raidPtr
, RF_RaidAddr_t raidSector
,
101 RF_RowCol_t
*col
, RF_SectorNum_t
*diskSector
,
104 RF_StripeNum_t SUID
= raidSector
/ raidPtr
->Layout
.sectorsPerStripeUnit
;
105 *col
= SUID
% raidPtr
->Layout
.numDataCol
;
106 *diskSector
= (SUID
/ (raidPtr
->Layout
.numDataCol
)) * raidPtr
->Layout
.sectorsPerStripeUnit
+
107 (raidSector
% raidPtr
->Layout
.sectorsPerStripeUnit
);
111 rf_MapParityRAID4(RF_Raid_t
*raidPtr
, RF_RaidAddr_t raidSector
,
112 RF_RowCol_t
*col
, RF_SectorNum_t
*diskSector
,
115 RF_StripeNum_t SUID
= raidSector
/ raidPtr
->Layout
.sectorsPerStripeUnit
;
117 *col
= raidPtr
->Layout
.numDataCol
;
118 *diskSector
= (SUID
/ (raidPtr
->Layout
.numDataCol
)) * raidPtr
->Layout
.sectorsPerStripeUnit
+
119 (raidSector
% raidPtr
->Layout
.sectorsPerStripeUnit
);
123 rf_IdentifyStripeRAID4(RF_Raid_t
*raidPtr
, RF_RaidAddr_t addr
,
124 RF_RowCol_t
**diskids
)
126 RF_Raid4ConfigInfo_t
*info
= raidPtr
->Layout
.layoutSpecificInfo
;
128 *diskids
= info
->stripeIdentifier
;
132 rf_MapSIDToPSIDRAID4(RF_RaidLayout_t
*layoutPtr
,
133 RF_StripeNum_t stripeID
,
134 RF_StripeNum_t
*psID
, RF_ReconUnitNum_t
*which_ru
)