2006-10-12 05:30:41 +04:00
|
|
|
/* $NetBSD: rf_parityscan.c,v 1.31 2006/10/12 01:31:52 christos Exp $ */
|
1998-11-13 07:20:26 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1995 Carnegie-Mellon University.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Author: Mark Holland
|
|
|
|
*
|
|
|
|
* 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_parityscan.c -- misc utilities related to parity verification
|
|
|
|
*
|
2003-12-31 19:23:50 +03:00
|
|
|
****************************************************************************/
|
1998-11-13 07:20:26 +03:00
|
|
|
|
2001-11-13 10:11:12 +03:00
|
|
|
#include <sys/cdefs.h>
|
2006-10-12 05:30:41 +04:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: rf_parityscan.c,v 1.31 2006/10/12 01:31:52 christos Exp $");
|
2001-11-13 10:11:12 +03:00
|
|
|
|
2001-10-04 19:58:51 +04:00
|
|
|
#include <dev/raidframe/raidframevar.h>
|
|
|
|
|
1998-11-13 07:20:26 +03:00
|
|
|
#include "rf_raid.h"
|
|
|
|
#include "rf_dag.h"
|
|
|
|
#include "rf_dagfuncs.h"
|
|
|
|
#include "rf_dagutils.h"
|
|
|
|
#include "rf_mcpair.h"
|
|
|
|
#include "rf_general.h"
|
|
|
|
#include "rf_engine.h"
|
|
|
|
#include "rf_parityscan.h"
|
|
|
|
#include "rf_map.h"
|
|
|
|
|
2003-12-31 19:23:50 +03:00
|
|
|
/*****************************************************************************
|
1998-11-13 07:20:26 +03:00
|
|
|
*
|
2003-12-31 19:23:50 +03:00
|
|
|
* walk through the entire arry and write new parity. This works by
|
|
|
|
* creating two DAGs, one to read a stripe of data and one to write
|
|
|
|
* new parity. The first is executed, the data is xored together, and
|
|
|
|
* then the second is executed. To avoid constantly building and
|
|
|
|
* tearing down the DAGs, we create them a priori and fill them in
|
|
|
|
* with the mapping information as we go along.
|
1998-11-13 07:20:26 +03:00
|
|
|
*
|
|
|
|
* there should never be more than one thread running this.
|
|
|
|
*
|
2003-12-31 19:23:50 +03:00
|
|
|
****************************************************************************/
|
1998-11-13 07:20:26 +03:00
|
|
|
|
2005-02-27 03:26:58 +03:00
|
|
|
int
|
2003-12-31 19:23:50 +03:00
|
|
|
rf_RewriteParity(RF_Raid_t *raidPtr)
|
1998-11-13 07:20:26 +03:00
|
|
|
{
|
1999-02-05 03:06:06 +03:00
|
|
|
RF_RaidLayout_t *layoutPtr = &raidPtr->Layout;
|
|
|
|
RF_AccessStripeMapHeader_t *asm_h;
|
1999-08-11 02:19:27 +04:00
|
|
|
int ret_val;
|
1999-03-15 01:10:46 +03:00
|
|
|
int rc;
|
1999-02-05 03:06:06 +03:00
|
|
|
RF_SectorNum_t i;
|
1998-11-13 07:20:26 +03:00
|
|
|
|
1999-08-10 05:53:26 +04:00
|
|
|
if (raidPtr->Layout.map->faultsTolerated == 0) {
|
|
|
|
/* There isn't any parity. Call it "okay." */
|
|
|
|
return (RF_PARITY_OKAY);
|
|
|
|
}
|
2003-12-29 05:38:17 +03:00
|
|
|
if (raidPtr->status != rf_rs_optimal) {
|
1999-08-10 05:53:26 +04:00
|
|
|
/*
|
2005-02-27 03:26:58 +03:00
|
|
|
* We're in degraded mode. Don't try to verify parity now!
|
|
|
|
* XXX: this should be a "we don't want to", not a
|
|
|
|
* "we can't" error.
|
1999-08-10 05:53:26 +04:00
|
|
|
*/
|
|
|
|
return (RF_PARITY_COULD_NOT_VERIFY);
|
|
|
|
}
|
|
|
|
|
1999-08-11 02:19:27 +04:00
|
|
|
ret_val = 0;
|
|
|
|
|
|
|
|
rc = RF_PARITY_OKAY;
|
1998-11-13 07:20:26 +03:00
|
|
|
|
2005-02-27 03:26:58 +03:00
|
|
|
for (i = 0; i < raidPtr->totalSectors &&
|
|
|
|
rc <= RF_PARITY_CORRECTED;
|
1999-03-15 01:10:46 +03:00
|
|
|
i += layoutPtr->dataSectorsPerStripe) {
|
2000-05-28 07:00:31 +04:00
|
|
|
if (raidPtr->waitShutdown) {
|
|
|
|
/* Someone is pulling the plug on this set...
|
|
|
|
abort the re-write */
|
|
|
|
return (1);
|
|
|
|
}
|
2005-02-27 03:26:58 +03:00
|
|
|
asm_h = rf_MapAccess(raidPtr, i,
|
|
|
|
layoutPtr->dataSectorsPerStripe,
|
1999-03-15 01:10:46 +03:00
|
|
|
NULL, RF_DONT_REMAP);
|
2005-02-27 03:26:58 +03:00
|
|
|
raidPtr->parity_rewrite_stripes_done =
|
2000-01-05 05:57:28 +03:00
|
|
|
i / layoutPtr->dataSectorsPerStripe ;
|
1999-02-05 03:06:06 +03:00
|
|
|
rc = rf_VerifyParity(raidPtr, asm_h->stripeMap, 1, 0);
|
1999-03-15 01:10:46 +03:00
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
switch (rc) {
|
|
|
|
case RF_PARITY_OKAY:
|
|
|
|
case RF_PARITY_CORRECTED:
|
|
|
|
break;
|
|
|
|
case RF_PARITY_BAD:
|
|
|
|
printf("Parity bad during correction\n");
|
1999-08-11 02:19:27 +04:00
|
|
|
ret_val = 1;
|
1999-02-05 03:06:06 +03:00
|
|
|
break;
|
|
|
|
case RF_PARITY_COULD_NOT_CORRECT:
|
|
|
|
printf("Could not correct bad parity\n");
|
1999-08-11 02:19:27 +04:00
|
|
|
ret_val = 1;
|
1999-02-05 03:06:06 +03:00
|
|
|
break;
|
|
|
|
case RF_PARITY_COULD_NOT_VERIFY:
|
|
|
|
printf("Could not verify parity\n");
|
1999-08-11 02:19:27 +04:00
|
|
|
ret_val = 1;
|
1999-02-05 03:06:06 +03:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printf("Bad rc=%d from VerifyParity in RewriteParity\n", rc);
|
1999-08-11 02:19:27 +04:00
|
|
|
ret_val = 1;
|
1999-02-05 03:06:06 +03:00
|
|
|
}
|
|
|
|
rf_FreeAccessStripeMap(asm_h);
|
|
|
|
}
|
1999-08-11 02:19:27 +04:00
|
|
|
return (ret_val);
|
1998-11-13 07:20:26 +03:00
|
|
|
}
|
2003-12-31 19:23:50 +03:00
|
|
|
/*****************************************************************************
|
1998-11-13 07:20:26 +03:00
|
|
|
*
|
2003-12-31 19:23:50 +03:00
|
|
|
* verify that the parity in a particular stripe is correct. we
|
|
|
|
* validate only the range of parity defined by parityPDA, since this
|
|
|
|
* is all we have locked. The way we do this is to create an asm that
|
|
|
|
* maps the whole stripe and then range-restrict it to the parity
|
1998-11-13 07:20:26 +03:00
|
|
|
* region defined by the parityPDA.
|
|
|
|
*
|
2003-12-31 19:23:50 +03:00
|
|
|
****************************************************************************/
|
2005-02-27 03:26:58 +03:00
|
|
|
int
|
2003-12-31 19:23:50 +03:00
|
|
|
rf_VerifyParity(RF_Raid_t *raidPtr, RF_AccessStripeMap_t *aasm,
|
|
|
|
int correct_it, RF_RaidAccessFlags_t flags)
|
1998-11-13 07:20:26 +03:00
|
|
|
{
|
1999-02-05 03:06:06 +03:00
|
|
|
RF_PhysDiskAddr_t *parityPDA;
|
|
|
|
RF_AccessStripeMap_t *doasm;
|
2003-02-09 13:04:32 +03:00
|
|
|
const RF_LayoutSW_t *lp;
|
1999-02-05 03:06:06 +03:00
|
|
|
int lrc, rc;
|
1998-11-13 07:20:26 +03:00
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
lp = raidPtr->Layout.map;
|
|
|
|
if (lp->faultsTolerated == 0) {
|
|
|
|
/*
|
|
|
|
* There isn't any parity. Call it "okay."
|
|
|
|
*/
|
|
|
|
return (RF_PARITY_OKAY);
|
|
|
|
}
|
|
|
|
rc = RF_PARITY_OKAY;
|
|
|
|
if (lp->VerifyParity) {
|
|
|
|
for (doasm = aasm; doasm; doasm = doasm->next) {
|
2005-02-27 03:26:58 +03:00
|
|
|
for (parityPDA = doasm->parityInfo; parityPDA;
|
1999-03-15 01:10:46 +03:00
|
|
|
parityPDA = parityPDA->next) {
|
2005-02-27 03:26:58 +03:00
|
|
|
lrc = lp->VerifyParity(raidPtr,
|
|
|
|
doasm->raidAddress,
|
1999-03-15 01:10:46 +03:00
|
|
|
parityPDA,
|
|
|
|
correct_it, flags);
|
1999-02-05 03:06:06 +03:00
|
|
|
if (lrc > rc) {
|
|
|
|
/* see rf_parityscan.h for why this
|
|
|
|
* works */
|
|
|
|
rc = lrc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
rc = RF_PARITY_COULD_NOT_VERIFY;
|
|
|
|
}
|
|
|
|
return (rc);
|
1998-11-13 07:20:26 +03:00
|
|
|
}
|
|
|
|
|
2005-02-27 03:26:58 +03:00
|
|
|
int
|
2003-12-31 19:23:50 +03:00
|
|
|
rf_VerifyParityBasic(RF_Raid_t *raidPtr, RF_RaidAddr_t raidAddr,
|
|
|
|
RF_PhysDiskAddr_t *parityPDA, int correct_it,
|
|
|
|
RF_RaidAccessFlags_t flags)
|
1998-11-13 07:20:26 +03:00
|
|
|
{
|
1999-02-05 03:06:06 +03:00
|
|
|
RF_RaidLayout_t *layoutPtr = &(raidPtr->Layout);
|
1999-03-15 01:10:46 +03:00
|
|
|
RF_RaidAddr_t startAddr = rf_RaidAddressOfPrevStripeBoundary(layoutPtr,
|
|
|
|
raidAddr);
|
1999-02-05 03:06:06 +03:00
|
|
|
RF_SectorCount_t numsector = parityPDA->numSector;
|
|
|
|
int numbytes = rf_RaidAddressToByte(raidPtr, numsector);
|
|
|
|
int bytesPerStripe = numbytes * layoutPtr->numDataCol;
|
|
|
|
RF_DagHeader_t *rd_dag_h, *wr_dag_h; /* read, write dag */
|
2002-09-23 07:36:08 +04:00
|
|
|
RF_DagNode_t *blockNode, *wrBlock;
|
1999-02-05 03:06:06 +03:00
|
|
|
RF_AccessStripeMapHeader_t *asm_h;
|
|
|
|
RF_AccessStripeMap_t *asmap;
|
|
|
|
RF_AllocListElem_t *alloclist;
|
|
|
|
RF_PhysDiskAddr_t *pda;
|
2005-05-30 02:03:09 +04:00
|
|
|
char *pbuf, *bf, *end_p, *p;
|
1999-02-05 03:06:06 +03:00
|
|
|
int i, retcode;
|
|
|
|
RF_ReconUnitNum_t which_ru;
|
2005-02-27 03:26:58 +03:00
|
|
|
RF_StripeNum_t psID = rf_RaidAddressToParityStripeID(layoutPtr,
|
|
|
|
raidAddr,
|
1999-03-15 01:10:46 +03:00
|
|
|
&which_ru);
|
1999-02-05 03:06:06 +03:00
|
|
|
int stripeWidth = layoutPtr->numDataCol + layoutPtr->numParityCol;
|
2004-03-02 02:30:57 +03:00
|
|
|
#if RF_ACC_TRACE > 0
|
1999-02-05 03:06:06 +03:00
|
|
|
RF_AccTraceEntry_t tracerec;
|
2004-03-02 02:30:57 +03:00
|
|
|
#endif
|
1999-02-05 03:06:06 +03:00
|
|
|
RF_MCPair_t *mcpair;
|
1998-11-13 07:20:26 +03:00
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
retcode = RF_PARITY_OKAY;
|
1998-11-13 07:20:26 +03:00
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
mcpair = rf_AllocMCPair();
|
|
|
|
rf_MakeAllocList(alloclist);
|
2005-05-30 02:03:09 +04:00
|
|
|
RF_MallocAndAdd(bf, numbytes * (layoutPtr->numDataCol + layoutPtr->numParityCol), (char *), alloclist);
|
2003-12-29 06:33:47 +03:00
|
|
|
RF_MallocAndAdd(pbuf, numbytes, (char *), alloclist);
|
2005-05-30 02:03:09 +04:00
|
|
|
end_p = bf + bytesPerStripe;
|
1998-11-13 07:20:26 +03:00
|
|
|
|
2005-05-30 02:03:09 +04:00
|
|
|
rd_dag_h = rf_MakeSimpleDAG(raidPtr, stripeWidth, numbytes, bf, rf_DiskReadFunc, rf_DiskReadUndoFunc,
|
1999-02-05 03:06:06 +03:00
|
|
|
"Rod", alloclist, flags, RF_IO_NORMAL_PRIORITY);
|
|
|
|
blockNode = rd_dag_h->succedents[0];
|
1998-11-13 07:20:26 +03:00
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
/* map the stripe and fill in the PDAs in the dag */
|
2005-05-30 02:03:09 +04:00
|
|
|
asm_h = rf_MapAccess(raidPtr, startAddr, layoutPtr->dataSectorsPerStripe, bf, RF_DONT_REMAP);
|
1999-02-05 03:06:06 +03:00
|
|
|
asmap = asm_h->stripeMap;
|
1998-11-13 07:20:26 +03:00
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
for (pda = asmap->physInfo, i = 0; i < layoutPtr->numDataCol; i++, pda = pda->next) {
|
|
|
|
RF_ASSERT(pda);
|
|
|
|
rf_RangeRestrictPDA(raidPtr, parityPDA, pda, 0, 1);
|
|
|
|
RF_ASSERT(pda->numSector != 0);
|
|
|
|
if (rf_TryToRedirectPDA(raidPtr, pda, 0))
|
|
|
|
goto out; /* no way to verify parity if disk is
|
|
|
|
* dead. return w/ good status */
|
|
|
|
blockNode->succedents[i]->params[0].p = pda;
|
|
|
|
blockNode->succedents[i]->params[2].v = psID;
|
2004-01-10 03:56:27 +03:00
|
|
|
blockNode->succedents[i]->params[3].v = RF_CREATE_PARAM3(RF_IO_NORMAL_PRIORITY, which_ru);
|
1999-02-05 03:06:06 +03:00
|
|
|
}
|
1998-11-13 07:20:26 +03:00
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
RF_ASSERT(!asmap->parityInfo->next);
|
|
|
|
rf_RangeRestrictPDA(raidPtr, parityPDA, asmap->parityInfo, 0, 1);
|
|
|
|
RF_ASSERT(asmap->parityInfo->numSector != 0);
|
|
|
|
if (rf_TryToRedirectPDA(raidPtr, asmap->parityInfo, 1))
|
|
|
|
goto out;
|
|
|
|
blockNode->succedents[layoutPtr->numDataCol]->params[0].p = asmap->parityInfo;
|
1998-11-13 07:20:26 +03:00
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
/* fire off the DAG */
|
2004-03-02 02:30:57 +03:00
|
|
|
#if RF_ACC_TRACE > 0
|
2001-07-18 10:45:33 +04:00
|
|
|
memset((char *) &tracerec, 0, sizeof(tracerec));
|
1999-02-05 03:06:06 +03:00
|
|
|
rd_dag_h->tracerec = &tracerec;
|
2004-03-02 02:30:57 +03:00
|
|
|
#endif
|
2002-07-14 00:14:33 +04:00
|
|
|
#if 0
|
1999-02-05 03:06:06 +03:00
|
|
|
if (rf_verifyParityDebug) {
|
|
|
|
printf("Parity verify read dag:\n");
|
|
|
|
rf_PrintDAGList(rd_dag_h);
|
|
|
|
}
|
2002-07-14 00:14:33 +04:00
|
|
|
#endif
|
1999-02-05 03:06:06 +03:00
|
|
|
RF_LOCK_MUTEX(mcpair->mutex);
|
|
|
|
mcpair->flag = 0;
|
2004-03-02 18:47:35 +03:00
|
|
|
RF_UNLOCK_MUTEX(mcpair->mutex);
|
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
rf_DispatchDAG(rd_dag_h, (void (*) (void *)) rf_MCPairWakeupFunc,
|
|
|
|
(void *) mcpair);
|
2004-03-02 18:47:35 +03:00
|
|
|
|
|
|
|
RF_LOCK_MUTEX(mcpair->mutex);
|
1999-02-05 03:06:06 +03:00
|
|
|
while (!mcpair->flag)
|
|
|
|
RF_WAIT_COND(mcpair->cond, mcpair->mutex);
|
|
|
|
RF_UNLOCK_MUTEX(mcpair->mutex);
|
|
|
|
if (rd_dag_h->status != rf_enable) {
|
|
|
|
RF_ERRORMSG("Unable to verify parity: can't read the stripe\n");
|
|
|
|
retcode = RF_PARITY_COULD_NOT_VERIFY;
|
|
|
|
goto out;
|
|
|
|
}
|
2005-05-30 02:03:09 +04:00
|
|
|
for (p = bf; p < end_p; p += numbytes) {
|
2003-12-31 03:00:06 +03:00
|
|
|
rf_bxor(p, pbuf, numbytes);
|
1999-02-05 03:06:06 +03:00
|
|
|
}
|
|
|
|
for (i = 0; i < numbytes; i++) {
|
2005-05-30 02:03:09 +04:00
|
|
|
if (pbuf[i] != bf[bytesPerStripe + i]) {
|
1999-02-05 03:06:06 +03:00
|
|
|
if (!correct_it)
|
|
|
|
RF_ERRORMSG3("Parity verify error: byte %d of parity is 0x%x should be 0x%x\n",
|
2005-05-30 02:03:09 +04:00
|
|
|
i, (u_char) bf[bytesPerStripe + i], (u_char) pbuf[i]);
|
1999-02-05 03:06:06 +03:00
|
|
|
retcode = RF_PARITY_BAD;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1998-11-13 07:20:26 +03:00
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
if (retcode && correct_it) {
|
|
|
|
wr_dag_h = rf_MakeSimpleDAG(raidPtr, 1, numbytes, pbuf, rf_DiskWriteFunc, rf_DiskWriteUndoFunc,
|
|
|
|
"Wnp", alloclist, flags, RF_IO_NORMAL_PRIORITY);
|
|
|
|
wrBlock = wr_dag_h->succedents[0];
|
|
|
|
wrBlock->succedents[0]->params[0].p = asmap->parityInfo;
|
|
|
|
wrBlock->succedents[0]->params[2].v = psID;
|
2004-01-10 03:56:27 +03:00
|
|
|
wrBlock->succedents[0]->params[3].v = RF_CREATE_PARAM3(RF_IO_NORMAL_PRIORITY, which_ru);
|
2004-03-02 02:30:57 +03:00
|
|
|
#if RF_ACC_TRACE > 0
|
2001-07-18 10:45:33 +04:00
|
|
|
memset((char *) &tracerec, 0, sizeof(tracerec));
|
1999-02-05 03:06:06 +03:00
|
|
|
wr_dag_h->tracerec = &tracerec;
|
2004-03-02 02:30:57 +03:00
|
|
|
#endif
|
2002-07-14 00:14:33 +04:00
|
|
|
#if 0
|
1999-02-05 03:06:06 +03:00
|
|
|
if (rf_verifyParityDebug) {
|
|
|
|
printf("Parity verify write dag:\n");
|
|
|
|
rf_PrintDAGList(wr_dag_h);
|
|
|
|
}
|
2002-07-14 00:14:33 +04:00
|
|
|
#endif
|
1999-02-05 03:06:06 +03:00
|
|
|
RF_LOCK_MUTEX(mcpair->mutex);
|
|
|
|
mcpair->flag = 0;
|
2004-03-02 18:47:35 +03:00
|
|
|
RF_UNLOCK_MUTEX(mcpair->mutex);
|
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
rf_DispatchDAG(wr_dag_h, (void (*) (void *)) rf_MCPairWakeupFunc,
|
|
|
|
(void *) mcpair);
|
2004-03-02 18:47:35 +03:00
|
|
|
|
|
|
|
RF_LOCK_MUTEX(mcpair->mutex);
|
1999-02-05 03:06:06 +03:00
|
|
|
while (!mcpair->flag)
|
|
|
|
RF_WAIT_COND(mcpair->cond, mcpair->mutex);
|
|
|
|
RF_UNLOCK_MUTEX(mcpair->mutex);
|
|
|
|
if (wr_dag_h->status != rf_enable) {
|
|
|
|
RF_ERRORMSG("Unable to correct parity in VerifyParity: can't write the stripe\n");
|
|
|
|
retcode = RF_PARITY_COULD_NOT_CORRECT;
|
|
|
|
}
|
|
|
|
rf_FreeDAG(wr_dag_h);
|
|
|
|
if (retcode == RF_PARITY_BAD)
|
|
|
|
retcode = RF_PARITY_CORRECTED;
|
|
|
|
}
|
1998-11-13 07:20:26 +03:00
|
|
|
out:
|
1999-02-05 03:06:06 +03:00
|
|
|
rf_FreeAccessStripeMap(asm_h);
|
|
|
|
rf_FreeAllocList(alloclist);
|
|
|
|
rf_FreeDAG(rd_dag_h);
|
|
|
|
rf_FreeMCPair(mcpair);
|
|
|
|
return (retcode);
|
1998-11-13 07:20:26 +03:00
|
|
|
}
|
|
|
|
|
2005-02-27 03:26:58 +03:00
|
|
|
int
|
2006-10-12 05:30:41 +04:00
|
|
|
rf_TryToRedirectPDA(RF_Raid_t *raidPtr, RF_PhysDiskAddr_t *pda,
|
|
|
|
int parity __unused)
|
1998-11-13 07:20:26 +03:00
|
|
|
{
|
2003-12-29 05:38:17 +03:00
|
|
|
if (raidPtr->Disks[pda->col].status == rf_ds_reconstructing) {
|
|
|
|
if (rf_CheckRUReconstructed(raidPtr->reconControl->reconMap, pda->startSector)) {
|
2004-03-05 06:58:21 +03:00
|
|
|
#if RF_INCLUDE_PARITY_DECLUSTERING_DS > 0
|
1999-02-05 03:06:06 +03:00
|
|
|
if (raidPtr->Layout.map->flags & RF_DISTRIBUTE_SPARE) {
|
2002-09-14 21:11:30 +04:00
|
|
|
#if RF_DEBUG_VERIFYPARITY
|
2003-12-29 05:38:17 +03:00
|
|
|
RF_RowCol_t oc = pda->col;
|
1999-02-05 03:06:06 +03:00
|
|
|
RF_SectorNum_t os = pda->startSector;
|
2002-09-14 21:11:30 +04:00
|
|
|
#endif
|
1999-02-05 03:06:06 +03:00
|
|
|
if (parity) {
|
2003-12-29 05:38:17 +03:00
|
|
|
(raidPtr->Layout.map->MapParity) (raidPtr, pda->raidAddress, &pda->col, &pda->startSector, RF_REMAP);
|
2002-09-14 21:11:30 +04:00
|
|
|
#if RF_DEBUG_VERIFYPARITY
|
1999-02-05 03:06:06 +03:00
|
|
|
if (rf_verifyParityDebug)
|
2003-12-29 05:38:17 +03:00
|
|
|
printf("VerifyParity: Redir P c %d sect %ld -> c %d sect %ld\n",
|
|
|
|
oc, (long) os, pda->col, (long) pda->startSector);
|
2002-09-14 21:11:30 +04:00
|
|
|
#endif
|
1999-02-05 03:06:06 +03:00
|
|
|
} else {
|
2003-12-29 05:38:17 +03:00
|
|
|
(raidPtr->Layout.map->MapSector) (raidPtr, pda->raidAddress, &pda->col, &pda->startSector, RF_REMAP);
|
2002-09-14 21:11:30 +04:00
|
|
|
#if RF_DEBUG_VERIFYPARITY
|
1999-02-05 03:06:06 +03:00
|
|
|
if (rf_verifyParityDebug)
|
2003-12-29 05:38:17 +03:00
|
|
|
printf("VerifyParity: Redir D c %d sect %ld -> c %d sect %ld\n",
|
|
|
|
oc, (long) os, pda->col, (long) pda->startSector);
|
2002-09-14 21:11:30 +04:00
|
|
|
#endif
|
1999-02-05 03:06:06 +03:00
|
|
|
}
|
|
|
|
} else {
|
2004-03-05 06:58:21 +03:00
|
|
|
#endif
|
2003-12-29 05:38:17 +03:00
|
|
|
RF_RowCol_t spCol = raidPtr->Disks[pda->col].spareCol;
|
1999-02-05 03:06:06 +03:00
|
|
|
pda->col = spCol;
|
2004-03-05 06:58:21 +03:00
|
|
|
#if RF_INCLUDE_PARITY_DECLUSTERING_DS > 0
|
1999-02-05 03:06:06 +03:00
|
|
|
}
|
2004-03-05 06:58:21 +03:00
|
|
|
#endif
|
1999-02-05 03:06:06 +03:00
|
|
|
}
|
1998-11-13 07:20:26 +03:00
|
|
|
}
|
2003-12-29 05:38:17 +03:00
|
|
|
if (RF_DEAD_DISK(raidPtr->Disks[pda->col].status))
|
1999-02-05 03:06:06 +03:00
|
|
|
return (1);
|
|
|
|
return (0);
|
1998-11-13 07:20:26 +03:00
|
|
|
}
|
2003-12-31 19:23:50 +03:00
|
|
|
/*****************************************************************************
|
1998-11-13 07:20:26 +03:00
|
|
|
*
|
|
|
|
* currently a stub.
|
|
|
|
*
|
2003-12-31 19:23:50 +03:00
|
|
|
* takes as input an ASM describing a write operation and containing
|
|
|
|
* one failure, and verifies that the parity was correctly updated to
|
|
|
|
* reflect the write.
|
1998-11-13 07:20:26 +03:00
|
|
|
*
|
2003-12-31 19:23:50 +03:00
|
|
|
* if it's a data unit that's failed, we read the other data units in
|
|
|
|
* the stripe and the parity unit, XOR them together, and verify that
|
|
|
|
* we get the data intended for the failed disk. Since it's easy, we
|
|
|
|
* also validate that the right data got written to the surviving data
|
|
|
|
* disks.
|
1998-11-13 07:20:26 +03:00
|
|
|
*
|
2003-12-31 19:23:50 +03:00
|
|
|
* If it's the parity that failed, there's really no validation we can
|
|
|
|
* do except the above verification that the right data got written to
|
|
|
|
* all disks. This is because the new data intended for the failed
|
|
|
|
* disk is supplied in the ASM, but this is of course not the case for
|
|
|
|
* the new parity.
|
1998-11-13 07:20:26 +03:00
|
|
|
*
|
2003-12-31 19:23:50 +03:00
|
|
|
****************************************************************************/
|
2002-09-21 05:08:38 +04:00
|
|
|
#if 0
|
2005-02-27 03:26:58 +03:00
|
|
|
int
|
2003-12-31 19:23:50 +03:00
|
|
|
rf_VerifyDegrModeWrite(RF_Raid_t *raidPtr, RF_AccessStripeMapHeader_t *asmh)
|
1998-11-13 07:20:26 +03:00
|
|
|
{
|
1999-02-05 03:06:06 +03:00
|
|
|
return (0);
|
1998-11-13 07:20:26 +03:00
|
|
|
}
|
2002-09-21 05:08:38 +04:00
|
|
|
#endif
|
1998-11-13 07:20:26 +03:00
|
|
|
/* creates a simple DAG with a header, a block-recon node at level 1,
|
2003-12-31 19:23:50 +03:00
|
|
|
* nNodes nodes at level 2, an unblock-recon node at level 3, and a
|
|
|
|
* terminator node at level 4. The stripe address field in the block
|
|
|
|
* and unblock nodes are not touched, nor are the pda fields in the
|
|
|
|
* second-level nodes, so they must be filled in later.
|
1998-11-13 07:20:26 +03:00
|
|
|
*
|
|
|
|
* commit point is established at unblock node - this means that any
|
2005-02-27 03:26:58 +03:00
|
|
|
* failure during dag execution causes the dag to fail
|
2003-12-31 19:23:50 +03:00
|
|
|
*
|
|
|
|
* name - node names at the second level
|
1998-11-13 07:20:26 +03:00
|
|
|
*/
|
1999-02-05 03:06:06 +03:00
|
|
|
RF_DagHeader_t *
|
2003-12-31 19:23:50 +03:00
|
|
|
rf_MakeSimpleDAG(RF_Raid_t *raidPtr, int nNodes, int bytesPerSU, char *databuf,
|
|
|
|
int (*doFunc) (RF_DagNode_t * node),
|
|
|
|
int (*undoFunc) (RF_DagNode_t * node),
|
2005-05-30 02:03:09 +04:00
|
|
|
const char *name, RF_AllocListElem_t *alloclist,
|
2006-10-12 05:30:41 +04:00
|
|
|
RF_RaidAccessFlags_t flags __unused, int priority __unused)
|
1998-11-13 07:20:26 +03:00
|
|
|
{
|
1999-02-05 03:06:06 +03:00
|
|
|
RF_DagHeader_t *dag_h;
|
2004-03-18 20:26:36 +03:00
|
|
|
RF_DagNode_t *nodes, *termNode, *blockNode, *unblockNode, *tmpNode;
|
1999-02-05 03:06:06 +03:00
|
|
|
int i;
|
1998-11-13 07:20:26 +03:00
|
|
|
|
2004-03-18 20:26:36 +03:00
|
|
|
/* grab a DAG header... */
|
1998-11-13 07:20:26 +03:00
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
dag_h = rf_AllocDAGHeader();
|
|
|
|
dag_h->raidPtr = (void *) raidPtr;
|
|
|
|
dag_h->allocList = NULL;/* we won't use this alloc list */
|
|
|
|
dag_h->status = rf_enable;
|
|
|
|
dag_h->numSuccedents = 1;
|
|
|
|
dag_h->creator = "SimpleDAG";
|
1998-11-13 07:20:26 +03:00
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
/* this dag can not commit until the unblock node is reached errors
|
|
|
|
* prior to the commit point imply the dag has failed */
|
|
|
|
dag_h->numCommitNodes = 1;
|
|
|
|
dag_h->numCommits = 0;
|
|
|
|
|
2004-03-18 20:26:36 +03:00
|
|
|
/* create the nodes, the block & unblock nodes, and the terminator
|
|
|
|
* node */
|
|
|
|
|
|
|
|
for (i = 0; i < nNodes; i++) {
|
|
|
|
tmpNode = rf_AllocDAGNode();
|
|
|
|
tmpNode->list_next = dag_h->nodes;
|
|
|
|
dag_h->nodes = tmpNode;
|
|
|
|
}
|
|
|
|
nodes = dag_h->nodes;
|
|
|
|
|
|
|
|
blockNode = rf_AllocDAGNode();
|
|
|
|
blockNode->list_next = dag_h->nodes;
|
|
|
|
dag_h->nodes = blockNode;
|
|
|
|
|
|
|
|
unblockNode = rf_AllocDAGNode();
|
|
|
|
unblockNode->list_next = dag_h->nodes;
|
|
|
|
dag_h->nodes = unblockNode;
|
|
|
|
|
|
|
|
termNode = rf_AllocDAGNode();
|
|
|
|
termNode->list_next = dag_h->nodes;
|
|
|
|
dag_h->nodes = termNode;
|
|
|
|
|
1999-02-05 03:06:06 +03:00
|
|
|
dag_h->succedents[0] = blockNode;
|
|
|
|
rf_InitNode(blockNode, rf_wait, RF_FALSE, rf_NullNodeFunc, rf_NullNodeUndoFunc, NULL, nNodes, 0, 0, 0, dag_h, "Nil", alloclist);
|
|
|
|
rf_InitNode(unblockNode, rf_wait, RF_TRUE, rf_NullNodeFunc, rf_NullNodeUndoFunc, NULL, 1, nNodes, 0, 0, dag_h, "Nil", alloclist);
|
|
|
|
unblockNode->succedents[0] = termNode;
|
2004-03-18 20:26:36 +03:00
|
|
|
tmpNode = nodes;
|
1999-02-05 03:06:06 +03:00
|
|
|
for (i = 0; i < nNodes; i++) {
|
2004-03-18 20:26:36 +03:00
|
|
|
blockNode->succedents[i] = unblockNode->antecedents[i] = tmpNode;
|
1999-02-05 03:06:06 +03:00
|
|
|
unblockNode->antType[i] = rf_control;
|
2004-03-18 20:26:36 +03:00
|
|
|
rf_InitNode(tmpNode, rf_wait, RF_FALSE, doFunc, undoFunc, rf_GenericWakeupFunc, 1, 1, 4, 0, dag_h, name, alloclist);
|
|
|
|
tmpNode->succedents[0] = unblockNode;
|
|
|
|
tmpNode->antecedents[0] = blockNode;
|
|
|
|
tmpNode->antType[0] = rf_control;
|
|
|
|
tmpNode->params[1].p = (databuf + (i * bytesPerSU));
|
|
|
|
tmpNode = tmpNode->list_next;
|
1999-02-05 03:06:06 +03:00
|
|
|
}
|
|
|
|
rf_InitNode(termNode, rf_wait, RF_FALSE, rf_TerminateFunc, rf_TerminateUndoFunc, NULL, 0, 1, 0, 0, dag_h, "Trm", alloclist);
|
|
|
|
termNode->antecedents[0] = unblockNode;
|
|
|
|
termNode->antType[0] = rf_control;
|
|
|
|
return (dag_h);
|
1998-11-13 07:20:26 +03:00
|
|
|
}
|