Home | History | Annotate | Line # | Download | only in raidframe
rf_raid4.c revision 1.9
      1  1.9  perry /*	$NetBSD: rf_raid4.c,v 1.9 2005/02/27 00:27:45 perry 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: Rachad Youssef
      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_raid4.c -- implements RAID Level 4
     32  1.1  oster  *
     33  1.1  oster  ***************************************/
     34  1.5  lukem 
     35  1.5  lukem #include <sys/cdefs.h>
     36  1.9  perry __KERNEL_RCSID(0, "$NetBSD: rf_raid4.c,v 1.9 2005/02/27 00:27:45 perry Exp $");
     37  1.1  oster 
     38  1.1  oster #include "rf_raid.h"
     39  1.1  oster #include "rf_dag.h"
     40  1.1  oster #include "rf_dagutils.h"
     41  1.1  oster #include "rf_dagfuncs.h"
     42  1.1  oster #include "rf_dagffrd.h"
     43  1.1  oster #include "rf_dagffwr.h"
     44  1.1  oster #include "rf_dagdegrd.h"
     45  1.1  oster #include "rf_dagdegwr.h"
     46  1.1  oster #include "rf_raid4.h"
     47  1.1  oster #include "rf_general.h"
     48  1.1  oster 
     49  1.1  oster typedef struct RF_Raid4ConfigInfo_s {
     50  1.3  oster 	RF_RowCol_t *stripeIdentifier;	/* filled in at config time & used by
     51  1.3  oster 					 * IdentifyStripe */
     52  1.3  oster }       RF_Raid4ConfigInfo_t;
     53  1.1  oster 
     54  1.1  oster 
     55  1.1  oster 
     56  1.9  perry int
     57  1.8  oster rf_ConfigureRAID4(RF_ShutdownList_t **listp, RF_Raid_t *raidPtr,
     58  1.8  oster 		  RF_Config_t *cfgPtr)
     59  1.1  oster {
     60  1.3  oster 	RF_RaidLayout_t *layoutPtr = &raidPtr->Layout;
     61  1.3  oster 	RF_Raid4ConfigInfo_t *info;
     62  1.3  oster 	int     i;
     63  1.1  oster 
     64  1.3  oster 	/* create a RAID level 4 configuration structure ... */
     65  1.3  oster 	RF_MallocAndAdd(info, sizeof(RF_Raid4ConfigInfo_t), (RF_Raid4ConfigInfo_t *), raidPtr->cleanupList);
     66  1.3  oster 	if (info == NULL)
     67  1.3  oster 		return (ENOMEM);
     68  1.3  oster 	layoutPtr->layoutSpecificInfo = (void *) info;
     69  1.1  oster 
     70  1.3  oster 	/* ... and fill it in. */
     71  1.3  oster 	RF_MallocAndAdd(info->stripeIdentifier, raidPtr->numCol * sizeof(RF_RowCol_t), (RF_RowCol_t *), raidPtr->cleanupList);
     72  1.3  oster 	if (info->stripeIdentifier == NULL)
     73  1.3  oster 		return (ENOMEM);
     74  1.3  oster 	for (i = 0; i < raidPtr->numCol; i++)
     75  1.3  oster 		info->stripeIdentifier[i] = i;
     76  1.1  oster 
     77  1.3  oster 	/* fill in the remaining layout parameters */
     78  1.3  oster 	layoutPtr->numStripe = layoutPtr->stripeUnitsPerDisk;
     79  1.3  oster 	layoutPtr->numDataCol = raidPtr->numCol - 1;
     80  1.3  oster 	layoutPtr->dataSectorsPerStripe = layoutPtr->numDataCol * layoutPtr->sectorsPerStripeUnit;
     81  1.3  oster 	layoutPtr->numParityCol = 1;
     82  1.3  oster 	raidPtr->totalSectors = layoutPtr->stripeUnitsPerDisk * layoutPtr->numDataCol * layoutPtr->sectorsPerStripeUnit;
     83  1.1  oster 
     84  1.3  oster 	return (0);
     85  1.1  oster }
     86  1.1  oster 
     87  1.9  perry int
     88  1.8  oster rf_GetDefaultNumFloatingReconBuffersRAID4(RF_Raid_t *raidPtr)
     89  1.1  oster {
     90  1.3  oster 	return (20);
     91  1.1  oster }
     92  1.1  oster 
     93  1.9  perry RF_HeadSepLimit_t
     94  1.8  oster rf_GetDefaultHeadSepLimitRAID4(RF_Raid_t *raidPtr)
     95  1.1  oster {
     96  1.3  oster 	return (20);
     97  1.1  oster }
     98  1.1  oster 
     99  1.9  perry void
    100  1.8  oster rf_MapSectorRAID4(RF_Raid_t *raidPtr, RF_RaidAddr_t raidSector,
    101  1.8  oster 		  RF_RowCol_t *col, RF_SectorNum_t *diskSector, int remap)
    102  1.1  oster {
    103  1.3  oster 	RF_StripeNum_t SUID = raidSector / raidPtr->Layout.sectorsPerStripeUnit;
    104  1.3  oster 	*col = SUID % raidPtr->Layout.numDataCol;
    105  1.3  oster 	*diskSector = (SUID / (raidPtr->Layout.numDataCol)) * raidPtr->Layout.sectorsPerStripeUnit +
    106  1.3  oster 	    (raidSector % raidPtr->Layout.sectorsPerStripeUnit);
    107  1.1  oster }
    108  1.1  oster 
    109  1.9  perry void
    110  1.8  oster rf_MapParityRAID4(RF_Raid_t *raidPtr, RF_RaidAddr_t raidSector,
    111  1.8  oster 		  RF_RowCol_t *col, RF_SectorNum_t *diskSector, int remap)
    112  1.1  oster {
    113  1.3  oster 	RF_StripeNum_t SUID = raidSector / raidPtr->Layout.sectorsPerStripeUnit;
    114  1.3  oster 
    115  1.3  oster 	*col = raidPtr->Layout.numDataCol;
    116  1.3  oster 	*diskSector = (SUID / (raidPtr->Layout.numDataCol)) * raidPtr->Layout.sectorsPerStripeUnit +
    117  1.3  oster 	    (raidSector % raidPtr->Layout.sectorsPerStripeUnit);
    118  1.1  oster }
    119  1.1  oster 
    120  1.9  perry void
    121  1.8  oster rf_IdentifyStripeRAID4(RF_Raid_t *raidPtr, RF_RaidAddr_t addr,
    122  1.8  oster 		       RF_RowCol_t **diskids)
    123  1.1  oster {
    124  1.3  oster 	RF_Raid4ConfigInfo_t *info = raidPtr->Layout.layoutSpecificInfo;
    125  1.3  oster 
    126  1.3  oster 	*diskids = info->stripeIdentifier;
    127  1.1  oster }
    128  1.1  oster 
    129  1.9  perry void
    130  1.8  oster rf_MapSIDToPSIDRAID4(RF_RaidLayout_t *layoutPtr, RF_StripeNum_t stripeID,
    131  1.8  oster 		     RF_StripeNum_t *psID, RF_ReconUnitNum_t *which_ru)
    132  1.1  oster {
    133  1.3  oster 	*which_ru = 0;
    134  1.3  oster 	*psID = stripeID;
    135  1.1  oster }
    136