1 /* $NetBSD: rf_raid0.c,v 1.4 2000/01/07 03:41:02 oster Exp $ */ 2 /* 3 * Copyright (c) 1995 Carnegie-Mellon University. 4 * All rights reserved. 5 * 6 * Author: Mark Holland 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@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_raid0.c -- implements RAID Level 0 32 * 33 ***************************************/ 34 35 #include "rf_types.h" 36 #include "rf_raid.h" 37 #include "rf_raid0.h" 38 #include "rf_dag.h" 39 #include "rf_dagffrd.h" 40 #include "rf_dagffwr.h" 41 #include "rf_dagutils.h" 42 #include "rf_dagfuncs.h" 43 #include "rf_general.h" 44 #include "rf_configure.h" 45 #include "rf_parityscan.h" 46 47 typedef struct RF_Raid0ConfigInfo_s { 48 RF_RowCol_t *stripeIdentifier; 49 } RF_Raid0ConfigInfo_t; 50 51 int 52 rf_ConfigureRAID0( 53 RF_ShutdownList_t ** listp, 54 RF_Raid_t * raidPtr, 55 RF_Config_t * cfgPtr) 56 { 57 RF_RaidLayout_t *layoutPtr = &raidPtr->Layout; 58 RF_Raid0ConfigInfo_t *info; 59 RF_RowCol_t i; 60 61 /* create a RAID level 0 configuration structure */ 62 RF_MallocAndAdd(info, sizeof(RF_Raid0ConfigInfo_t), (RF_Raid0ConfigInfo_t *), raidPtr->cleanupList); 63 if (info == NULL) 64 return (ENOMEM); 65 layoutPtr->layoutSpecificInfo = (void *) info; 66 67 RF_MallocAndAdd(info->stripeIdentifier, raidPtr->numCol * sizeof(RF_RowCol_t), (RF_RowCol_t *), raidPtr->cleanupList); 68 if (info->stripeIdentifier == NULL) 69 return (ENOMEM); 70 for (i = 0; i < raidPtr->numCol; i++) 71 info->stripeIdentifier[i] = i; 72 73 RF_ASSERT(raidPtr->numRow == 1); 74 raidPtr->totalSectors = layoutPtr->stripeUnitsPerDisk * raidPtr->numCol * layoutPtr->sectorsPerStripeUnit; 75 layoutPtr->numStripe = layoutPtr->stripeUnitsPerDisk; 76 layoutPtr->dataSectorsPerStripe = raidPtr->numCol * layoutPtr->sectorsPerStripeUnit; 77 layoutPtr->bytesPerStripeUnit = layoutPtr->sectorsPerStripeUnit << raidPtr->logBytesPerSector; 78 layoutPtr->numDataCol = raidPtr->numCol; 79 layoutPtr->numParityCol = 0; 80 return (0); 81 } 82 83 void 84 rf_MapSectorRAID0( 85 RF_Raid_t * raidPtr, 86 RF_RaidAddr_t raidSector, 87 RF_RowCol_t * row, 88 RF_RowCol_t * col, 89 RF_SectorNum_t * diskSector, 90 int remap) 91 { 92 RF_StripeNum_t SUID = raidSector / raidPtr->Layout.sectorsPerStripeUnit; 93 *row = 0; 94 *col = SUID % raidPtr->numCol; 95 *diskSector = (SUID / raidPtr->numCol) * raidPtr->Layout.sectorsPerStripeUnit + 96 (raidSector % raidPtr->Layout.sectorsPerStripeUnit); 97 } 98 99 void 100 rf_MapParityRAID0( 101 RF_Raid_t * raidPtr, 102 RF_RaidAddr_t raidSector, 103 RF_RowCol_t * row, 104 RF_RowCol_t * col, 105 RF_SectorNum_t * diskSector, 106 int remap) 107 { 108 *row = *col = 0; 109 *diskSector = 0; 110 } 111 112 void 113 rf_IdentifyStripeRAID0( 114 RF_Raid_t * raidPtr, 115 RF_RaidAddr_t addr, 116 RF_RowCol_t ** diskids, 117 RF_RowCol_t * outRow) 118 { 119 RF_Raid0ConfigInfo_t *info; 120 121 info = raidPtr->Layout.layoutSpecificInfo; 122 *diskids = info->stripeIdentifier; 123 *outRow = 0; 124 } 125 126 void 127 rf_MapSIDToPSIDRAID0( 128 RF_RaidLayout_t * layoutPtr, 129 RF_StripeNum_t stripeID, 130 RF_StripeNum_t * psID, 131 RF_ReconUnitNum_t * which_ru) 132 { 133 *which_ru = 0; 134 *psID = stripeID; 135 } 136 137 void 138 rf_RAID0DagSelect( 139 RF_Raid_t * raidPtr, 140 RF_IoType_t type, 141 RF_AccessStripeMap_t * asmap, 142 RF_VoidFuncPtr * createFunc) 143 { 144 *createFunc = ((type == RF_IO_TYPE_READ) ? 145 (RF_VoidFuncPtr) rf_CreateFaultFreeReadDAG : (RF_VoidFuncPtr) rf_CreateRAID0WriteDAG); 146 } 147 148 int 149 rf_VerifyParityRAID0( 150 RF_Raid_t * raidPtr, 151 RF_RaidAddr_t raidAddr, 152 RF_PhysDiskAddr_t * parityPDA, 153 int correct_it, 154 RF_RaidAccessFlags_t flags) 155 { 156 /* 157 * No parity is always okay. 158 */ 159 return (RF_PARITY_OKAY); 160 } 161