📄 rf_copyback.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. *//***************************************************************************************** * * copyback.c -- code to copy reconstructed data back from spare space to * the replaced disk. * * the code operates using callbacks on the I/Os to continue with the next * unit to be copied back. We do this because a simple loop containing blocking I/Os * will not work in the simulator. * ****************************************************************************************//* * $Locker: $ * $Log: rf_copyback.c,v $ * Revision 1.26 1996/08/06 22:26:00 jimz * don't include sys/buf.h on linux * * Revision 1.25 1996/07/30 03:30:40 jimz * include rf_types.h first * * Revision 1.24 1996/07/27 18:39:52 jimz * cleanup sweep * * Revision 1.23 1996/07/18 22:57:14 jimz * port simulator to AIX * * Revision 1.22 1996/07/11 19:08:00 jimz * generalize reconstruction mechanism * allow raid1 reconstructs via copyback (done with array * quiesced, not online, therefore not disk-directed) * * Revision 1.21 1996/07/11 16:03:47 jimz * fixed hanging bug in rf_CopybackWriteDoneProc() * * Revision 1.20 1996/06/10 11:55:47 jimz * Straightened out some per-array/not-per-array distinctions, fixed * a couple bugs related to confusion. Added shutdown lists. Removed * layout shutdown function (now subsumed by shutdown lists). * * Revision 1.19 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.18 1996/06/07 21:33:04 jimz * begin using consistent types for sector numbers, * stripe numbers, row+col numbers, recon unit numbers * * Revision 1.17 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.16 1996/06/03 23:28:26 jimz * more bugfixes * check in tree to sync for IPDS runs with current bugfixes * there still may be a problem with threads in the script test * getting I/Os stuck- not trivially reproducible (runs ~50 times * in a row without getting stuck) * * Revision 1.15 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.14 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.13 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.12 1996/05/27 18:56:37 jimz * more code cleanup * better typing * compiles in all 3 environments * * Revision 1.11 1996/05/24 22:17:04 jimz * continue code + namespace cleanup * typed a bunch of flags * * Revision 1.10 1996/05/24 01:59:45 jimz * another checkpoint in code cleanup for release * time to sync kernel tree * * Revision 1.9 1996/05/23 21:46:35 jimz * checkpoint in code cleanup (release prep) * lots of types, function names have been fixed * * Revision 1.8 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.7 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.6 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.5 1995/12/01 15:15:31 root * added copyright info * * Revision 1.4 1995/06/23 13:41:36 robby * updeated to prototypes in rf_layout.h * */#include "rf_types.h"#include <sys/time.h>#ifndef LINUX#include <sys/buf.h>#endif /* !LINUX */#include "rf_raid.h"#include "rf_threadid.h"#include "rf_mcpair.h"#include "rf_acctrace.h"#include "rf_etimer.h"#include "rf_general.h"#include "rf_utils.h"#include "rf_copyback.h"#include "rf_camlayer.h"#include "rf_decluster.h"#include "rf_driver.h"#include "rf_shutdown.h"#include "rf_sys.h"#define RF_COPYBACK_DATA 0#define RF_COPYBACK_PARITY 1int rf_copyback_in_progress;static int rf_CopybackReadDoneProc(RF_CopybackDesc_t *desc, int status);static int rf_CopybackWriteDoneProc(RF_CopybackDesc_t *desc, int status);static void rf_CopybackOne(RF_CopybackDesc_t *desc, int typ, RF_RaidAddr_t addr, RF_RowCol_t testRow, RF_RowCol_t testCol, RF_SectorNum_t testOffs);static void rf_CopybackComplete(RF_CopybackDesc_t *desc, int status);int rf_ConfigureCopyback(listp) RF_ShutdownList_t **listp;{ rf_copyback_in_progress = 0; return(0);}/* do a complete copyback */void rf_CopybackReconstructedData(raidPtr) RF_Raid_t *raidPtr;{ int bus, targ, lun, done, retcode; RF_CopybackDesc_t *desc; RF_RowCol_t frow, fcol; RF_RaidDisk_t *badDisk; RF_DiskOp_t *tur_op; char *databuf; done = 0; fcol = 0; for (frow=0; frow<raidPtr->numRow; frow++) { for (fcol=0; fcol<raidPtr->numCol; fcol++) { if (raidPtr->Disks[frow][fcol].status == rf_ds_dist_spared || raidPtr->Disks[frow][fcol].status == rf_ds_spared) { done = 1; break; } } if (done) break; } if (frow == raidPtr->numRow) { printf("COPYBACK: no disks need copyback\n"); return; } badDisk = &raidPtr->Disks[frow][fcol];#ifndef SIMULATE if (rf_extract_ids(badDisk->devname, &bus, &targ, &lun)) { printf("COPYBACK: unable to extract bus, target, lun from devname %s\n", badDisk->devname); return; } /* TUR the disk that's marked as bad to be sure that it's actually alive */ rf_SCSI_AllocTUR(&tur_op); retcode = rf_SCSI_DoTUR(tur_op, bus, targ, lun, badDisk->dev); rf_SCSI_FreeDiskOp(tur_op, 0); if (retcode) { printf("COPYBACK: target disk failed TUR\n"); return; }#endif /* !SIMULATE */ /* get a buffer to hold one SU */ RF_Malloc(databuf, rf_RaidAddressToByte(raidPtr, raidPtr->Layout.sectorsPerStripeUnit), (char *)); /* create a descriptor */ RF_Malloc(desc, sizeof(*desc), (RF_CopybackDesc_t *)); desc->raidPtr = raidPtr; desc->status = 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -