⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rf_decluster.c

📁 RAIDFrame是个非常好的磁盘阵列RAID仿真工具
💻 C
📖 第 1 页 / 共 3 页
字号:
/* * 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_decluster.c -- code related to the declustered layout * * Created 10-21-92 (MCH) * * Nov 93:  adding support for distributed sparing.  This code is a little *          complex:  the basic layout used is as follows: *          let F = (v-1)/GCD(r,v-1).  The spare space for each set of *          F consecutive fulltables is grouped together and placed after *          that set of tables. *                   +------------------------------+ *                   |        F fulltables          | *                   |        Spare Space           | *                   |        F fulltables          | *                   |        Spare Space           | *                   |            ...               | *                   +------------------------------+ * *--------------------------------------------------------------------*//* * $Locker:  $ * $Log: rf_decluster.c,v $ * Revision 1.51  1996/08/21  19:47:10  jimz * fix bogus return values from config * * Revision 1.50  1996/08/20  22:41:42  jimz * better diagnostics for bad blockdesigns * * Revision 1.49  1996/07/31  16:56:18  jimz * dataBytesPerStripe, sectorsPerDisk init arch-indep. * * Revision 1.48  1996/07/29  14:05:12  jimz * fix numPUs/numRUs confusion (everything is now numRUs) * clean up some commenting, return values * * Revision 1.47  1996/07/27  23:36:08  jimz * Solaris port of simulator * * Revision 1.46  1996/07/27  18:40:11  jimz * cleanup sweep * * Revision 1.45  1996/07/18  22:57:14  jimz * port simulator to AIX * * Revision 1.44  1996/07/13  00:00:59  jimz * sanitized generalized reconstruction architecture * cleaned up head sep, rbuf problems * * Revision 1.43  1996/06/19  17:53:48  jimz * move GetNumSparePUs, InstallSpareTable ops into layout switch * * Revision 1.42  1996/06/17  03:23:48  jimz * switch DeclusteredDS typing * * Revision 1.41  1996/06/11  08:55:15  jimz * improved error-checking at configuration time * * Revision 1.40  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.39  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.38  1996/06/07  22:26:27  jimz * type-ify which_ru (RF_ReconUnitNum_t) * * Revision 1.37  1996/06/07  21:33:04  jimz * begin using consistent types for sector numbers, * stripe numbers, row+col numbers, recon unit numbers * * Revision 1.36  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.35  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.34  1996/05/30  23:22:16  jimz * bugfixes of serialization, timing problems * more cleanup * * Revision 1.33  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.32  1996/05/27  18:56:37  jimz * more code cleanup * better typing * compiles in all 3 environments * * Revision 1.31  1996/05/24  01:59:45  jimz * another checkpoint in code cleanup for release * time to sync kernel tree * * Revision 1.30  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.29  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.28  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.27  1995/12/01  16:00:08  root * added copyright info * * Revision 1.26  1995/11/28  21:35:12  amiri * set the RF_BD_DECLUSTERED flag * * Revision 1.25  1995/11/17  18:56:00  wvcii * added prototyping to MapParity * * Revision 1.24  1995/07/04  22:25:33  holland * increased default num bufs * * Revision 1.23  1995/07/03  20:23:51  holland * changed floating recon bufs & head sep yet again * * Revision 1.22  1995/07/03  18:12:14  holland * changed the way the number of floating recon bufs & the head sep * limit are set * * Revision 1.21  1995/07/02  15:07:42  holland * bug fixes related to getting distributed sparing numbers * * Revision 1.20  1995/06/23  13:41:28  robby * updeated to prototypes in rf_layout.h * */#include "rf_types.h"#include "rf_raid.h"#include "rf_raidframe.h"#include "rf_configure.h"#include "rf_decluster.h"#include "rf_debugMem.h"#include "rf_utils.h"#include "rf_alloclist.h"#include "rf_general.h"#include "rf_shutdown.h"#include "rf_sys.h"extern int rf_copyback_in_progress;                /* debug only *//* configuration code */int rf_ConfigureDeclustered(  RF_ShutdownList_t  **listp,  RF_Raid_t           *raidPtr,  RF_Config_t         *cfgPtr){    RF_RaidLayout_t *layoutPtr = &(raidPtr->Layout);    int b, v, k, r, lambda;				/* block design params */    int i, j;    RF_RowCol_t *first_avail_slot;    RF_StripeCount_t complete_FT_count, numCompleteFullTablesPerDisk;    RF_DeclusteredConfigInfo_t *info;    RF_StripeCount_t PUsPerDisk, spareRegionDepthInPUs, numCompleteSpareRegionsPerDisk, extraPUsPerDisk;    RF_StripeCount_t totSparePUsPerDisk;    RF_SectorNum_t diskOffsetOfLastFullTableInSUs;    RF_SectorCount_t SpareSpaceInSUs;    char *cfgBuf = (char *) (cfgPtr->layoutSpecific);    RF_StripeNum_t l, SUID;    SUID = l = 0;    numCompleteSpareRegionsPerDisk = 0;    /* 1. create layout specific structure */    RF_MallocAndAdd(info, sizeof(RF_DeclusteredConfigInfo_t), (RF_DeclusteredConfigInfo_t *), raidPtr->cleanupList);    if (info == NULL)      return(ENOMEM);    layoutPtr->layoutSpecificInfo = (void *) info;    info->SpareTable = NULL;    /* 2. extract parameters from the config structure */    if (layoutPtr->map->flags & RF_DISTRIBUTE_SPARE) {      (void) bcopy(cfgBuf, info->sparemap_fname, RF_SPAREMAP_NAME_LEN);    }    cfgBuf += RF_SPAREMAP_NAME_LEN;        b        = *( (int *) cfgBuf);   cfgBuf += sizeof(int);    v        = *( (int *) cfgBuf);   cfgBuf += sizeof(int);    k        = *( (int *) cfgBuf);   cfgBuf += sizeof(int);    r        = *( (int *) cfgBuf);   cfgBuf += sizeof(int);    lambda   = *( (int *) cfgBuf);   cfgBuf += sizeof(int);    raidPtr->noRotate = *( (int *) cfgBuf);   cfgBuf += sizeof(int);    /* the sparemaps are generated assuming that parity is rotated, so we issue     * a warning if both distributed sparing and no-rotate are on at the same time     */    if ((layoutPtr->map->flags & RF_DISTRIBUTE_SPARE) && raidPtr->noRotate) {	RF_ERRORMSG("Warning:  distributed sparing specified without parity rotation.\n");    }    if (raidPtr->numCol != v) {        RF_ERRORMSG2("RAID: config error: table element count (%d) not equal to no. of cols (%d)\n", v, raidPtr->numCol);        return(EINVAL);    }    /* 3.  set up the values used in the mapping code */    info->BlocksPerTable = b;    info->Lambda = lambda;    info->NumParityReps = info->groupSize = k;    info->SUsPerTable = b * (k-1) * layoutPtr->SUsPerPU;/* b blks, k-1 SUs each */    info->SUsPerFullTable = k * info->SUsPerTable;	/* rot k times */    info->PUsPerBlock = k-1;    info->SUsPerBlock = info->PUsPerBlock * layoutPtr->SUsPerPU;    info->TableDepthInPUs = (b*k) / v;    info->FullTableDepthInPUs = info->TableDepthInPUs * k;		/* k repetitions */    /* used only in distributed sparing case */    info->FullTablesPerSpareRegion = (v-1) / rf_gcd(r, v-1);		/* (v-1)/gcd fulltables */    info->TablesPerSpareRegion = k * info->FullTablesPerSpareRegion;    info->SpareSpaceDepthPerRegionInSUs = (r * info->TablesPerSpareRegion / (v-1)) * layoutPtr->SUsPerPU;    /* check to make sure the block design is sufficiently small */    if ((raidPtr->Layout.map->flags & RF_DISTRIBUTE_SPARE)) {        if (info->FullTableDepthInPUs * layoutPtr->SUsPerPU + info->SpareSpaceDepthPerRegionInSUs > layoutPtr->stripeUnitsPerDisk) {	    RF_ERRORMSG3("RAID: config error: Full Table depth (%d) + Spare Space (%d) larger than disk size (%d) (BD too big)\n",		    info->FullTableDepthInPUs, info->SpareSpaceDepthPerRegionInSUs, layoutPtr->stripeUnitsPerDisk);	    return(EINVAL);	}    } else {	if (info->TableDepthInPUs * layoutPtr->SUsPerPU > layoutPtr->stripeUnitsPerDisk) {	    RF_ERRORMSG2("RAID: config error: Table depth (%d) larger than disk size (%d) (BD too big)\n",		    info->TableDepthInPUs * layoutPtr->SUsPerPU, layoutPtr->stripeUnitsPerDisk);	    return(EINVAL);	}    }	

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -