rf_decluster.h revision 1.3
1/*	$NetBSD: rf_decluster.h,v 1.3 1999/02/05 00:06:09 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
51					 * disk */
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
59					 * stripe */
60	RF_RowCol_t **LayoutTable;	/* the block design table */
61	RF_RowCol_t **OffsetTable;	/* the sector offset table */
62	RF_RowCol_t **BlockTable;	/* the block membership table */
63	RF_StripeCount_t SUsPerFullTable;	/* stripe units per full table */
64	RF_StripeCount_t SUsPerTable;	/* stripe units per table */
65	RF_StripeCount_t PUsPerBlock;	/* parity units per block */
66	RF_StripeCount_t SUsPerBlock;	/* stripe units per block */
67	RF_StripeCount_t BlocksPerTable;	/* block design tuples per
68						 * table */
69	RF_StripeCount_t NumParityReps;	/* tables per full table */
70	RF_StripeCount_t TableDepthInPUs;	/* PUs on one disk in 1 table */
71	RF_StripeCount_t FullTableDepthInPUs;	/* PUs on one disk in 1
72						 * fulltable */
73	RF_StripeCount_t FullTableLimitSUID;	/* SU where partial fulltables
74						 * start */
75	RF_StripeCount_t ExtraTablesPerDisk;	/* # of tables in last
76						 * fulltable */
77	RF_SectorNum_t DiskOffsetOfLastFullTableInSUs;	/* disk offs of partial
78							 * ft, if any */
79	RF_StripeCount_t numCompleteFullTablesPerDisk;	/* ft identifier of
80							 * partial ft, if any */
81	u_int   Lambda;		/* the pair count in the block design */
82
83	/* these are used only in the distributed-sparing case */
84	RF_StripeCount_t FullTablesPerSpareRegion;	/* # of ft's comprising
85							 * 1 spare region */
86	RF_StripeCount_t TablesPerSpareRegion;	/* # of tables */
87	RF_SectorCount_t SpareSpaceDepthPerRegionInSUs;	/* spare
88							 * space/disk/region */
89	RF_SectorCount_t SpareRegionDepthInSUs;	/* # of units/disk/region */
90	RF_SectorNum_t DiskOffsetOfLastSpareSpaceChunkInSUs;	/* locates sp space
91								 * after partial ft */
92	RF_StripeCount_t TotSparePUsPerDisk;	/* total number of spare PUs
93						 * per disk */
94	RF_StripeCount_t NumCompleteSRs;
95	RF_SpareTableEntry_t **SpareTable;	/* remap table for spare space */
96	char    sparemap_fname[RF_SPAREMAP_NAME_LEN];	/* where to find
97							 * sparemap. not used in
98							 * kernel */
99};
100
101int
102rf_ConfigureDeclustered(RF_ShutdownList_t ** listp, RF_Raid_t * raidPtr,
103    RF_Config_t * cfgPtr);
104int
105rf_ConfigureDeclusteredDS(RF_ShutdownList_t ** listp, RF_Raid_t * raidPtr,
106    RF_Config_t * cfgPtr);
107
108void
109rf_MapSectorDeclustered(RF_Raid_t * raidPtr, RF_RaidAddr_t raidSector,
110    RF_RowCol_t * row, RF_RowCol_t * col, RF_SectorNum_t * diskSector, int remap);
111void
112rf_MapParityDeclustered(RF_Raid_t * raidPtr, RF_RaidAddr_t raidSector,
113    RF_RowCol_t * row, RF_RowCol_t * col, RF_SectorNum_t * diskSector, int remap);
114void
115rf_IdentifyStripeDeclustered(RF_Raid_t * raidPtr, RF_RaidAddr_t addr,
116    RF_RowCol_t ** diskids, RF_RowCol_t * outRow);
117void
118rf_MapSIDToPSIDDeclustered(RF_RaidLayout_t * layoutPtr,
119    RF_StripeNum_t stripeID, RF_StripeNum_t * psID,
120    RF_ReconUnitNum_t * which_ru);
121int     rf_InstallSpareTable(RF_Raid_t * raidPtr, RF_RowCol_t frow, RF_RowCol_t fcol);
122void    rf_FreeSpareTable(RF_Raid_t * raidPtr);
123
124RF_HeadSepLimit_t rf_GetDefaultHeadSepLimitDeclustered(RF_Raid_t * raidPtr);
125int     rf_GetDefaultNumFloatingReconBuffersDeclustered(RF_Raid_t * raidPtr);
126
127void
128rf_decluster_adjust_params(RF_RaidLayout_t * layoutPtr,
129    RF_StripeNum_t * SUID, RF_StripeCount_t * sus_per_fulltable,
130    RF_StripeCount_t * fulltable_depth, RF_StripeNum_t * base_suid);
131void
132rf_remap_to_spare_space(
133    RF_RaidLayout_t * layoutPtr,
134    RF_DeclusteredConfigInfo_t * info, RF_RowCol_t row, RF_StripeNum_t FullTableID,
135    RF_StripeNum_t TableID, RF_SectorNum_t BlockID, RF_StripeNum_t base_suid,
136    RF_StripeNum_t SpareRegion, RF_RowCol_t * outCol, RF_StripeNum_t * outSU);
137int     rf_SetSpareTable(RF_Raid_t * raidPtr, void *data);
138RF_ReconUnitCount_t rf_GetNumSpareRUsDeclustered(RF_Raid_t * raidPtr);
139
140#endif				/* !_RF__RF_DECLUSTER_H_ */
141