Home | History | Annotate | Line # | Download | only in raidframe
rf_raid4.c revision 1.13
      1  1.13  christos /*	$NetBSD: rf_raid4.c,v 1.13 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: 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.13  christos __KERNEL_RCSID(0, "$NetBSD: rf_raid4.c,v 1.13 2019/02/09 03:34:00 christos 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.12  christos rf_ConfigureRAID4(RF_ShutdownList_t **listp, RF_Raid_t *raidPtr,
     58  1.12  christos 		  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.13  christos 	info = RF_MallocAndAdd(sizeof(*info), 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.13  christos 	info->stripeIdentifier = RF_MallocAndAdd(raidPtr->numCol *
     72  1.13  christos 	    sizeof(*info->stripeIdentifier), raidPtr->cleanupList);
     73   1.3     oster 	if (info->stripeIdentifier == NULL)
     74   1.3     oster 		return (ENOMEM);
     75   1.3     oster 	for (i = 0; i < raidPtr->numCol; i++)
     76   1.3     oster 		info->stripeIdentifier[i] = i;
     77   1.1     oster 
     78   1.3     oster 	/* fill in the remaining layout parameters */
     79   1.3     oster 	layoutPtr->numStripe = layoutPtr->stripeUnitsPerDisk;
     80   1.3     oster 	layoutPtr->numDataCol = raidPtr->numCol - 1;
     81   1.3     oster 	layoutPtr->dataSectorsPerStripe = layoutPtr->numDataCol * layoutPtr->sectorsPerStripeUnit;
     82   1.3     oster 	layoutPtr->numParityCol = 1;
     83   1.3     oster 	raidPtr->totalSectors = layoutPtr->stripeUnitsPerDisk * layoutPtr->numDataCol * layoutPtr->sectorsPerStripeUnit;
     84   1.1     oster 
     85   1.3     oster 	return (0);
     86   1.1     oster }
     87   1.1     oster 
     88   1.9     perry int
     89  1.12  christos rf_GetDefaultNumFloatingReconBuffersRAID4(RF_Raid_t *raidPtr)
     90   1.1     oster {
     91   1.3     oster 	return (20);
     92   1.1     oster }
     93   1.1     oster 
     94   1.9     perry RF_HeadSepLimit_t
     95  1.12  christos rf_GetDefaultHeadSepLimitRAID4(RF_Raid_t *raidPtr)
     96   1.1     oster {
     97   1.3     oster 	return (20);
     98   1.1     oster }
     99   1.1     oster 
    100   1.9     perry void
    101   1.8     oster rf_MapSectorRAID4(RF_Raid_t *raidPtr, RF_RaidAddr_t raidSector,
    102  1.11  christos 		  RF_RowCol_t *col, RF_SectorNum_t *diskSector,
    103  1.12  christos 		  int remap)
    104   1.1     oster {
    105   1.3     oster 	RF_StripeNum_t SUID = raidSector / raidPtr->Layout.sectorsPerStripeUnit;
    106   1.3     oster 	*col = SUID % raidPtr->Layout.numDataCol;
    107   1.3     oster 	*diskSector = (SUID / (raidPtr->Layout.numDataCol)) * raidPtr->Layout.sectorsPerStripeUnit +
    108   1.3     oster 	    (raidSector % raidPtr->Layout.sectorsPerStripeUnit);
    109   1.1     oster }
    110   1.1     oster 
    111   1.9     perry void
    112   1.8     oster rf_MapParityRAID4(RF_Raid_t *raidPtr, RF_RaidAddr_t raidSector,
    113  1.11  christos 		  RF_RowCol_t *col, RF_SectorNum_t *diskSector,
    114  1.12  christos 		  int remap)
    115   1.1     oster {
    116   1.3     oster 	RF_StripeNum_t SUID = raidSector / raidPtr->Layout.sectorsPerStripeUnit;
    117   1.3     oster 
    118   1.3     oster 	*col = raidPtr->Layout.numDataCol;
    119   1.3     oster 	*diskSector = (SUID / (raidPtr->Layout.numDataCol)) * raidPtr->Layout.sectorsPerStripeUnit +
    120   1.3     oster 	    (raidSector % raidPtr->Layout.sectorsPerStripeUnit);
    121   1.1     oster }
    122   1.1     oster 
    123   1.9     perry void
    124  1.12  christos rf_IdentifyStripeRAID4(RF_Raid_t *raidPtr, RF_RaidAddr_t addr,
    125   1.8     oster 		       RF_RowCol_t **diskids)
    126   1.1     oster {
    127   1.3     oster 	RF_Raid4ConfigInfo_t *info = raidPtr->Layout.layoutSpecificInfo;
    128   1.3     oster 
    129   1.3     oster 	*diskids = info->stripeIdentifier;
    130   1.1     oster }
    131   1.1     oster 
    132   1.9     perry void
    133  1.12  christos rf_MapSIDToPSIDRAID4(RF_RaidLayout_t *layoutPtr,
    134  1.11  christos 		     RF_StripeNum_t stripeID,
    135   1.8     oster 		     RF_StripeNum_t *psID, RF_ReconUnitNum_t *which_ru)
    136   1.1     oster {
    137   1.3     oster 	*which_ru = 0;
    138   1.3     oster 	*psID = stripeID;
    139   1.1     oster }
    140