rf_decluster.h revision 1.1
1/*	$NetBSD: rf_decluster.h,v 1.1 1998/11/13 04:20:28 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/*
39 * :
40 * Log: rf_decluster.h,v
41 * Revision 1.20  1996/07/29 14:05:12  jimz
42 * fix numPUs/numRUs confusion (everything is now numRUs)
43 * clean up some commenting, return values
44 *
45 * Revision 1.19  1996/07/13  00:00:59  jimz
46 * sanitized generalized reconstruction architecture
47 * cleaned up head sep, rbuf problems
48 *
49 * Revision 1.18  1996/06/19  17:53:48  jimz
50 * move GetNumSparePUs, InstallSpareTable ops into layout switch
51 *
52 * Revision 1.17  1996/06/10  11:55:47  jimz
53 * Straightened out some per-array/not-per-array distinctions, fixed
54 * a couple bugs related to confusion. Added shutdown lists. Removed
55 * layout shutdown function (now subsumed by shutdown lists).
56 *
57 * Revision 1.16  1996/06/09  02:36:46  jimz
58 * lots of little crufty cleanup- fixup whitespace
59 * issues, comment #ifdefs, improve typing in some
60 * places (esp size-related)
61 *
62 * Revision 1.15  1996/06/07  22:26:27  jimz
63 * type-ify which_ru (RF_ReconUnitNum_t)
64 *
65 * Revision 1.14  1996/06/07  21:33:04  jimz
66 * begin using consistent types for sector numbers,
67 * stripe numbers, row+col numbers, recon unit numbers
68 *
69 * Revision 1.13  1996/05/27  18:56:37  jimz
70 * more code cleanup
71 * better typing
72 * compiles in all 3 environments
73 *
74 * Revision 1.12  1996/05/24  01:59:45  jimz
75 * another checkpoint in code cleanup for release
76 * time to sync kernel tree
77 *
78 * Revision 1.11  1996/05/23  21:46:35  jimz
79 * checkpoint in code cleanup (release prep)
80 * lots of types, function names have been fixed
81 *
82 * Revision 1.10  1996/05/18  19:51:34  jimz
83 * major code cleanup- fix syntax, make some types consistent,
84 * add prototypes, clean out dead code, et cetera
85 *
86 * Revision 1.9  1995/12/01  15:58:23  root
87 * added copyright info
88 *
89 * Revision 1.8  1995/11/17  18:57:02  wvcii
90 * added prototyping to MapParity
91 *
92 * Revision 1.7  1995/07/02  15:08:31  holland
93 * bug fixes related to getting distributed sparing numbers
94 *
95 * Revision 1.6  1995/06/23  13:41:18  robby
96 * updeated to prototypes in rf_layout.h
97 *
98 */
99
100#ifndef _RF__RF_DECLUSTER_H_
101#define _RF__RF_DECLUSTER_H_
102
103#include "rf_types.h"
104
105/*
106 * These structures define the tables used to locate the spare unit
107 * associated with a particular data or parity unit, and to perform
108 * the associated inverse mapping.
109 */
110struct RF_SpareTableEntry_s {
111    u_int spareDisk;             /* disk to which this block is spared */
112    u_int spareBlockOffsetInSUs; /* offset into spare table for that disk */
113};
114
115#define RF_SPAREMAP_NAME_LEN 128
116
117/* this is the layout-specific info structure for the declustered layout.
118 */
119struct RF_DeclusteredConfigInfo_s {
120  RF_StripeCount_t    groupSize;                      /* no. of stripe units per parity stripe */
121  RF_RowCol_t       **LayoutTable;	                  /* the block design table */
122  RF_RowCol_t       **OffsetTable;                    /* the sector offset table */
123  RF_RowCol_t       **BlockTable;                     /* the block membership table */
124  RF_StripeCount_t    SUsPerFullTable;                /* stripe units per full table */
125  RF_StripeCount_t    SUsPerTable;                    /* stripe units per table */
126  RF_StripeCount_t    PUsPerBlock;                    /* parity units per block */
127  RF_StripeCount_t    SUsPerBlock;                    /* stripe units per block */
128  RF_StripeCount_t    BlocksPerTable;                 /* block design tuples per table */
129  RF_StripeCount_t    NumParityReps;                  /* tables per full table */
130  RF_StripeCount_t    TableDepthInPUs;                /* PUs on one disk in 1 table */
131  RF_StripeCount_t    FullTableDepthInPUs;            /* PUs on one disk in 1 fulltable */
132  RF_StripeCount_t    FullTableLimitSUID;             /* SU where partial fulltables start */
133  RF_StripeCount_t    ExtraTablesPerDisk;             /* # of tables in last fulltable */
134  RF_SectorNum_t      DiskOffsetOfLastFullTableInSUs; /* disk offs of partial ft, if any */
135  RF_StripeCount_t    numCompleteFullTablesPerDisk;   /* ft identifier of partial ft, if any */
136  u_int               Lambda;                         /* the pair count in the block design */
137
138  /* these are used only in the distributed-sparing case */
139  RF_StripeCount_t    FullTablesPerSpareRegion;       /* # of ft's comprising 1 spare region */
140  RF_StripeCount_t    TablesPerSpareRegion;           /* # of tables */
141  RF_SectorCount_t    SpareSpaceDepthPerRegionInSUs;  /* spare space/disk/region */
142  RF_SectorCount_t    SpareRegionDepthInSUs;          /* # of units/disk/region */
143  RF_SectorNum_t      DiskOffsetOfLastSpareSpaceChunkInSUs; /* locates sp space after partial ft */
144  RF_StripeCount_t    TotSparePUsPerDisk;             /* total number of spare PUs per disk */
145  RF_StripeCount_t    NumCompleteSRs;
146  RF_SpareTableEntry_t        **SpareTable;           /* remap table for spare space */
147  char sparemap_fname[RF_SPAREMAP_NAME_LEN];          /* where to find sparemap. not used in kernel */
148};
149
150int rf_ConfigureDeclustered(RF_ShutdownList_t **listp, RF_Raid_t *raidPtr,
151	RF_Config_t *cfgPtr);
152int rf_ConfigureDeclusteredDS(RF_ShutdownList_t **listp, RF_Raid_t *raidPtr,
153	RF_Config_t *cfgPtr);
154
155void rf_MapSectorDeclustered(RF_Raid_t *raidPtr, RF_RaidAddr_t raidSector,
156	RF_RowCol_t *row, RF_RowCol_t *col, RF_SectorNum_t *diskSector, int remap);
157void rf_MapParityDeclustered(RF_Raid_t *raidPtr, RF_RaidAddr_t raidSector,
158	RF_RowCol_t *row, RF_RowCol_t *col, RF_SectorNum_t *diskSector, int remap);
159void rf_IdentifyStripeDeclustered(RF_Raid_t *raidPtr, RF_RaidAddr_t addr,
160	RF_RowCol_t **diskids, RF_RowCol_t *outRow);
161void rf_MapSIDToPSIDDeclustered(RF_RaidLayout_t *layoutPtr,
162	RF_StripeNum_t stripeID, RF_StripeNum_t *psID,
163	RF_ReconUnitNum_t *which_ru);
164int  rf_InstallSpareTable(RF_Raid_t *raidPtr, RF_RowCol_t frow, RF_RowCol_t fcol);
165void rf_FreeSpareTable(RF_Raid_t *raidPtr);
166
167RF_HeadSepLimit_t rf_GetDefaultHeadSepLimitDeclustered(RF_Raid_t *raidPtr);
168int rf_GetDefaultNumFloatingReconBuffersDeclustered(RF_Raid_t *raidPtr);
169
170void rf_decluster_adjust_params(RF_RaidLayout_t *layoutPtr,
171	RF_StripeNum_t *SUID, RF_StripeCount_t *sus_per_fulltable,
172	RF_StripeCount_t *fulltable_depth, RF_StripeNum_t *base_suid);
173void rf_remap_to_spare_space(
174RF_RaidLayout_t *layoutPtr,
175RF_DeclusteredConfigInfo_t *info, RF_RowCol_t row, RF_StripeNum_t FullTableID,
176	RF_StripeNum_t TableID, RF_SectorNum_t BlockID, RF_StripeNum_t base_suid,
177	RF_StripeNum_t SpareRegion, RF_RowCol_t *outCol, RF_StripeNum_t *outSU);
178int rf_SetSpareTable(RF_Raid_t *raidPtr, void *data);
179RF_ReconUnitCount_t rf_GetNumSpareRUsDeclustered(RF_Raid_t *raidPtr);
180
181#endif /* !_RF__RF_DECLUSTER_H_ */
182