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