Home | History | Annotate | Line # | Download | only in raidframe
rf_evenodd_dags.c revision 1.1
      1 /*	$NetBSD: rf_evenodd_dags.c,v 1.1 1998/11/13 04:20:29 oster Exp $	*/
      2 /*
      3  * rf_evenodd_dags.c
      4  */
      5 /*
      6  * Copyright (c) 1996 Carnegie-Mellon University.
      7  * All rights reserved.
      8  *
      9  * Author: Chang-Ming Wu
     10  *
     11  * Permission to use, copy, modify and distribute this software and
     12  * its documentation is hereby granted, provided that both the copyright
     13  * notice and this permission notice appear in all copies of the
     14  * software, derivative works or modified versions, and any portions
     15  * thereof, and that both notices appear in supporting documentation.
     16  *
     17  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     18  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
     19  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     20  *
     21  * Carnegie Mellon requests users of this software to return to
     22  *
     23  *  Software Distribution Coordinator  or  Software.Distribution (at) CS.CMU.EDU
     24  *  School of Computer Science
     25  *  Carnegie Mellon University
     26  *  Pittsburgh PA 15213-3890
     27  *
     28  * any improvements or extensions that they make and grant Carnegie the
     29  * rights to redistribute these changes.
     30  */
     31 
     32 #include "rf_archs.h"
     33 
     34 #if RF_INCLUDE_EVENODD > 0
     35 
     36 #include "rf_types.h"
     37 #include "rf_raid.h"
     38 #include "rf_dag.h"
     39 #include "rf_dagfuncs.h"
     40 #include "rf_dagutils.h"
     41 #include "rf_etimer.h"
     42 #include "rf_acctrace.h"
     43 #include "rf_general.h"
     44 #include "rf_evenodd_dags.h"
     45 #include "rf_evenodd.h"
     46 #include "rf_evenodd_dagfuncs.h"
     47 #include "rf_pq.h"
     48 #include "rf_dagdegrd.h"
     49 #include "rf_dagdegwr.h"
     50 #include "rf_dagffwr.h"
     51 
     52 
     53 /*
     54  * Lost one data.
     55  * Use P to reconstruct missing data.
     56  */
     57 RF_CREATE_DAG_FUNC_DECL(rf_EO_100_CreateReadDAG)
     58 {
     59   rf_CreateDegradedReadDAG(raidPtr, asmap, dag_h, bp, flags, allocList, &rf_eoPRecoveryFuncs);
     60 }
     61 
     62 /*
     63  * Lost data + E.
     64  * Use P to reconstruct missing data.
     65  */
     66 RF_CREATE_DAG_FUNC_DECL(rf_EO_101_CreateReadDAG)
     67 {
     68   rf_CreateDegradedReadDAG(raidPtr, asmap, dag_h, bp, flags, allocList, &rf_eoPRecoveryFuncs);
     69 }
     70 
     71 /*
     72  * Lost data + P.
     73  * Make E look like P, and use Eor for Xor, and we can
     74  * use degraded read DAG.
     75  */
     76 RF_CREATE_DAG_FUNC_DECL(rf_EO_110_CreateReadDAG)
     77 {
     78   RF_PhysDiskAddr_t *temp;
     79   /* swap P and E pointers to fake out the DegradedReadDAG code */
     80   temp = asmap->parityInfo; asmap->parityInfo = asmap->qInfo; asmap->qInfo = temp;
     81   rf_CreateDegradedReadDAG(raidPtr, asmap, dag_h, bp, flags, allocList, &rf_eoERecoveryFuncs);
     82 }
     83 
     84 /*
     85  * Lost two data.
     86  */
     87 RF_CREATE_DAG_FUNC_DECL(rf_EOCreateDoubleDegradedReadDAG)
     88 {
     89   rf_EO_DoubleDegRead(raidPtr, asmap, dag_h, bp, flags, allocList);
     90 }
     91 
     92 /*
     93  * Lost two data.
     94  */
     95 RF_CREATE_DAG_FUNC_DECL(rf_EO_200_CreateReadDAG)
     96 {
     97   rf_EOCreateDoubleDegradedReadDAG(raidPtr, asmap, dag_h, bp, flags, allocList);
     98 }
     99 
    100 RF_CREATE_DAG_FUNC_DECL(rf_EO_100_CreateWriteDAG)
    101 {
    102   if (asmap->numStripeUnitsAccessed != 1 &&
    103       asmap->failedPDAs[0]->numSector != raidPtr->Layout.sectorsPerStripeUnit)
    104     RF_PANIC();
    105   rf_CommonCreateSimpleDegradedWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, 2, (int (*)(RF_DagNode_t *))rf_Degraded_100_EOFunc, RF_TRUE);
    106 }
    107 
    108 /*
    109  * E is dead. Small write.
    110  */
    111 RF_CREATE_DAG_FUNC_DECL(rf_EO_001_CreateSmallWriteDAG)
    112 {
    113   rf_CommonCreateSmallWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, &rf_EOSmallWritePFuncs, NULL);
    114 }
    115 
    116 /*
    117  * E is dead. Large write.
    118  */
    119 RF_CREATE_DAG_FUNC_DECL(rf_EO_001_CreateLargeWriteDAG)
    120 {
    121   rf_CommonCreateLargeWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, 1, rf_RegularPFunc, RF_TRUE);
    122 }
    123 
    124 /*
    125  * P is dead. Small write.
    126  * Swap E + P, use single-degraded stuff.
    127  */
    128 RF_CREATE_DAG_FUNC_DECL(rf_EO_010_CreateSmallWriteDAG)
    129 {
    130   RF_PhysDiskAddr_t *temp;
    131   /* swap P and E pointers to fake out the DegradedReadDAG code */
    132   temp = asmap->parityInfo; asmap->parityInfo = asmap->qInfo; asmap->qInfo = temp;
    133   rf_CommonCreateSmallWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, &rf_EOSmallWriteEFuncs, NULL);
    134 }
    135 
    136 /*
    137  * P is dead. Large write.
    138  * Swap E + P, use single-degraded stuff.
    139  */
    140 RF_CREATE_DAG_FUNC_DECL(rf_EO_010_CreateLargeWriteDAG)
    141 {
    142   RF_PhysDiskAddr_t *temp;
    143   /* swap P and E pointers to fake out the code */
    144   temp = asmap->parityInfo; asmap->parityInfo = asmap->qInfo; asmap->qInfo = temp;
    145   rf_CommonCreateLargeWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, 1, rf_RegularEFunc, RF_FALSE);
    146 }
    147 
    148 RF_CREATE_DAG_FUNC_DECL(rf_EO_011_CreateWriteDAG)
    149 {
    150   rf_CreateNonRedundantWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList,
    151     RF_IO_TYPE_WRITE);
    152 }
    153 
    154 RF_CREATE_DAG_FUNC_DECL(rf_EO_110_CreateWriteDAG)
    155 {
    156   RF_PhysDiskAddr_t *temp;
    157 
    158   if (asmap->numStripeUnitsAccessed != 1 &&
    159       asmap->failedPDAs[0]->numSector != raidPtr->Layout.sectorsPerStripeUnit)
    160   {
    161     RF_PANIC();
    162   }
    163   /* swap P and E to fake out parity code */
    164   temp = asmap->parityInfo; asmap->parityInfo = asmap->qInfo; asmap->qInfo = temp;
    165   rf_CommonCreateSimpleDegradedWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList,1, (int (*)(RF_DagNode_t *))rf_EO_DegradedWriteEFunc, RF_FALSE);
    166   /* is the regular E func the right one to call? */
    167 }
    168 
    169 RF_CREATE_DAG_FUNC_DECL(rf_EO_101_CreateWriteDAG)
    170 {
    171   if (asmap->numStripeUnitsAccessed != 1 &&
    172       asmap->failedPDAs[0]->numSector != raidPtr->Layout.sectorsPerStripeUnit)
    173     RF_PANIC();
    174   rf_CommonCreateSimpleDegradedWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList,1, rf_RecoveryXorFunc, RF_TRUE);
    175 }
    176 
    177 RF_CREATE_DAG_FUNC_DECL(rf_EO_DoubleDegRead)
    178 {
    179   rf_DoubleDegRead(raidPtr, asmap, dag_h, bp, flags, allocList,
    180     "Re", "EvenOddRecovery", rf_EvenOddDoubleRecoveryFunc);
    181 }
    182 
    183 RF_CREATE_DAG_FUNC_DECL(rf_EOCreateSmallWriteDAG)
    184 {
    185   rf_CommonCreateSmallWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, &rf_pFuncs, &rf_EOSmallWriteEFuncs);
    186 }
    187 
    188 RF_CREATE_DAG_FUNC_DECL(rf_EOCreateLargeWriteDAG)
    189 {
    190   rf_CommonCreateLargeWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, 2, rf_RegularPEFunc, RF_FALSE);
    191 }
    192 
    193 RF_CREATE_DAG_FUNC_DECL(rf_EO_200_CreateWriteDAG)
    194 {
    195   rf_DoubleDegSmallWrite(raidPtr, asmap, dag_h, bp, flags, allocList, "Re", "We", "EOWrDDRecovery", rf_EOWriteDoubleRecoveryFunc);
    196 }
    197 
    198 #endif /* RF_INCLUDE_EVENODD > 0 */
    199