1 1.16 christos /* $NetBSD: rf_raid0.c,v 1.16 2019/02/09 03:34:00 christos Exp $ */ 2 1.1 oster /* 3 1.1 oster * Copyright (c) 1995 Carnegie-Mellon University. 4 1.1 oster * All rights reserved. 5 1.1 oster * 6 1.1 oster * Author: Mark Holland 7 1.1 oster * 8 1.1 oster * Permission to use, copy, modify and distribute this software and 9 1.1 oster * its documentation is hereby granted, provided that both the copyright 10 1.1 oster * notice and this permission notice appear in all copies of the 11 1.1 oster * software, derivative works or modified versions, and any portions 12 1.1 oster * thereof, and that both notices appear in supporting documentation. 13 1.1 oster * 14 1.1 oster * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 15 1.1 oster * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND 16 1.1 oster * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 17 1.1 oster * 18 1.1 oster * Carnegie Mellon requests users of this software to return to 19 1.1 oster * 20 1.1 oster * Software Distribution Coordinator or Software.Distribution (at) CS.CMU.EDU 21 1.1 oster * School of Computer Science 22 1.1 oster * Carnegie Mellon University 23 1.1 oster * Pittsburgh PA 15213-3890 24 1.1 oster * 25 1.1 oster * any improvements or extensions that they make and grant Carnegie the 26 1.1 oster * rights to redistribute these changes. 27 1.1 oster */ 28 1.1 oster 29 1.1 oster /*************************************** 30 1.1 oster * 31 1.1 oster * rf_raid0.c -- implements RAID Level 0 32 1.1 oster * 33 1.1 oster ***************************************/ 34 1.6 lukem 35 1.6 lukem #include <sys/cdefs.h> 36 1.16 christos __KERNEL_RCSID(0, "$NetBSD: rf_raid0.c,v 1.16 2019/02/09 03:34:00 christos Exp $"); 37 1.1 oster 38 1.5 oster #include <dev/raidframe/raidframevar.h> 39 1.5 oster 40 1.1 oster #include "rf_raid.h" 41 1.1 oster #include "rf_raid0.h" 42 1.1 oster #include "rf_dag.h" 43 1.1 oster #include "rf_dagffrd.h" 44 1.1 oster #include "rf_dagffwr.h" 45 1.1 oster #include "rf_dagutils.h" 46 1.1 oster #include "rf_dagfuncs.h" 47 1.1 oster #include "rf_general.h" 48 1.1 oster #include "rf_parityscan.h" 49 1.1 oster 50 1.1 oster typedef struct RF_Raid0ConfigInfo_s { 51 1.3 oster RF_RowCol_t *stripeIdentifier; 52 1.3 oster } RF_Raid0ConfigInfo_t; 53 1.1 oster 54 1.12 perry int 55 1.15 christos rf_ConfigureRAID0(RF_ShutdownList_t **listp, RF_Raid_t *raidPtr, 56 1.15 christos RF_Config_t *cfgPtr) 57 1.3 oster { 58 1.3 oster RF_RaidLayout_t *layoutPtr = &raidPtr->Layout; 59 1.3 oster RF_Raid0ConfigInfo_t *info; 60 1.3 oster RF_RowCol_t i; 61 1.3 oster 62 1.3 oster /* create a RAID level 0 configuration structure */ 63 1.16 christos info = RF_MallocAndAdd(sizeof(*info), raidPtr->cleanupList); 64 1.3 oster if (info == NULL) 65 1.3 oster return (ENOMEM); 66 1.3 oster layoutPtr->layoutSpecificInfo = (void *) info; 67 1.3 oster 68 1.16 christos info->stripeIdentifier = RF_MallocAndAdd(raidPtr->numCol 69 1.16 christos * sizeof(*info->stripeIdentifier), raidPtr->cleanupList); 70 1.3 oster if (info->stripeIdentifier == NULL) 71 1.3 oster return (ENOMEM); 72 1.3 oster for (i = 0; i < raidPtr->numCol; i++) 73 1.3 oster info->stripeIdentifier[i] = i; 74 1.3 oster 75 1.3 oster raidPtr->totalSectors = layoutPtr->stripeUnitsPerDisk * raidPtr->numCol * layoutPtr->sectorsPerStripeUnit; 76 1.3 oster layoutPtr->numStripe = layoutPtr->stripeUnitsPerDisk; 77 1.3 oster layoutPtr->dataSectorsPerStripe = raidPtr->numCol * layoutPtr->sectorsPerStripeUnit; 78 1.3 oster layoutPtr->numDataCol = raidPtr->numCol; 79 1.3 oster layoutPtr->numParityCol = 0; 80 1.3 oster return (0); 81 1.3 oster } 82 1.3 oster 83 1.12 perry void 84 1.9 oster rf_MapSectorRAID0(RF_Raid_t *raidPtr, RF_RaidAddr_t raidSector, 85 1.15 christos RF_RowCol_t *col, RF_SectorNum_t *diskSector, int remap) 86 1.3 oster { 87 1.3 oster RF_StripeNum_t SUID = raidSector / raidPtr->Layout.sectorsPerStripeUnit; 88 1.3 oster *col = SUID % raidPtr->numCol; 89 1.3 oster *diskSector = (SUID / raidPtr->numCol) * raidPtr->Layout.sectorsPerStripeUnit + 90 1.3 oster (raidSector % raidPtr->Layout.sectorsPerStripeUnit); 91 1.3 oster } 92 1.3 oster 93 1.12 perry void 94 1.15 christos rf_MapParityRAID0(RF_Raid_t *raidPtr, 95 1.15 christos RF_RaidAddr_t raidSector, RF_RowCol_t *col, 96 1.15 christos RF_SectorNum_t *diskSector, int remap) 97 1.3 oster { 98 1.8 oster *col = 0; 99 1.3 oster *diskSector = 0; 100 1.3 oster } 101 1.3 oster 102 1.12 perry void 103 1.15 christos rf_IdentifyStripeRAID0(RF_Raid_t *raidPtr, RF_RaidAddr_t addr, 104 1.9 oster RF_RowCol_t **diskids) 105 1.3 oster { 106 1.3 oster RF_Raid0ConfigInfo_t *info; 107 1.3 oster 108 1.3 oster info = raidPtr->Layout.layoutSpecificInfo; 109 1.3 oster *diskids = info->stripeIdentifier; 110 1.3 oster } 111 1.3 oster 112 1.12 perry void 113 1.15 christos rf_MapSIDToPSIDRAID0(RF_RaidLayout_t *layoutPtr, 114 1.14 christos RF_StripeNum_t stripeID, RF_StripeNum_t *psID, RF_ReconUnitNum_t *which_ru) 115 1.3 oster { 116 1.3 oster *which_ru = 0; 117 1.3 oster *psID = stripeID; 118 1.3 oster } 119 1.3 oster 120 1.12 perry void 121 1.3 oster rf_RAID0DagSelect( 122 1.3 oster RF_Raid_t * raidPtr, 123 1.3 oster RF_IoType_t type, 124 1.15 christos RF_AccessStripeMap_t * asmap, 125 1.3 oster RF_VoidFuncPtr * createFunc) 126 1.3 oster { 127 1.10 oster if (raidPtr->numFailures > 0) { 128 1.10 oster *createFunc = NULL; 129 1.10 oster return; 130 1.10 oster } 131 1.3 oster *createFunc = ((type == RF_IO_TYPE_READ) ? 132 1.3 oster (RF_VoidFuncPtr) rf_CreateFaultFreeReadDAG : (RF_VoidFuncPtr) rf_CreateRAID0WriteDAG); 133 1.3 oster } 134 1.3 oster 135 1.12 perry int 136 1.15 christos rf_VerifyParityRAID0(RF_Raid_t *raidPtr, 137 1.15 christos RF_RaidAddr_t raidAddr, RF_PhysDiskAddr_t *parityPDA, 138 1.15 christos int correct_it, RF_RaidAccessFlags_t flags) 139 1.3 oster { 140 1.3 oster /* 141 1.3 oster * No parity is always okay. 142 1.3 oster */ 143 1.3 oster return (RF_PARITY_OKAY); 144 1.1 oster } 145