Home | History | Annotate | Line # | Download | only in raidframe
rf_pqdeg.c revision 1.1
      1  1.1  oster /*	$NetBSD: rf_pqdeg.c,v 1.1 1998/11/13 04:20:32 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 /*
     30  1.1  oster  * Log: rf_pqdeg.c,v
     31  1.1  oster  * Revision 1.19  1996/11/05 21:10:40  jimz
     32  1.1  oster  * failed pda generalization
     33  1.1  oster  *
     34  1.1  oster  * Revision 1.18  1996/07/31  16:30:01  jimz
     35  1.1  oster  * asm/asmap fix
     36  1.1  oster  *
     37  1.1  oster  * Revision 1.17  1996/07/31  15:35:09  jimz
     38  1.1  oster  * evenodd changes; bugfixes for double-degraded archs, generalize
     39  1.1  oster  * some formerly PQ-only functions
     40  1.1  oster  *
     41  1.1  oster  * Revision 1.16  1996/07/27  23:36:08  jimz
     42  1.1  oster  * Solaris port of simulator
     43  1.1  oster  *
     44  1.1  oster  * Revision 1.15  1996/07/22  19:52:16  jimz
     45  1.1  oster  * switched node params to RF_DagParam_t, a union of
     46  1.1  oster  * a 64-bit int and a void *, for better portability
     47  1.1  oster  * attempted hpux port, but failed partway through for
     48  1.1  oster  * lack of a single C compiler capable of compiling all
     49  1.1  oster  * source files
     50  1.1  oster  *
     51  1.1  oster  * Revision 1.14  1996/06/02  17:31:48  jimz
     52  1.1  oster  * Moved a lot of global stuff into array structure, where it belongs.
     53  1.1  oster  * Fixed up paritylogging, pss modules in this manner. Some general
     54  1.1  oster  * code cleanup. Removed lots of dead code, some dead files.
     55  1.1  oster  *
     56  1.1  oster  * Revision 1.13  1996/05/31  22:26:54  jimz
     57  1.1  oster  * fix a lot of mapping problems, memory allocation problems
     58  1.1  oster  * found some weird lock issues, fixed 'em
     59  1.1  oster  * more code cleanup
     60  1.1  oster  *
     61  1.1  oster  * Revision 1.12  1996/05/27  18:56:37  jimz
     62  1.1  oster  * more code cleanup
     63  1.1  oster  * better typing
     64  1.1  oster  * compiles in all 3 environments
     65  1.1  oster  *
     66  1.1  oster  * Revision 1.11  1996/05/24  22:17:04  jimz
     67  1.1  oster  * continue code + namespace cleanup
     68  1.1  oster  * typed a bunch of flags
     69  1.1  oster  *
     70  1.1  oster  * Revision 1.10  1996/05/24  04:28:55  jimz
     71  1.1  oster  * release cleanup ckpt
     72  1.1  oster  *
     73  1.1  oster  * Revision 1.9  1996/05/18  19:51:34  jimz
     74  1.1  oster  * major code cleanup- fix syntax, make some types consistent,
     75  1.1  oster  * add prototypes, clean out dead code, et cetera
     76  1.1  oster  *
     77  1.1  oster  * Revision 1.8  1996/05/03  19:41:07  wvcii
     78  1.1  oster  * added includes for dag library
     79  1.1  oster  *
     80  1.1  oster  * Revision 1.7  1995/11/30  16:19:36  wvcii
     81  1.1  oster  * added copyright info
     82  1.1  oster  *
     83  1.1  oster  * Revision 1.6  1995/11/07  16:15:08  wvcii
     84  1.1  oster  * updated/added prototyping for dag creation
     85  1.1  oster  *
     86  1.1  oster  * Revision 1.5  1995/03/01  20:25:48  holland
     87  1.1  oster  * kernelization changes
     88  1.1  oster  *
     89  1.1  oster  * Revision 1.4  1995/02/03  22:31:36  holland
     90  1.1  oster  * many changes related to kernelization
     91  1.1  oster  *
     92  1.1  oster  * Revision 1.3  1995/02/01  15:13:05  holland
     93  1.1  oster  * moved #include of general.h out of raid.h and into each file
     94  1.1  oster  *
     95  1.1  oster  * Revision 1.2  1994/12/05  04:50:26  danner
     96  1.1  oster  * additional pq support
     97  1.1  oster  *
     98  1.1  oster  * Revision 1.1  1994/11/29  20:36:02  danner
     99  1.1  oster  * Initial revision
    100  1.1  oster  *
    101  1.1  oster  */
    102  1.1  oster 
    103  1.1  oster #include "rf_archs.h"
    104  1.1  oster 
    105  1.1  oster #if (RF_INCLUDE_DECL_PQ > 0) || (RF_INCLUDE_RAID6 > 0)
    106  1.1  oster 
    107  1.1  oster #include "rf_types.h"
    108  1.1  oster #include "rf_raid.h"
    109  1.1  oster #include "rf_dag.h"
    110  1.1  oster #include "rf_dagutils.h"
    111  1.1  oster #include "rf_dagfuncs.h"
    112  1.1  oster #include "rf_dagffrd.h"
    113  1.1  oster #include "rf_dagffwr.h"
    114  1.1  oster #include "rf_dagdegrd.h"
    115  1.1  oster #include "rf_dagdegwr.h"
    116  1.1  oster #include "rf_threadid.h"
    117  1.1  oster #include "rf_etimer.h"
    118  1.1  oster #include "rf_pqdeg.h"
    119  1.1  oster #include "rf_general.h"
    120  1.1  oster #include "rf_pqdegdags.h"
    121  1.1  oster #include "rf_pq.h"
    122  1.1  oster 
    123  1.1  oster /*
    124  1.1  oster    Degraded mode dag functions for P+Q calculations.
    125  1.1  oster 
    126  1.1  oster    The following nomenclature is used.
    127  1.1  oster 
    128  1.1  oster    PQ_<D><P><Q>_Create{Large,Small}<Write|Read>DAG
    129  1.1  oster 
    130  1.1  oster    where <D><P><Q> are single digits representing the number of failed
    131  1.1  oster    data units <D> (0,1,2), parity units <P> (0,1), and Q units <Q>, effecting
    132  1.1  oster    the I/O. The reads have only  PQ_<D><P><Q>_CreateReadDAG variants, while
    133  1.1  oster    the single fault writes have both large and small write versions. (Single fault
    134  1.1  oster    PQ is equivalent to normal mode raid 5 in many aspects.
    135  1.1  oster 
    136  1.1  oster    Some versions degenerate into the same case, and are grouped together below.
    137  1.1  oster */
    138  1.1  oster 
    139  1.1  oster /* Reads, single failure
    140  1.1  oster 
    141  1.1  oster    we have parity, so we can do a raid 5
    142  1.1  oster    reconstruct read.
    143  1.1  oster */
    144  1.1  oster 
    145  1.1  oster RF_CREATE_DAG_FUNC_DECL(rf_PQ_100_CreateReadDAG)
    146  1.1  oster {
    147  1.1  oster   rf_CreateDegradedReadDAG(raidPtr, asmap, dag_h, bp, flags, allocList, &rf_pRecoveryFuncs);
    148  1.1  oster }
    149  1.1  oster 
    150  1.1  oster /* Reads double failure  */
    151  1.1  oster 
    152  1.1  oster /*
    153  1.1  oster    Q is lost, but not parity
    154  1.1  oster    so we can a raid 5 reconstruct read.
    155  1.1  oster */
    156  1.1  oster 
    157  1.1  oster RF_CREATE_DAG_FUNC_DECL(rf_PQ_101_CreateReadDAG)
    158  1.1  oster {
    159  1.1  oster   rf_CreateDegradedReadDAG(raidPtr, asmap, dag_h, bp, flags, allocList, &rf_pRecoveryFuncs);
    160  1.1  oster }
    161  1.1  oster 
    162  1.1  oster /*
    163  1.1  oster   parity is lost, so we need to
    164  1.1  oster   do a reconstruct read and recompute
    165  1.1  oster   the data with Q.
    166  1.1  oster */
    167  1.1  oster 
    168  1.1  oster RF_CREATE_DAG_FUNC_DECL(rf_PQ_110_CreateReadDAG)
    169  1.1  oster {
    170  1.1  oster   RF_PhysDiskAddr_t *temp;
    171  1.1  oster   /* swap P and Q pointers to fake out the DegradedReadDAG code */
    172  1.1  oster   temp = asmap->parityInfo; asmap->parityInfo = asmap->qInfo; asmap->qInfo = temp;
    173  1.1  oster   rf_CreateDegradedReadDAG(raidPtr, asmap, dag_h, bp, flags, allocList, &rf_qRecoveryFuncs);
    174  1.1  oster }
    175  1.1  oster 
    176  1.1  oster /*
    177  1.1  oster   Two data units are dead in this stripe, so we will need read
    178  1.1  oster   both P and Q to reconstruct the data. Note that only
    179  1.1  oster   one data unit we are reading may actually be missing.
    180  1.1  oster */
    181  1.1  oster RF_CREATE_DAG_FUNC_DECL(rf_CreateDoubleDegradedReadDAG)
    182  1.1  oster {
    183  1.1  oster   rf_PQ_DoubleDegRead(raidPtr, asmap, dag_h, bp, flags, allocList);
    184  1.1  oster }
    185  1.1  oster 
    186  1.1  oster RF_CREATE_DAG_FUNC_DECL(rf_PQ_200_CreateReadDAG)
    187  1.1  oster {
    188  1.1  oster   rf_CreateDoubleDegradedReadDAG(raidPtr, asmap, dag_h, bp, flags, allocList);
    189  1.1  oster }
    190  1.1  oster 
    191  1.1  oster /* Writes, single failure */
    192  1.1  oster 
    193  1.1  oster RF_CREATE_DAG_FUNC_DECL(rf_PQ_100_CreateWriteDAG)
    194  1.1  oster {
    195  1.1  oster   if (asmap->numStripeUnitsAccessed != 1 &&
    196  1.1  oster       asmap->failedPDAs[0]->numSector != raidPtr->Layout.sectorsPerStripeUnit)
    197  1.1  oster     RF_PANIC();
    198  1.1  oster   rf_CommonCreateSimpleDegradedWriteDAG(raidPtr, asmap, dag_h, bp, flags,
    199  1.1  oster     allocList, 2, (int (*)())rf_Degraded_100_PQFunc, RF_FALSE);
    200  1.1  oster }
    201  1.1  oster 
    202  1.1  oster /* Dead  P - act like a RAID 5 small write with parity = Q */
    203  1.1  oster RF_CREATE_DAG_FUNC_DECL(rf_PQ_010_CreateSmallWriteDAG)
    204  1.1  oster {
    205  1.1  oster   RF_PhysDiskAddr_t *temp;
    206  1.1  oster   /* swap P and Q pointers to fake out the DegradedReadDAG code */
    207  1.1  oster   temp = asmap->parityInfo; asmap->parityInfo = asmap->qInfo; asmap->qInfo = temp;
    208  1.1  oster   rf_CommonCreateSmallWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, &rf_qFuncs, NULL);
    209  1.1  oster }
    210  1.1  oster 
    211  1.1  oster /* Dead Q - act like a RAID 5 small write */
    212  1.1  oster RF_CREATE_DAG_FUNC_DECL(rf_PQ_001_CreateSmallWriteDAG)
    213  1.1  oster {
    214  1.1  oster   rf_CommonCreateSmallWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, &rf_pFuncs, NULL);
    215  1.1  oster }
    216  1.1  oster 
    217  1.1  oster /* Dead P - act like a RAID 5 large write but for Q */
    218  1.1  oster RF_CREATE_DAG_FUNC_DECL(rf_PQ_010_CreateLargeWriteDAG)
    219  1.1  oster {
    220  1.1  oster   RF_PhysDiskAddr_t *temp;
    221  1.1  oster   /* swap P and Q pointers to fake out the code */
    222  1.1  oster   temp = asmap->parityInfo; asmap->parityInfo = asmap->qInfo; asmap->qInfo = temp;
    223  1.1  oster   rf_CommonCreateLargeWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, 1, rf_RegularQFunc, RF_FALSE);
    224  1.1  oster }
    225  1.1  oster 
    226  1.1  oster /* Dead Q - act like a RAID 5 large write */
    227  1.1  oster RF_CREATE_DAG_FUNC_DECL(rf_PQ_001_CreateLargeWriteDAG)
    228  1.1  oster {
    229  1.1  oster   rf_CommonCreateLargeWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList, 1, rf_RegularPFunc, RF_FALSE);
    230  1.1  oster }
    231  1.1  oster 
    232  1.1  oster 
    233  1.1  oster /*
    234  1.1  oster  * writes, double failure
    235  1.1  oster  */
    236  1.1  oster 
    237  1.1  oster /*
    238  1.1  oster  * Lost P & Q - do a nonredundant write
    239  1.1  oster  */
    240  1.1  oster RF_CREATE_DAG_FUNC_DECL(rf_PQ_011_CreateWriteDAG)
    241  1.1  oster {
    242  1.1  oster   rf_CreateNonRedundantWriteDAG(raidPtr, asmap, dag_h, bp, flags, allocList,
    243  1.1  oster     RF_IO_TYPE_WRITE);
    244  1.1  oster }
    245  1.1  oster 
    246  1.1  oster /*
    247  1.1  oster    In the two cases below,
    248  1.1  oster    A nasty case arises when the write a (strict) portion of a failed stripe unit
    249  1.1  oster    and parts of another su. For now, we do not support this.
    250  1.1  oster */
    251  1.1  oster 
    252  1.1  oster /*
    253  1.1  oster   Lost Data and  P - do a Q write.
    254  1.1  oster */
    255  1.1  oster RF_CREATE_DAG_FUNC_DECL(rf_PQ_110_CreateWriteDAG)
    256  1.1  oster {
    257  1.1  oster   RF_PhysDiskAddr_t *temp;
    258  1.1  oster 
    259  1.1  oster   if (asmap->numStripeUnitsAccessed != 1 &&
    260  1.1  oster       asmap->failedPDAs[0]->numSector != raidPtr->Layout.sectorsPerStripeUnit)
    261  1.1  oster   {
    262  1.1  oster     RF_PANIC();
    263  1.1  oster   }
    264  1.1  oster   /* swap P and Q to fake out parity code */
    265  1.1  oster   temp = asmap->parityInfo;
    266  1.1  oster   asmap->parityInfo = asmap->qInfo;
    267  1.1  oster   asmap->qInfo = temp;
    268  1.1  oster   rf_CommonCreateSimpleDegradedWriteDAG(raidPtr, asmap, dag_h, bp, flags,
    269  1.1  oster     allocList,1, (int (*)())rf_PQ_DegradedWriteQFunc, RF_FALSE);
    270  1.1  oster   /* is the regular Q func the right one to call? */
    271  1.1  oster }
    272  1.1  oster 
    273  1.1  oster /*
    274  1.1  oster    Lost Data and Q - do degraded mode P write
    275  1.1  oster */
    276  1.1  oster RF_CREATE_DAG_FUNC_DECL(rf_PQ_101_CreateWriteDAG)
    277  1.1  oster {
    278  1.1  oster   if (asmap->numStripeUnitsAccessed != 1 &&
    279  1.1  oster       asmap->failedPDAs[0]->numSector != raidPtr->Layout.sectorsPerStripeUnit)
    280  1.1  oster     RF_PANIC();
    281  1.1  oster   rf_CommonCreateSimpleDegradedWriteDAG(raidPtr, asmap, dag_h, bp, flags,
    282  1.1  oster     allocList,1, rf_RecoveryXorFunc, RF_FALSE);
    283  1.1  oster }
    284  1.1  oster 
    285  1.1  oster #endif /* (RF_INCLUDE_DECL_PQ > 0) || (RF_INCLUDE_RAID6 > 0) */
    286