Home | History | Annotate | Line # | Download | only in raidframe
rf_pqdeg.c revision 1.3
      1  1.3  oster /*	$NetBSD: rf_pqdeg.c,v 1.3 1999/02/05 00:06:15 oster 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: Daniel Stodolsky
      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 #include "rf_archs.h"
     30  1.1  oster 
     31  1.1  oster #if (RF_INCLUDE_DECL_PQ > 0) || (RF_INCLUDE_RAID6 > 0)
     32  1.1  oster 
     33  1.1  oster #include "rf_types.h"
     34  1.1  oster #include "rf_raid.h"
     35  1.1  oster #include "rf_dag.h"
     36  1.1  oster #include "rf_dagutils.h"
     37  1.1  oster #include "rf_dagfuncs.h"
     38  1.1  oster #include "rf_dagffrd.h"
     39  1.1  oster #include "rf_dagffwr.h"
     40  1.1  oster #include "rf_dagdegrd.h"
     41  1.1  oster #include "rf_dagdegwr.h"
     42  1.1  oster #include "rf_threadid.h"
     43  1.1  oster #include "rf_etimer.h"
     44  1.1  oster #include "rf_pqdeg.h"
     45  1.1  oster #include "rf_general.h"
     46  1.1  oster #include "rf_pqdegdags.h"
     47  1.1  oster #include "rf_pq.h"
     48  1.1  oster 
     49  1.1  oster /*
     50  1.1  oster    Degraded mode dag functions for P+Q calculations.
     51  1.1  oster 
     52  1.3  oster    The following nomenclature is used.
     53  1.1  oster 
     54  1.1  oster    PQ_<D><P><Q>_Create{Large,Small}<Write|Read>DAG
     55  1.1  oster 
     56  1.1  oster    where <D><P><Q> are single digits representing the number of failed
     57  1.1  oster    data units <D> (0,1,2), parity units <P> (0,1), and Q units <Q>, effecting
     58  1.1  oster    the I/O. The reads have only  PQ_<D><P><Q>_CreateReadDAG variants, while
     59  1.1  oster    the single fault writes have both large and small write versions. (Single fault
     60  1.3  oster    PQ is equivalent to normal mode raid 5 in many aspects.
     61  1.1  oster 
     62  1.1  oster    Some versions degenerate into the same case, and are grouped together below.
     63  1.1  oster */
     64  1.1  oster 
     65  1.3  oster /* Reads, single failure
     66  1.1  oster 
     67  1.1  oster    we have parity, so we can do a raid 5
     68  1.1  oster    reconstruct read.
     69  1.1  oster */
     70  1.1  oster 
     71  1.1  oster RF_CREATE_DAG_FUNC_DECL(rf_PQ_100_CreateReadDAG)
     72  1.1  oster {
     73  1.3  oster 	rf_CreateDegradedReadDAG(raidPtr, asmap, dag_h, bp, flags, allocList, &rf_pRecoveryFuncs);
     74  1.1  oster }
     75  1.1  oster /* Reads double failure  */
     76  1.1  oster 
     77  1.1  oster /*
     78  1.1  oster    Q is lost, but not parity
     79  1.1  oster    so we can a raid 5 reconstruct read.
     80  1.1  oster */
     81  1.1  oster 
     82  1.1  oster RF_CREATE_DAG_FUNC_DECL(rf_PQ_101_CreateReadDAG)
     83  1.1  oster {
     84  1.3  oster 	rf_CreateDegradedReadDAG(raidPtr, asmap, dag_h, bp, flags, allocList, &rf_pRecoveryFuncs);
     85  1.1  oster }
     86  1.1  oster /*
     87  1.1  oster   parity is lost, so we need to
     88  1.1  oster   do a reconstruct read and recompute
     89  1.1  oster   the data with Q.
     90  1.1  oster */
     91  1.1  oster 
     92  1.1  oster RF_CREATE_DAG_FUNC_DECL(rf_PQ_110_CreateReadDAG)
     93  1.1  oster {
     94  1.3  oster 	RF_PhysDiskAddr_t *temp;
     95  1.3  oster 	/* swap P and Q pointers to fake out the DegradedReadDAG code */
     96  1.3  oster 	temp = asmap->parityInfo;
     97  1.3  oster 	asmap->parityInfo = asmap->qInfo;
     98  1.3  oster 	asmap->qInfo = temp;
     99  1.3  oster 	rf_CreateDegradedReadDAG(raidPtr, asmap, dag_h, bp, flags, allocList, &rf_qRecoveryFuncs);
    100  1.1  oster }
    101  1.1  oster /*
    102  1.1  oster   Two data units are dead in this stripe, so we will need read
    103  1.3  oster   both P and Q to reconstruct the data. Note that only
    104  1.3  oster   one data unit we are reading may actually be missing.
    105  1.1  oster */
    106  1.1  oster RF_CREATE_DAG_FUNC_DECL(rf_CreateDoubleDegradedReadDAG)
    107  1.1  oster {
    108  1.3  oster 	rf_PQ_DoubleDegRead(raidPtr, asmap, dag_h, bp, flags, allocList);
    109  1.1  oster }
    110  1.1  oster RF_CREATE_DAG_FUNC_DECL(rf_PQ_200_CreateReadDAG)
    111  1.1  oster {
    112  1.3  oster 	rf_CreateDoubleDegradedReadDAG(raidPtr, asmap, dag_h, bp, flags, allocList);
    113  1.1  oster }
    114  1.1  oster /* Writes, single failure */
    115  1.1  oster 
    116  1.1  oster RF_CREATE_DAG_FUNC_DECL(rf_PQ_100_CreateWriteDAG)
    117  1.1  oster {
    118  1.3  oster 	if (asmap->numStripeUnitsAccessed != 1 &&
    119  1.3  oster 	    asmap->failedPDAs[0]->numSector != raidPtr->Layout.sectorsPerStripeUnit)
    120  1.3  oster 		RF_PANIC();
    121  1.3  oster 	rf_CommonCreateSimpleDegradedWriteDAG(raidPtr, asmap, dag_h, bp, flags,
    122  1.3  oster 	    allocList, 2, (int (*) ()) rf_Degraded_100_PQFunc, RF_FALSE);
    123  1.1  oster }
    124  1.1  oster /* Dead  P - act like a RAID 5 small write with parity = Q */
    125  1.1  oster RF_CREATE_DAG_FUNC_DECL(rf_PQ_010_CreateSmallWriteDAG)
    126  1.1  oster {
    127  1.3  oster 	RF_PhysDiskAddr_t *temp;
    128  1.3  oster 	/* swap P and Q pointers to fake out the DegradedReadDAG code */
    129  1.3  oster 	temp = asmap->parityInfo;
    130  1.3  oster 	asmap->parityInfo = asmap->qInfo;
    131  1.3  oster 	asmap->qInfo = temp;
    132  1.3  oster 	rf_CommonCreateSmallWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, &rf_qFuncs, NULL);
    133  1.1  oster }
    134  1.1  oster /* Dead Q - act like a RAID 5 small write */
    135  1.1  oster RF_CREATE_DAG_FUNC_DECL(rf_PQ_001_CreateSmallWriteDAG)
    136  1.1  oster {
    137  1.3  oster 	rf_CommonCreateSmallWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, &rf_pFuncs, NULL);
    138  1.1  oster }
    139  1.1  oster /* Dead P - act like a RAID 5 large write but for Q */
    140  1.1  oster RF_CREATE_DAG_FUNC_DECL(rf_PQ_010_CreateLargeWriteDAG)
    141  1.1  oster {
    142  1.3  oster 	RF_PhysDiskAddr_t *temp;
    143  1.3  oster 	/* swap P and Q pointers to fake out the code */
    144  1.3  oster 	temp = asmap->parityInfo;
    145  1.3  oster 	asmap->parityInfo = asmap->qInfo;
    146  1.3  oster 	asmap->qInfo = temp;
    147  1.3  oster 	rf_CommonCreateLargeWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, 1, rf_RegularQFunc, RF_FALSE);
    148  1.1  oster }
    149  1.1  oster /* Dead Q - act like a RAID 5 large write */
    150  1.1  oster RF_CREATE_DAG_FUNC_DECL(rf_PQ_001_CreateLargeWriteDAG)
    151  1.1  oster {
    152  1.3  oster 	rf_CommonCreateLargeWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, 1, rf_RegularPFunc, RF_FALSE);
    153  1.1  oster }
    154  1.1  oster 
    155  1.1  oster 
    156  1.1  oster /*
    157  1.1  oster  * writes, double failure
    158  1.1  oster  */
    159  1.1  oster 
    160  1.1  oster /*
    161  1.3  oster  * Lost P & Q - do a nonredundant write
    162  1.1  oster  */
    163  1.1  oster RF_CREATE_DAG_FUNC_DECL(rf_PQ_011_CreateWriteDAG)
    164  1.1  oster {
    165  1.3  oster 	rf_CreateNonRedundantWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList,
    166  1.3  oster 	    RF_IO_TYPE_WRITE);
    167  1.1  oster }
    168  1.1  oster /*
    169  1.1  oster    In the two cases below,
    170  1.1  oster    A nasty case arises when the write a (strict) portion of a failed stripe unit
    171  1.1  oster    and parts of another su. For now, we do not support this.
    172  1.1  oster */
    173  1.1  oster 
    174  1.1  oster /*
    175  1.1  oster   Lost Data and  P - do a Q write.
    176  1.1  oster */
    177  1.1  oster RF_CREATE_DAG_FUNC_DECL(rf_PQ_110_CreateWriteDAG)
    178  1.1  oster {
    179  1.3  oster 	RF_PhysDiskAddr_t *temp;
    180  1.1  oster 
    181  1.3  oster 	if (asmap->numStripeUnitsAccessed != 1 &&
    182  1.3  oster 	    asmap->failedPDAs[0]->numSector != raidPtr->Layout.sectorsPerStripeUnit) {
    183  1.3  oster 		RF_PANIC();
    184  1.3  oster 	}
    185  1.3  oster 	/* swap P and Q to fake out parity code */
    186  1.3  oster 	temp = asmap->parityInfo;
    187  1.3  oster 	asmap->parityInfo = asmap->qInfo;
    188  1.3  oster 	asmap->qInfo = temp;
    189  1.3  oster 	rf_CommonCreateSimpleDegradedWriteDAG(raidPtr, asmap, dag_h, bp, flags,
    190  1.3  oster 	    allocList, 1, (int (*) ()) rf_PQ_DegradedWriteQFunc, RF_FALSE);
    191  1.3  oster 	/* is the regular Q func the right one to call? */
    192  1.1  oster }
    193  1.1  oster /*
    194  1.1  oster    Lost Data and Q - do degraded mode P write
    195  1.1  oster */
    196  1.1  oster RF_CREATE_DAG_FUNC_DECL(rf_PQ_101_CreateWriteDAG)
    197  1.1  oster {
    198  1.3  oster 	if (asmap->numStripeUnitsAccessed != 1 &&
    199  1.3  oster 	    asmap->failedPDAs[0]->numSector != raidPtr->Layout.sectorsPerStripeUnit)
    200  1.3  oster 		RF_PANIC();
    201  1.3  oster 	rf_CommonCreateSimpleDegradedWriteDAG(raidPtr, asmap, dag_h, bp, flags,
    202  1.3  oster 	    allocList, 1, rf_RecoveryXorFunc, RF_FALSE);
    203  1.1  oster }
    204  1.3  oster #endif				/* (RF_INCLUDE_DECL_PQ > 0) ||
    205  1.3  oster 				 * (RF_INCLUDE_RAID6 > 0) */
    206