rf_raid.h revision 1.2 1 /* $NetBSD: rf_raid.h,v 1.2 1999/01/26 02:34:00 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 (at) 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 * rf_raid.h -- main header file for RAID driver
31 **********************************************/
32
33
34 #ifndef _RF__RF_RAID_H_
35 #define _RF__RF_RAID_H_
36
37 #include "rf_archs.h"
38 #include "rf_types.h"
39 #include "rf_threadstuff.h"
40
41 #include "rf_netbsd.h"
42
43 #include <sys/disklabel.h>
44 #include <sys/types.h>
45
46 #include "rf_alloclist.h"
47 #include "rf_stripelocks.h"
48 #include "rf_layout.h"
49 #include "rf_disks.h"
50 #include "rf_debugMem.h"
51 #include "rf_diskqueue.h"
52 #include "rf_reconstruct.h"
53 #include "rf_acctrace.h"
54
55 #if RF_INCLUDE_PARITYLOGGING > 0
56 #include "rf_paritylog.h"
57 #endif /* RF_INCLUDE_PARITYLOGGING > 0 */
58
59 #define RF_MAX_DISKS 128 /* max disks per array */
60 #define RF_DEV2RAIDID(_dev) (DISKUNIT(_dev))
61
62 /*
63 * Each row in the array is a distinct parity group, so
64 * each has it's own status, which is one of the following.
65 */
66 typedef enum RF_RowStatus_e {
67 rf_rs_optimal,
68 rf_rs_degraded,
69 rf_rs_reconstructing,
70 rf_rs_reconfigured
71 } RF_RowStatus_t;
72
73 struct RF_CumulativeStats_s {
74 struct timeval start; /* the time when the stats were last started*/
75 struct timeval stop; /* the time when the stats were last stopped */
76 long sum_io_us; /* sum of all user response times (us) */
77 long num_ios; /* total number of I/Os serviced */
78 long num_sect_moved; /* total number of sectors read or written */
79 };
80
81 struct RF_ThroughputStats_s {
82 RF_DECLARE_MUTEX(mutex)/* a mutex used to lock the configuration stuff */
83 struct timeval start; /* timer started when numOutstandingRequests moves from 0 to 1 */
84 struct timeval stop; /* timer stopped when numOutstandingRequests moves from 1 to 0 */
85 RF_uint64 sum_io_us; /* total time timer is enabled */
86 RF_uint64 num_ios; /* total number of ios processed by RAIDframe */
87 long num_out_ios; /* number of outstanding ios */
88 };
89
90 struct RF_Raid_s {
91 /* This portion never changes, and can be accessed without locking */
92 /* an exception is Disks[][].status, which requires locking when it is changed */
93 u_int numRow; /* number of rows of disks, typically == # of ranks */
94 u_int numCol; /* number of columns of disks, typically == # of disks/rank */
95 u_int numSpare; /* number of spare disks */
96 int maxQueueDepth; /* max disk queue depth */
97 RF_SectorCount_t totalSectors; /* total number of sectors in the array */
98 RF_SectorCount_t sectorsPerDisk; /* number of sectors on each disk */
99 u_int logBytesPerSector; /* base-2 log of the number of bytes in a sector */
100 u_int bytesPerSector; /* bytes in a sector */
101 RF_int32 sectorMask; /* mask of bytes-per-sector */
102
103 RF_RaidLayout_t Layout; /* all information related to layout */
104 RF_RaidDisk_t **Disks; /* all information related to physical disks */
105 RF_DiskQueue_t **Queues; /* all information related to disk queues */
106 /* NOTE: This is an anchor point via which the queues can be accessed,
107 * but the enqueue/dequeue routines in diskqueue.c use a local copy of
108 * this pointer for the actual accesses.
109 */
110 /* The remainder of the structure can change, and therefore requires locking on reads and updates */
111 RF_DECLARE_MUTEX(mutex) /* mutex used to serialize access to the fields below */
112 RF_RowStatus_t *status; /* the status of each row in the array */
113 int valid; /* indicates successful configuration */
114 RF_LockTableEntry_t *lockTable; /* stripe-lock table */
115 RF_LockTableEntry_t *quiesceLock; /* quiesnce table */
116 int numFailures; /* total number of failures in the array */
117
118 /*
119 * Cleanup stuff
120 */
121 RF_ShutdownList_t *shutdownList; /* shutdown activities */
122 RF_AllocListElem_t *cleanupList; /* memory to be freed at shutdown time */
123
124 /*
125 * Recon stuff
126 */
127 RF_HeadSepLimit_t headSepLimit;
128 int numFloatingReconBufs;
129 int reconInProgress;
130 RF_DECLARE_COND(waitForReconCond)
131 RF_RaidReconDesc_t *reconDesc; /* reconstruction descriptor */
132 RF_ReconCtrl_t **reconControl; /* reconstruction control structure pointers for each row in the array */
133
134 /*
135 * Array-quiescence stuff
136 */
137 RF_DECLARE_MUTEX(access_suspend_mutex)
138 RF_DECLARE_COND(quiescent_cond)
139 RF_IoCount_t accesses_suspended;
140 RF_IoCount_t accs_in_flight;
141 int access_suspend_release;
142 int waiting_for_quiescence;
143 RF_CallbackDesc_t *quiesce_wait_list;
144
145 /*
146 * Statistics
147 */
148 #if !defined(_KERNEL) && !defined(SIMULATE)
149 RF_ThroughputStats_t throughputstats;
150 #endif /* !KERNEL && !SIMULATE */
151 RF_CumulativeStats_t userstats;
152
153 /*
154 * Engine thread control
155 */
156 RF_DECLARE_MUTEX(node_queue_mutex)
157 RF_DECLARE_COND(node_queue_cond)
158 RF_DagNode_t *node_queue;
159 RF_Thread_t engine_thread;
160 RF_ThreadGroup_t engine_tg;
161 int shutdown_engine;
162 int dags_in_flight; /* debug */
163
164 /*
165 * PSS (Parity Stripe Status) stuff
166 */
167 RF_FreeList_t *pss_freelist;
168 long pssTableSize;
169
170 /*
171 * Reconstruction stuff
172 */
173 int procsInBufWait;
174 int numFullReconBuffers;
175 RF_AccTraceEntry_t *recon_tracerecs;
176 unsigned long accumXorTimeUs;
177 RF_ReconDoneProc_t *recon_done_procs;
178 RF_DECLARE_MUTEX(recon_done_proc_mutex)
179
180 /*
181 * nAccOutstanding, waitShutdown protected by desc freelist lock
182 * (This may seem strange, since that's a central serialization point
183 * for a per-array piece of data, but otherwise, it'd be an extra
184 * per-array lock, and that'd only be less efficient...)
185 */
186 RF_DECLARE_COND(outstandingCond)
187 int waitShutdown;
188 int nAccOutstanding;
189
190 RF_DiskId_t **diskids;
191 RF_DiskId_t *sparediskids;
192
193 int raidid;
194 RF_AccTotals_t acc_totals;
195 int keep_acc_totals;
196
197 struct raidcinfo **raid_cinfo; /* array of component info */
198 struct proc *proc; /* XXX shouldn't be needed here.. :-p */
199
200 int terminate_disk_queues;
201
202 /*
203 * XXX
204 *
205 * config-specific information should be moved
206 * somewhere else, or at least hung off this
207 * in some generic way
208 */
209
210 /* used by rf_compute_workload_shift */
211 RF_RowCol_t hist_diskreq[RF_MAXROW][RF_MAXCOL];
212
213 /* used by declustering */
214 int noRotate;
215
216 #if RF_INCLUDE_PARITYLOGGING > 0
217 /* used by parity logging */
218 RF_SectorCount_t regionLogCapacity;
219 RF_ParityLogQueue_t parityLogPool; /* pool of unused parity logs */
220 RF_RegionInfo_t *regionInfo; /* array of region state */
221 int numParityLogs;
222 int numSectorsPerLog;
223 int regionParityRange;
224 int logsInUse; /* debugging */
225 RF_ParityLogDiskQueue_t parityLogDiskQueue; /* state of parity logging disk work */
226 RF_RegionBufferQueue_t regionBufferPool; /* buffers for holding region log */
227 RF_RegionBufferQueue_t parityBufferPool; /* buffers for holding parity */
228 caddr_t parityLogBufferHeap; /* pool of unused parity logs */
229 RF_Thread_t pLogDiskThreadHandle;
230
231 #endif /* RF_INCLUDE_PARITYLOGGING > 0 */
232 };
233
234 #endif /* !_RF__RF_RAID_H_ */
235