2 /* $NetBSD: rf_raid.h,v 1.12 2000/02/24 17:12:10 oster Exp $ */
4 * Copyright (c) 1995 Carnegie-Mellon University.
9 * Permission to use, copy, modify and distribute this software and
10 * its documentation is hereby granted, provided that both the copyright
11 * notice and this permission notice appear in all copies of the
12 * software, derivative works or modified versions, and any portions
13 * thereof, and that both notices appear in supporting documentation.
15 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
16 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
17 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
19 * Carnegie Mellon requests users of this software to return to
21 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
22 * School of Computer Science
23 * Carnegie Mellon University
24 * Pittsburgh PA 15213-3890
26 * any improvements or extensions that they make and grant Carnegie the
27 * rights to redistribute these changes.
30 /**********************************************
31 * rf_raid.h -- main header file for RAID driver
32 **********************************************/
35 #ifndef _RF__RF_RAID_H_
36 #define _RF__RF_RAID_H_
38 #include <dev/raidframe/rf_archs.h>
39 #include <dev/raidframe/rf_types.h>
40 #include <dev/raidframe/rf_threadstuff.h>
42 #include <dev/raidframe/rf_bsd.h>
44 #include <sys/disklabel.h>
45 #include <sys/types.h>
47 #include <dev/raidframe/rf_alloclist.h>
48 #include <dev/raidframe/rf_stripelocks.h>
49 #include <dev/raidframe/rf_layout.h>
50 #include <dev/raidframe/rf_disks.h>
51 #include <dev/raidframe/rf_debugMem.h>
52 #include <dev/raidframe/rf_diskqueue.h>
53 #include <dev/raidframe/rf_reconstruct.h>
54 #include <dev/raidframe/rf_acctrace.h>
56 #if RF_INCLUDE_PARITYLOGGING > 0
57 #include <dev/raidframe/rf_paritylog.h>
58 #endif /* RF_INCLUDE_PARITYLOGGING > 0 */
60 #define RF_MAX_DISKS 128 /* max disks per array */
61 #if defined(__NetBSD__)
62 #define RF_DEV2RAIDID(_dev) (DISKUNIT(_dev))
65 #define RF_COMPONENT_LABEL_VERSION_1 1
66 #define RF_COMPONENT_LABEL_VERSION 2
67 #define RF_RAID_DIRTY 0
68 #define RF_RAID_CLEAN 1
72 * Each row in the array is a distinct parity group, so
73 * each has it's own status, which is one of the following.
75 typedef enum RF_RowStatus_e {
82 struct RF_CumulativeStats_s {
83 struct timeval start; /* the time when the stats were last started */
84 struct timeval stop; /* the time when the stats were last stopped */
85 long sum_io_us; /* sum of all user response times (us) */
86 long num_ios; /* total number of I/Os serviced */
87 long num_sect_moved; /* total number of sectors read or written */
90 struct RF_ThroughputStats_s {
91 RF_DECLARE_MUTEX(mutex) /* a mutex used to lock the configuration
93 struct timeval start; /* timer started when numOutstandingRequests
94 * moves from 0 to 1 */
95 struct timeval stop; /* timer stopped when numOutstandingRequests
96 * moves from 1 to 0 */
97 RF_uint64 sum_io_us; /* total time timer is enabled */
98 RF_uint64 num_ios; /* total number of ios processed by RAIDframe */
99 long num_out_ios; /* number of outstanding ios */
103 /* This portion never changes, and can be accessed without locking */
104 /* an exception is Disks[][].status, which requires locking when it is
105 * changed. XXX this is no longer true. numSpare and friends can
108 u_int numRow; /* number of rows of disks, typically == # of
110 u_int numCol; /* number of columns of disks, typically == #
112 u_int numSpare; /* number of spare disks */
113 int maxQueueDepth; /* max disk queue depth */
114 RF_SectorCount_t totalSectors; /* total number of sectors in the
116 RF_SectorCount_t sectorsPerDisk; /* number of sectors on each
118 u_int logBytesPerSector; /* base-2 log of the number of bytes
120 u_int bytesPerSector; /* bytes in a sector */
121 RF_int32 sectorMask; /* mask of bytes-per-sector */
123 RF_RaidLayout_t Layout; /* all information related to layout */
124 RF_RaidDisk_t **Disks; /* all information related to physical disks */
125 RF_DiskQueue_t **Queues;/* all information related to disk queues */
126 RF_DiskQueueSW_t *qType;/* pointer to the DiskQueueSW used for the
128 /* NOTE: This is an anchor point via which the queues can be
129 * accessed, but the enqueue/dequeue routines in diskqueue.c use a
130 * local copy of this pointer for the actual accesses. */
131 /* The remainder of the structure can change, and therefore requires
132 * locking on reads and updates */
133 RF_DECLARE_MUTEX(mutex) /* mutex used to serialize access to
134 * the fields below */
135 RF_RowStatus_t *status; /* the status of each row in the array */
136 int valid; /* indicates successful configuration */
137 RF_LockTableEntry_t *lockTable; /* stripe-lock table */
138 RF_LockTableEntry_t *quiesceLock; /* quiesnce table */
139 int numFailures; /* total number of failures in the array */
140 int numNewFailures; /* number of *new* failures (that havn't
141 caused a mod_counter update */
143 int parity_good; /* !0 if parity is known to be correct */
144 int serial_number; /* a "serial number" for this set */
145 int mod_counter; /* modification counter for component labels */
146 int clean; /* the clean bit for this array. */
148 int openings; /* Number of IO's which can be scheduled
149 simultaneously (high-level - not a
150 per-component limit)*/
152 int maxOutstanding; /* maxOutstanding requests (per-component) */
153 int autoconfigure; /* automatically configure this RAID set.
155 int root_partition; /* Use this set as /
157 int last_unit; /* last unit number (e.g. 0 for /dev/raid0)
158 of this component. Used for autoconfigure
160 int config_order; /* 0 .. n. The order in which the component
161 should be auto-configured. E.g. 0 is will
162 done first, (and would become raid0).
163 This may be in conflict with last_unit!!?! */
164 /* Not currently used. */
169 RF_ShutdownList_t *shutdownList; /* shutdown activities */
170 RF_AllocListElem_t *cleanupList; /* memory to be freed at
176 RF_HeadSepLimit_t headSepLimit;
177 int numFloatingReconBufs;
179 RF_DECLARE_COND(waitForReconCond)
180 RF_RaidReconDesc_t *reconDesc; /* reconstruction descriptor */
181 RF_ReconCtrl_t **reconControl; /* reconstruction control structure
182 * pointers for each row in the array */
185 * Array-quiescence stuff
187 RF_DECLARE_MUTEX(access_suspend_mutex)
188 RF_DECLARE_COND(quiescent_cond)
189 RF_IoCount_t accesses_suspended;
190 RF_IoCount_t accs_in_flight;
191 int access_suspend_release;
192 int waiting_for_quiescence;
193 RF_CallbackDesc_t *quiesce_wait_list;
198 #if !defined(_KERNEL) && !defined(SIMULATE)
199 RF_ThroughputStats_t throughputstats;
200 #endif /* !KERNEL && !SIMULATE */
201 RF_CumulativeStats_t userstats;
202 int parity_rewrite_stripes_done;
203 int recon_stripes_done;
204 int copyback_stripes_done;
206 int recon_in_progress;
207 int parity_rewrite_in_progress;
208 int copyback_in_progress;
211 * Engine thread control
213 RF_DECLARE_MUTEX(node_queue_mutex)
214 RF_DECLARE_COND(node_queue_cond)
215 RF_DagNode_t *node_queue;
216 RF_Thread_t parity_rewrite_thread;
217 RF_Thread_t copyback_thread;
218 RF_Thread_t engine_thread;
219 RF_Thread_t recon_thread;
220 RF_ThreadGroup_t engine_tg;
222 int dags_in_flight; /* debug */
225 * PSS (Parity Stripe Status) stuff
227 RF_FreeList_t *pss_freelist;
231 * Reconstruction stuff
234 int numFullReconBuffers;
235 RF_AccTraceEntry_t *recon_tracerecs;
236 unsigned long accumXorTimeUs;
237 RF_ReconDoneProc_t *recon_done_procs;
238 RF_DECLARE_MUTEX(recon_done_proc_mutex)
240 * nAccOutstanding, waitShutdown protected by desc freelist lock
241 * (This may seem strange, since that's a central serialization point
242 * for a per-array piece of data, but otherwise, it'd be an extra
243 * per-array lock, and that'd only be less efficient...)
245 RF_DECLARE_COND(outstandingCond)
249 RF_DiskId_t **diskids;
250 RF_DiskId_t *sparediskids;
253 RF_AccTotals_t acc_totals;
256 struct raidcinfo **raid_cinfo; /* array of component info */
258 int terminate_disk_queues;
263 * config-specific information should be moved
264 * somewhere else, or at least hung off this
265 * in some generic way
268 /* used by rf_compute_workload_shift */
269 RF_RowCol_t hist_diskreq[RF_MAXROW][RF_MAXCOL];
271 /* used by declustering */
274 #if RF_INCLUDE_PARITYLOGGING > 0
275 /* used by parity logging */
276 RF_SectorCount_t regionLogCapacity;
277 RF_ParityLogQueue_t parityLogPool; /* pool of unused parity logs */
278 RF_RegionInfo_t *regionInfo; /* array of region state */
280 int numSectorsPerLog;
281 int regionParityRange;
282 int logsInUse; /* debugging */
283 RF_ParityLogDiskQueue_t parityLogDiskQueue; /* state of parity
284 * logging disk work */
285 RF_RegionBufferQueue_t regionBufferPool; /* buffers for holding
287 RF_RegionBufferQueue_t parityBufferPool; /* buffers for holding
289 caddr_t parityLogBufferHeap; /* pool of unused parity logs */
290 RF_Thread_t pLogDiskThreadHandle;
292 #endif /* RF_INCLUDE_PARITYLOGGING > 0 */
293 /* Point back to the softc for this device. This is needed to rid
294 * ourselves of the ugly static device arrays.
295 * XXX Will this affect compatibility with NetBSD?
299 #endif /* !_RF__RF_RAID_H_ */