rf_decluster.h revision 1.2
1/*	$NetBSD: rf_decluster.h,v 1.2 1999/01/26 02:33:55 oster Exp $	*/
2/*
3 * Copyright (c) 1995 Carnegie-Mellon University.
4 * All rights reserved.
5 *
6 * Author: Mark Holland
7 *
8 * Permission to use, copy, modify and distribute this software and
9 * its documentation is hereby granted, provided that both the copyright
10 * notice and this permission notice appear in all copies of the
11 * software, derivative works or modified versions, and any portions
12 * thereof, and that both notices appear in supporting documentation.
13 *
14 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
15 * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
16 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
17 *
18 * Carnegie Mellon requests users of this software to return to
19 *
20 *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
21 *  School of Computer Science
22 *  Carnegie Mellon University
23 *  Pittsburgh PA 15213-3890
24 *
25 * any improvements or extensions that they make and grant Carnegie the
26 * rights to redistribute these changes.
27 */
28
29/*----------------------------------------------------------------------
30 *
31 * decluster.h -- header file for declustered layout code
32 *
33 * Adapted from raidSim version July 1994
34 * Created 10-21-92 (MCH)
35 *
36 *--------------------------------------------------------------------*/
37
38#ifndef _RF__RF_DECLUSTER_H_
39#define _RF__RF_DECLUSTER_H_
40
41#include "rf_types.h"
42
43/*
44 * These structures define the tables used to locate the spare unit
45 * associated with a particular data or parity unit, and to perform
46 * the associated inverse mapping.
47 */
48struct RF_SpareTableEntry_s {
49    u_int spareDisk;             /* disk to which this block is spared */
50    u_int spareBlockOffsetInSUs; /* offset into spare table for that disk */
51};
52
53#define RF_SPAREMAP_NAME_LEN 128
54
55/* this is the layout-specific info structure for the declustered layout.
56 */
57struct RF_DeclusteredConfigInfo_s {
58  RF_StripeCount_t    groupSize;                      /* no. of stripe units per parity stripe */
59  RF_RowCol_t       **LayoutTable;	                  /* the block design table */
60  RF_RowCol_t       **OffsetTable;                    /* the sector offset table */
61  RF_RowCol_t       **BlockTable;                     /* the block membership table */
62  RF_StripeCount_t    SUsPerFullTable;                /* stripe units per full table */
63  RF_StripeCount_t    SUsPerTable;                    /* stripe units per table */
64  RF_StripeCount_t    PUsPerBlock;                    /* parity units per block */
65  RF_StripeCount_t    SUsPerBlock;                    /* stripe units per block */
66  RF_StripeCount_t    BlocksPerTable;                 /* block design tuples per table */
67  RF_StripeCount_t    NumParityReps;                  /* tables per full table */
68  RF_StripeCount_t    TableDepthInPUs;                /* PUs on one disk in 1 table */
69  RF_StripeCount_t    FullTableDepthInPUs;            /* PUs on one disk in 1 fulltable */
70  RF_StripeCount_t    FullTableLimitSUID;             /* SU where partial fulltables start */
71  RF_StripeCount_t    ExtraTablesPerDisk;             /* # of tables in last fulltable */
72  RF_SectorNum_t      DiskOffsetOfLastFullTableInSUs; /* disk offs of partial ft, if any */
73  RF_StripeCount_t    numCompleteFullTablesPerDisk;   /* ft identifier of partial ft, if any */
74  u_int               Lambda;                         /* the pair count in the block design */
75
76  /* these are used only in the distributed-sparing case */
77  RF_StripeCount_t    FullTablesPerSpareRegion;       /* # of ft's comprising 1 spare region */
78  RF_StripeCount_t    TablesPerSpareRegion;           /* # of tables */
79  RF_SectorCount_t    SpareSpaceDepthPerRegionInSUs;  /* spare space/disk/region */
80  RF_SectorCount_t    SpareRegionDepthInSUs;          /* # of units/disk/region */
81  RF_SectorNum_t      DiskOffsetOfLastSpareSpaceChunkInSUs; /* locates sp space after partial ft */
82  RF_StripeCount_t    TotSparePUsPerDisk;             /* total number of spare PUs per disk */
83  RF_StripeCount_t    NumCompleteSRs;
84  RF_SpareTableEntry_t        **SpareTable;           /* remap table for spare space */
85  char sparemap_fname[RF_SPAREMAP_NAME_LEN];          /* where to find sparemap. not used in kernel */
86};
87
88int rf_ConfigureDeclustered(RF_ShutdownList_t **listp, RF_Raid_t *raidPtr,
89	RF_Config_t *cfgPtr);
90int rf_ConfigureDeclusteredDS(RF_ShutdownList_t **listp, RF_Raid_t *raidPtr,
91	RF_Config_t *cfgPtr);
92
93void rf_MapSectorDeclustered(RF_Raid_t *raidPtr, RF_RaidAddr_t raidSector,
94	RF_RowCol_t *row, RF_RowCol_t *col, RF_SectorNum_t *diskSector, int remap);
95void rf_MapParityDeclustered(RF_Raid_t *raidPtr, RF_RaidAddr_t raidSector,
96	RF_RowCol_t *row, RF_RowCol_t *col, RF_SectorNum_t *diskSector, int remap);
97void rf_IdentifyStripeDeclustered(RF_Raid_t *raidPtr, RF_RaidAddr_t addr,
98	RF_RowCol_t **diskids, RF_RowCol_t *outRow);
99void rf_MapSIDToPSIDDeclustered(RF_RaidLayout_t *layoutPtr,
100	RF_StripeNum_t stripeID, RF_StripeNum_t *psID,
101	RF_ReconUnitNum_t *which_ru);
102int  rf_InstallSpareTable(RF_Raid_t *raidPtr, RF_RowCol_t frow, RF_RowCol_t fcol);
103void rf_FreeSpareTable(RF_Raid_t *raidPtr);
104
105RF_HeadSepLimit_t rf_GetDefaultHeadSepLimitDeclustered(RF_Raid_t *raidPtr);
106int rf_GetDefaultNumFloatingReconBuffersDeclustered(RF_Raid_t *raidPtr);
107
108void rf_decluster_adjust_params(RF_RaidLayout_t *layoutPtr,
109	RF_StripeNum_t *SUID, RF_StripeCount_t *sus_per_fulltable,
110	RF_StripeCount_t *fulltable_depth, RF_StripeNum_t *base_suid);
111void rf_remap_to_spare_space(
112RF_RaidLayout_t *layoutPtr,
113RF_DeclusteredConfigInfo_t *info, RF_RowCol_t row, RF_StripeNum_t FullTableID,
114	RF_StripeNum_t TableID, RF_SectorNum_t BlockID, RF_StripeNum_t base_suid,
115	RF_StripeNum_t SpareRegion, RF_RowCol_t *outCol, RF_StripeNum_t *outSU);
116int rf_SetSpareTable(RF_Raid_t *raidPtr, void *data);
117RF_ReconUnitCount_t rf_GetNumSpareRUsDeclustered(RF_Raid_t *raidPtr);
118
119#endif /* !_RF__RF_DECLUSTER_H_ */
120