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