📄 rf_parityscan.c
字号:
/* * 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 * *****************************************************************************//* * $Locker: $ * $Log: rf_parityscan.c,v $ * Revision 1.47 1996/08/20 20:35:01 jimz * change diagnostic string in rewrite * * Revision 1.46 1996/08/20 20:03:19 jimz * fixed parity rewrite to actually use arch-specific parity stuff * (this ever worked... how?) * * Revision 1.45 1996/08/16 17:41:25 jimz * allow rewrite parity on any fault-tolerant arch * * Revision 1.44 1996/07/28 20:31:39 jimz * i386netbsd port * true/false fixup * * Revision 1.43 1996/07/27 23:36:08 jimz * Solaris port of simulator * * Revision 1.42 1996/07/22 21:12:01 jimz * clean up parity scan status printing * * Revision 1.41 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.40 1996/07/13 00:00:59 jimz * sanitized generalized reconstruction architecture * cleaned up head sep, rbuf problems * * Revision 1.39 1996/07/09 21:44:26 jimz * fix bogus return code in VerifyParityBasic when a stripe can't be corrected * * Revision 1.38 1996/06/20 17:56:57 jimz * update VerifyParity to check complete AccessStripeMaps * * Revision 1.37 1996/06/19 22:23:01 jimz * parity verification is now a layout-configurable thing * not all layouts currently support it (correctly, anyway) * * Revision 1.36 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.35 1996/06/07 22:26:27 jimz * type-ify which_ru (RF_ReconUnitNum_t) * * Revision 1.34 1996/06/07 21:33:04 jimz * begin using consistent types for sector numbers, * stripe numbers, row+col numbers, recon unit numbers * * Revision 1.33 1996/06/05 18:06:02 jimz * Major code cleanup. The Great Renaming is now done. * Better modularity. Better typing. Fixed a bunch of * synchronization bugs. Made a lot of global stuff * per-desc or per-array. Removed dead code. * * Revision 1.32 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.31 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.30 1996/05/30 23:22:16 jimz * bugfixes of serialization, timing problems * more cleanup * * Revision 1.29 1996/05/30 12:59:18 jimz * make etimer happier, more portable * * Revision 1.28 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.27 1996/05/27 18:56:37 jimz * more code cleanup * better typing * compiles in all 3 environments * * Revision 1.26 1996/05/24 22:17:04 jimz * continue code + namespace cleanup * typed a bunch of flags * * Revision 1.25 1996/05/24 04:28:55 jimz * release cleanup ckpt * * Revision 1.24 1996/05/23 21:46:35 jimz * checkpoint in code cleanup (release prep) * lots of types, function names have been fixed * * Revision 1.23 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.22 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.21 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.20 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.19 1995/11/30 16:16:49 wvcii * added copyright info * * Revision 1.18 1995/11/19 16:32:19 wvcii * eliminated initialization of dag header fields which no longer exist * (numDags, numDagsDone, firstHdr) * * Revision 1.17 1995/11/07 16:23:36 wvcii * added comments, asserts, and prototypes * encoded commit point nodes, barrier, and antecedents types into dags * */#include "rf_types.h"#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"#include "rf_sys.h"/***************************************************************************************** * * 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. * * there should never be more than one thread running this. * ****************************************************************************************/int rf_RewriteParity(raidPtr) RF_Raid_t *raidPtr;{ RF_RaidLayout_t *layoutPtr = &raidPtr->Layout; RF_AccessStripeMapHeader_t *asm_h; int old_pctg, new_pctg, rc; RF_PhysDiskAddr_t pda; RF_SectorNum_t i; pda.startSector = 0; pda.numSector = raidPtr->Layout.sectorsPerStripeUnit; old_pctg = -1; for (i=0; i<raidPtr->totalSectors; i+=layoutPtr->dataSectorsPerStripe) { asm_h = rf_MapAccess(raidPtr, i, layoutPtr->dataSectorsPerStripe, NULL, RF_DONT_REMAP); rc = rf_VerifyParity(raidPtr, asm_h->stripeMap, 1, 0); switch (rc) { case RF_PARITY_OKAY: case RF_PARITY_CORRECTED: break; case RF_PARITY_BAD: printf("Parity bad during correction\n"); RF_PANIC(); break; case RF_PARITY_COULD_NOT_CORRECT: printf("Could not correct bad parity\n"); RF_PANIC(); break; case RF_PARITY_COULD_NOT_VERIFY: printf("Could not verify parity\n"); RF_PANIC(); break; default: printf("Bad rc=%d from VerifyParity in RewriteParity\n", rc); RF_PANIC(); } rf_FreeAccessStripeMap(asm_h); new_pctg = i*1000/raidPtr->totalSectors; if (new_pctg != old_pctg) {#ifndef KERNEL fprintf(stderr,"\rParity rewrite: %d.%d%% complete", new_pctg/10, new_pctg%10); fflush(stderr);#endif /* !KERNEL */ } old_pctg = new_pctg; }#ifndef KERNEL fprintf(stderr,"\rParity rewrite: 100.0%% complete\n");#endif /* !KERNEL */}/***************************************************************************************** * * 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 * region defined by the parityPDA. * ****************************************************************************************/int rf_VerifyParity(raidPtr, aasm, correct_it, flags) RF_Raid_t *raidPtr; RF_AccessStripeMap_t *aasm; int correct_it; RF_RaidAccessFlags_t flags;{ RF_PhysDiskAddr_t *parityPDA; RF_AccessStripeMap_t *doasm; RF_LayoutSW_t *lp; int lrc, rc; lp = raidPtr->Layout.map; if (lp->faultsTolerated == 0) { /* * There isn't any parity. Call it "okay."
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -