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