[BACK]Return to rf_raid4.c CVS log [TXT][DIR] Up to [local] / sys / dev / raidframe

Annotation of sys/dev/raidframe/rf_raid4.c, Revision 1.1.1.1

1.1       nbrk        1: /*     $OpenBSD: rf_raid4.c,v 1.4 2002/12/16 07:01:04 tdeval Exp $     */
                      2: /*     $NetBSD: rf_raid4.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: Rachad Youssef
                      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_raid4.c -- Implements RAID Level 4.
                     34:  *
                     35:  *****************************************/
                     36:
                     37: #include "rf_raid.h"
                     38: #include "rf_dag.h"
                     39: #include "rf_dagutils.h"
                     40: #include "rf_dagfuncs.h"
                     41: #include "rf_dagffrd.h"
                     42: #include "rf_dagffwr.h"
                     43: #include "rf_dagdegrd.h"
                     44: #include "rf_dagdegwr.h"
                     45: #include "rf_raid4.h"
                     46: #include "rf_general.h"
                     47:
                     48: typedef struct RF_Raid4ConfigInfo_s {
                     49:        RF_RowCol_t *stripeIdentifier;  /*
                     50:                                         * Filled in at config time & used by
                     51:                                         * IdentifyStripe.
                     52:                                         */
                     53: } RF_Raid4ConfigInfo_t;
                     54:
                     55:
                     56: int
                     57: rf_ConfigureRAID4(RF_ShutdownList_t **listp, RF_Raid_t *raidPtr,
                     58:     RF_Config_t *cfgPtr)
                     59: {
                     60:        RF_RaidLayout_t *layoutPtr = &raidPtr->Layout;
                     61:        RF_Raid4ConfigInfo_t *info;
                     62:        int i;
                     63:
                     64:        /* Create a RAID level 4 configuration structure... */
                     65:        RF_MallocAndAdd(info, sizeof(RF_Raid4ConfigInfo_t),
                     66:            (RF_Raid4ConfigInfo_t *), raidPtr->cleanupList);
                     67:        if (info == NULL)
                     68:                return (ENOMEM);
                     69:        layoutPtr->layoutSpecificInfo = (void *) info;
                     70:
                     71:        /* ... and fill it in. */
                     72:        RF_MallocAndAdd(info->stripeIdentifier, raidPtr->numCol *
                     73:            sizeof(RF_RowCol_t), (RF_RowCol_t *), raidPtr->cleanupList);
                     74:        if (info->stripeIdentifier == NULL)
                     75:                return (ENOMEM);
                     76:        for (i = 0; i < raidPtr->numCol; i++)
                     77:                info->stripeIdentifier[i] = i;
                     78:
                     79:        RF_ASSERT(raidPtr->numRow == 1);
                     80:
                     81:        /* Fill in the remaining layout parameters. */
                     82:        layoutPtr->numStripe = layoutPtr->stripeUnitsPerDisk;
                     83:        layoutPtr->bytesPerStripeUnit = layoutPtr->sectorsPerStripeUnit <<
                     84:            raidPtr->logBytesPerSector;
                     85:        layoutPtr->numDataCol = raidPtr->numCol - 1;
                     86:        layoutPtr->dataSectorsPerStripe = layoutPtr->numDataCol *
                     87:            layoutPtr->sectorsPerStripeUnit;
                     88:        layoutPtr->numParityCol = 1;
                     89:        raidPtr->totalSectors = layoutPtr->stripeUnitsPerDisk *
                     90:            layoutPtr->numDataCol * layoutPtr->sectorsPerStripeUnit;
                     91:
                     92:        return (0);
                     93: }
                     94:
                     95: int
                     96: rf_GetDefaultNumFloatingReconBuffersRAID4(RF_Raid_t *raidPtr)
                     97: {
                     98:        return (20);
                     99: }
                    100:
                    101: RF_HeadSepLimit_t
                    102: rf_GetDefaultHeadSepLimitRAID4(RF_Raid_t *raidPtr)
                    103: {
                    104:        return (20);
                    105: }
                    106:
                    107: void
                    108: rf_MapSectorRAID4(RF_Raid_t *raidPtr, RF_RaidAddr_t raidSector,
                    109:     RF_RowCol_t *row, RF_RowCol_t *col, RF_SectorNum_t *diskSector, int remap)
                    110: {
                    111:        RF_StripeNum_t SUID = raidSector / raidPtr->Layout.sectorsPerStripeUnit;
                    112:        *row = 0;
                    113:        *col = SUID % raidPtr->Layout.numDataCol;
                    114:        *diskSector = (SUID / (raidPtr->Layout.numDataCol)) *
                    115:            raidPtr->Layout.sectorsPerStripeUnit +
                    116:            (raidSector % raidPtr->Layout.sectorsPerStripeUnit);
                    117: }
                    118:
                    119: void
                    120: rf_MapParityRAID4(RF_Raid_t *raidPtr, RF_RaidAddr_t raidSector,
                    121:     RF_RowCol_t *row, RF_RowCol_t *col, RF_SectorNum_t *diskSector, int remap)
                    122: {
                    123:        RF_StripeNum_t SUID = raidSector / raidPtr->Layout.sectorsPerStripeUnit;
                    124:
                    125:        *row = 0;
                    126:        *col = raidPtr->Layout.numDataCol;
                    127:        *diskSector = (SUID / (raidPtr->Layout.numDataCol)) *
                    128:            raidPtr->Layout.sectorsPerStripeUnit +
                    129:            (raidSector % raidPtr->Layout.sectorsPerStripeUnit);
                    130: }
                    131:
                    132: void
                    133: rf_IdentifyStripeRAID4(RF_Raid_t *raidPtr, RF_RaidAddr_t addr,
                    134:     RF_RowCol_t **diskids, RF_RowCol_t *outRow)
                    135: {
                    136:        RF_Raid4ConfigInfo_t *info = raidPtr->Layout.layoutSpecificInfo;
                    137:
                    138:        *outRow = 0;
                    139:        *diskids = info->stripeIdentifier;
                    140: }
                    141:
                    142: void
                    143: rf_MapSIDToPSIDRAID4(RF_RaidLayout_t *layoutPtr, RF_StripeNum_t stripeID,
                    144:     RF_StripeNum_t *psID, RF_ReconUnitNum_t *which_ru)
                    145: {
                    146:        *which_ru = 0;
                    147:        *psID = stripeID;
                    148: }

CVSweb