1 /* $NetBSD: rf_raid4.c,v 1.4 2000/01/07 03:41:02 oster Exp $ */
6 * Copyright (c) 1995 Carnegie-Mellon University.
9 * Author: Rachad Youssef
11 * Permission to use, copy, modify and distribute this software and
12 * its documentation is hereby granted, provided that both the copyright
13 * notice and this permission notice appear in all copies of the
14 * software, derivative works or modified versions, and any portions
15 * thereof, and that both notices appear in supporting documentation.
17 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
18 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
19 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
21 * Carnegie Mellon requests users of this software to return to
23 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
24 * School of Computer Science
25 * Carnegie Mellon University
26 * Pittsburgh PA 15213-3890
28 * any improvements or extensions that they make and grant Carnegie the
29 * rights to redistribute these changes.
32 /***************************************
34 * rf_raid4.c -- implements RAID Level 4
36 ***************************************/
38 #include <dev/raidframe/rf_raid.h>
39 #include <dev/raidframe/rf_dag.h>
40 #include <dev/raidframe/rf_dagutils.h>
41 #include <dev/raidframe/rf_dagfuncs.h>
42 #include <dev/raidframe/rf_dagffrd.h>
43 #include <dev/raidframe/rf_dagffwr.h>
44 #include <dev/raidframe/rf_dagdegrd.h>
45 #include <dev/raidframe/rf_dagdegwr.h>
46 #include <dev/raidframe/rf_raid4.h>
47 #include <dev/raidframe/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;
58 RF_ShutdownList_t ** listp,
62 RF_RaidLayout_t *layoutPtr = &raidPtr->Layout;
63 RF_Raid4ConfigInfo_t *info;
66 /* create a RAID level 4 configuration structure ... */
67 RF_MallocAndAdd(info, sizeof(RF_Raid4ConfigInfo_t), (RF_Raid4ConfigInfo_t *), raidPtr->cleanupList);
70 layoutPtr->layoutSpecificInfo = (void *) info;
72 /* ... and fill it in. */
73 RF_MallocAndAdd(info->stripeIdentifier, raidPtr->numCol * sizeof(RF_RowCol_t), (RF_RowCol_t *), raidPtr->cleanupList);
74 if (info->stripeIdentifier == NULL)
76 for (i = 0; i < raidPtr->numCol; i++)
77 info->stripeIdentifier[i] = i;
79 RF_ASSERT(raidPtr->numRow == 1);
81 /* fill in the remaining layout parameters */
82 layoutPtr->numStripe = layoutPtr->stripeUnitsPerDisk;
83 layoutPtr->bytesPerStripeUnit = layoutPtr->sectorsPerStripeUnit << raidPtr->logBytesPerSector;
84 layoutPtr->numDataCol = raidPtr->numCol - 1;
85 layoutPtr->dataSectorsPerStripe = layoutPtr->numDataCol * layoutPtr->sectorsPerStripeUnit;
86 layoutPtr->numParityCol = 1;
87 raidPtr->totalSectors = layoutPtr->stripeUnitsPerDisk * layoutPtr->numDataCol * layoutPtr->sectorsPerStripeUnit;
93 rf_GetDefaultNumFloatingReconBuffersRAID4(RF_Raid_t * raidPtr)
99 rf_GetDefaultHeadSepLimitRAID4(RF_Raid_t * raidPtr)
107 RF_RaidAddr_t raidSector,
110 RF_SectorNum_t * diskSector,
113 RF_StripeNum_t SUID = raidSector / raidPtr->Layout.sectorsPerStripeUnit;
115 *col = SUID % raidPtr->Layout.numDataCol;
116 *diskSector = (SUID / (raidPtr->Layout.numDataCol)) * raidPtr->Layout.sectorsPerStripeUnit +
117 (raidSector % raidPtr->Layout.sectorsPerStripeUnit);
123 RF_RaidAddr_t raidSector,
126 RF_SectorNum_t * diskSector,
129 RF_StripeNum_t SUID = raidSector / raidPtr->Layout.sectorsPerStripeUnit;
132 *col = raidPtr->Layout.numDataCol;
133 *diskSector = (SUID / (raidPtr->Layout.numDataCol)) * raidPtr->Layout.sectorsPerStripeUnit +
134 (raidSector % raidPtr->Layout.sectorsPerStripeUnit);
138 rf_IdentifyStripeRAID4(
141 RF_RowCol_t ** diskids,
142 RF_RowCol_t * outRow)
144 RF_Raid4ConfigInfo_t *info = raidPtr->Layout.layoutSpecificInfo;
147 *diskids = info->stripeIdentifier;
151 rf_MapSIDToPSIDRAID4(
152 RF_RaidLayout_t * layoutPtr,
153 RF_StripeNum_t stripeID,
154 RF_StripeNum_t * psID,
155 RF_ReconUnitNum_t * which_ru)