1 /* $OpenBSD: rf_reconmap.h,v 1.3 2002/12/16 07:01:05 tdeval Exp $ */
2 /* $NetBSD: rf_reconmap.h,v 1.3 1999/02/05 00:06:16 oster Exp $ */
3
4 /*
5 * Copyright (c) 1995 Carnegie-Mellon University.
6 * All rights reserved.
7 *
8 * Author: Mark Holland
9 *
10 * Permission to use, copy, modify and distribute this software and
11 * its documentation is hereby granted, provided that both the copyright
12 * notice and this permission notice appear in all copies of the
13 * software, derivative works or modified versions, and any portions
14 * thereof, and that both notices appear in supporting documentation.
15 *
16 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
17 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
18 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
19 *
20 * Carnegie Mellon requests users of this software to return to
21 *
22 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
23 * School of Computer Science
24 * Carnegie Mellon University
25 * Pittsburgh PA 15213-3890
26 *
27 * any improvements or extensions that they make and grant Carnegie the
28 * rights to redistribute these changes.
29 */
30
31 /******************************************************************************
32 * rf_reconMap.h
33 *
34 * -- Header file describing reconstruction status data structure.
35 ******************************************************************************/
36
37 #ifndef _RF__RF_RECONMAP_H_
38 #define _RF__RF_RECONMAP_H_
39
40 #include "rf_types.h"
41 #include "rf_threadstuff.h"
42
43 /*
44 * Main reconstruction status descriptor; size and maxsize are used for
45 * monitoring only: they have no function for reconstruction.
46 */
47 struct RF_ReconMap_s {
48 RF_SectorCount_t sectorsPerReconUnit;
49 /*
50 * Sectors per reconstruct
51 * unit.
52 */
53 RF_SectorCount_t sectorsInDisk;/* Total sectors in disk. */
54 RF_SectorCount_t unitsLeft; /* Recon units left to recon. */
55 RF_ReconUnitCount_t totalRUs; /* Total recon units on disk. */
56 RF_ReconUnitCount_t spareRUs; /*
57 * Total number of spare RUs on
58 * failed disk.
59 */
60 RF_StripeCount_t totalParityStripes;
61 /*
62 * Total number of parity
63 * stripes in array.
64 */
65 u_int size; /*
66 * Overall size of this
67 * structure.
68 */
69 u_int maxSize; /* Maximum size so far. */
70 RF_ReconMapListElem_t **status; /*
71 * Array of ptrs to list
72 * elements.
73 */
74 RF_DECLARE_MUTEX (mutex);
75 };
76
77 /* A list element. */
78 struct RF_ReconMapListElem_s {
79 /* Bounding sect nums on this block. */
80 RF_SectorNum_t startSector;
81 RF_SectorNum_t stopSector;
82 RF_ReconMapListElem_t *next; /* Next element in list. */
83 };
84
85 RF_ReconMap_t *rf_MakeReconMap(RF_Raid_t *,
86 RF_SectorCount_t, RF_SectorCount_t, RF_ReconUnitCount_t);
87
88 void rf_ReconMapUpdate(RF_Raid_t *, RF_ReconMap_t *,
89 RF_SectorNum_t, RF_SectorNum_t);
90
91 void rf_FreeReconMap(RF_ReconMap_t *);
92
93 int rf_CheckRUReconstructed(RF_ReconMap_t *, RF_SectorNum_t);
94
95 RF_ReconUnitCount_t rf_UnitsLeftToReconstruct(RF_ReconMap_t *);
96
97 void rf_PrintReconMap(RF_Raid_t *, RF_ReconMap_t *, RF_RowCol_t, RF_RowCol_t);
98
99 void rf_PrintReconSchedule(RF_ReconMap_t *, struct timeval *);
100
101 #endif /* !_RF__RF_RECONMAP_H_ */