📄 rf_pqdegdags.c
字号:
/* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. * * Author: Daniel Stodolsky * * Permission to use, copy, modify and distribute this software and * its documentation is hereby granted, provided that both the copyright * notice and this permission notice appear in all copies of the * software, derivative works or modified versions, and any portions * thereof, and that both notices appear in supporting documentation. * * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. * * Carnegie Mellon requests users of this software to return to * * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU * School of Computer Science * Carnegie Mellon University * Pittsburgh PA 15213-3890 * * any improvements or extensions that they make and grant Carnegie the * rights to redistribute these changes. *//* * rf_pqdegdags.c * Degraded mode dags for double fault cases. *//* * $Locker: $ * $Log: rf_pqdegdags.c,v $ * Revision 1.30 1996/07/31 16:30:05 jimz * asm/asmap fix * * Revision 1.29 1996/07/31 15:35:15 jimz * evenodd changes; bugfixes for double-degraded archs, generalize * some formerly PQ-only functions * * Revision 1.28 1996/07/28 20:31:39 jimz * i386netbsd port * true/false fixup * * Revision 1.27 1996/07/27 23:36:08 jimz * Solaris port of simulator * * Revision 1.26 1996/07/22 19:52:16 jimz * switched node params to RF_DagParam_t, a union of * a 64-bit int and a void *, for better portability * attempted hpux port, but failed partway through for * lack of a single C compiler capable of compiling all * source files * * Revision 1.25 1996/06/09 02:36:46 jimz * lots of little crufty cleanup- fixup whitespace * issues, comment #ifdefs, improve typing in some * places (esp size-related) * * Revision 1.24 1996/06/07 22:26:27 jimz * type-ify which_ru (RF_ReconUnitNum_t) * * Revision 1.23 1996/06/07 21:33:04 jimz * begin using consistent types for sector numbers, * stripe numbers, row+col numbers, recon unit numbers * * Revision 1.22 1996/06/02 17:31:48 jimz * Moved a lot of global stuff into array structure, where it belongs. * Fixed up paritylogging, pss modules in this manner. Some general * code cleanup. Removed lots of dead code, some dead files. * * Revision 1.21 1996/05/31 22:26:54 jimz * fix a lot of mapping problems, memory allocation problems * found some weird lock issues, fixed 'em * more code cleanup * * Revision 1.20 1996/05/30 12:59:18 jimz * make etimer happier, more portable * * Revision 1.19 1996/05/30 11:29:41 jimz * Numerous bug fixes. Stripe lock release code disagreed with the taking code * about when stripes should be locked (I made it consistent: no parity, no lock) * There was a lot of extra serialization of I/Os which I've removed- a lot of * it was to calculate values for the cache code, which is no longer with us. * More types, function, macro cleanup. Added code to properly quiesce the array * on shutdown. Made a lot of stuff array-specific which was (bogusly) general * before. Fixed memory allocation, freeing bugs. * * Revision 1.18 1996/05/27 18:56:37 jimz * more code cleanup * better typing * compiles in all 3 environments * * Revision 1.17 1996/05/24 22:17:04 jimz * continue code + namespace cleanup * typed a bunch of flags * * Revision 1.16 1996/05/24 04:28:55 jimz * release cleanup ckpt * * Revision 1.15 1996/05/23 21:46:35 jimz * checkpoint in code cleanup (release prep) * lots of types, function names have been fixed * * Revision 1.14 1996/05/23 00:33:23 jimz * code cleanup: move all debug decls to rf_options.c, all extern * debug decls to rf_options.h, all debug vars preceded by rf_ * * Revision 1.13 1996/05/18 19:51:34 jimz * major code cleanup- fix syntax, make some types consistent, * add prototypes, clean out dead code, et cetera * * Revision 1.12 1996/05/08 21:01:24 jimz * fixed up enum type names that were conflicting with other * enums and function names (ie, "panic") * future naming trends will be towards RF_ and rf_ for * everything raidframe-related * * Revision 1.11 1996/05/03 19:47:50 wvcii * removed include of rf_redstripe.h * * Revision 1.10 1995/12/12 18:10:06 jimz * MIN -> RF_MIN, MAX -> RF_MAX, ASSERT -> RF_ASSERT * fix 80-column brain damage in comments * * Revision 1.9 1995/11/30 16:17:57 wvcii * added copyright info * * Revision 1.8 1995/11/07 15:33:25 wvcii * dag creation routines now generate term node * added asserts * encoded commit point nodes, antecedence types into dags * didn't add commit barrier - the code is a mess and needs to * be cleand up first * */#include "rf_archs.h"#if (RF_INCLUDE_DECL_PQ > 0) || (RF_INCLUDE_RAID6 > 0)#include "rf_types.h"#include "rf_raid.h"#include "rf_dag.h"#include "rf_dagfuncs.h"#include "rf_dagutils.h"#include "rf_etimer.h"#include "rf_acctrace.h"#include "rf_general.h"#include "rf_pqdegdags.h"#include "rf_pq.h"#include "rf_sys.h"static void applyPDA(RF_Raid_t *raidPtr, RF_PhysDiskAddr_t *pda, RF_PhysDiskAddr_t *ppda, RF_PhysDiskAddr_t *qpda, void *bp);/* Two data drives have failed, and we are doing a read that covers one of them. We may also be reading some of the surviving drives. ***************************************************************************************** * * creates a DAG to perform a degraded-mode read of data within one stripe. * This DAG is as follows: * * Hdr * | * Block * / / \ \ \ \ * Rud ... Rud Rrd ... Rrd Rp Rq * | \ | \ | \ | \ | \ | \ * * | | * Unblock X * \ / * ------ T ------ * * Each R node is a successor of the L node * One successor arc from each R node goes to U, and the other to X * There is one Rud for each chunk of surviving user data requested by the user, * and one Rrd for each chunk of surviving user data _not_ being read by the user * R = read, ud = user data, rd = recovery (surviving) data, p = P data, q = Qdata * X = pq recovery node, T = terminate * * The block & unblock nodes are leftovers from a previous version. They * do nothing, but I haven't deleted them because it would be a tremendous * effort to put them back in. * * Note: The target buffer for the XOR node is set to the actual user buffer where the * failed data is supposed to end up. This buffer is zero'd by the code here. Thus, * if you create a degraded read dag, use it, and then re-use, you have to be sure to * zero the target buffer prior to the re-use. * * Every buffer read is passed to the pq recovery node, whose job it is to sort out whats * needs and what's not. ****************************************************************************************//* init a disk node with 2 successors and one predecessor */#define INIT_DISK_NODE(node,name) \rf_InitNode(node, rf_wait, RF_FALSE, rf_DiskReadFunc, rf_DiskReadUndoFunc, rf_GenericWakeupFunc, 2,1,4,0, dag_h, name, allocList); \(node)->succedents[0] = unblockNode; \(node)->succedents[1] = recoveryNode; \(node)->antecedents[0] = blockNode; \(node)->antType[0] = rf_control#define DISK_NODE_PARAMS(_node_,_p_) \ (_node_).params[0].p = _p_ ; \ (_node_).params[1].p = (_p_)->bufPtr; \ (_node_).params[2].v = parityStripeID; \ (_node_).params[3].v = RF_CREATE_PARAM3(RF_IO_NORMAL_PRIORITY, 0, 0, which_ru)#define DISK_NODE_PDA(node) ((node)->params[0].p)RF_CREATE_DAG_FUNC_DECL(rf_PQ_DoubleDegRead){ rf_DoubleDegRead(raidPtr, asmap, dag_h, bp, flags, allocList, "Rq", "PQ Recovery", rf_PQDoubleRecoveryFunc);} static void applyPDA(raidPtr,pda,ppda,qpda, bp) RF_Raid_t *raidPtr; RF_PhysDiskAddr_t *pda; RF_PhysDiskAddr_t *ppda; RF_PhysDiskAddr_t *qpda; void *bp;{ RF_RaidLayout_t *layoutPtr = &(raidPtr->Layout); RF_RaidAddr_t s0off = rf_StripeUnitOffset(layoutPtr, ppda->startSector); RF_SectorCount_t s0len = ppda->numSector, len; RF_SectorNum_t suoffset; unsigned coeff; char *pbuf = ppda->bufPtr; char *qbuf = qpda->bufPtr; char *buf; int delta; suoffset = rf_StripeUnitOffset(layoutPtr, pda->startSector); len = pda->numSector; /* see if pda intersects a recovery pda */ if ((suoffset < s0off+s0len) && ( suoffset+len > s0off)) { buf = pda->bufPtr; coeff = rf_RaidAddressToStripeUnitID(&(raidPtr->Layout),pda->raidAddress); coeff = (coeff % raidPtr->Layout.numDataCol); if (suoffset < s0off) { delta = s0off - suoffset; buf += rf_RaidAddressToStripeUnitID(&(raidPtr->Layout),delta); suoffset = s0off; len -= delta; } if (suoffset > s0off) { delta = suoffset - s0off; pbuf += rf_RaidAddressToStripeUnitID(&(raidPtr->Layout),delta); qbuf += rf_RaidAddressToStripeUnitID(&(raidPtr->Layout),delta); } if ((suoffset + len) > (s0len + s0off)) len = s0len + s0off - suoffset; /* src, dest, len */ rf_bxor(buf,pbuf,rf_RaidAddressToByte(raidPtr,len), bp); /* dest, src, len, coeff */ rf_IncQ((unsigned long *)qbuf,(unsigned long *)buf,rf_RaidAddressToByte(raidPtr,len),coeff); }}/* Recover data in the case of a double failure. There can be two result buffers, one for each chunk of data trying to be recovered. The params are pda's that have not been range restricted or otherwise politely massaged - this should be done here. The last params are the
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -