]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/raidframe/rf_raid.h
This commit was generated by cvs2svn to compensate for changes in r106907,
[FreeBSD/FreeBSD.git] / sys / dev / raidframe / rf_raid.h
1 /*      $FreeBSD$ */
2 /*      $NetBSD: rf_raid.h,v 1.12 2000/02/24 17:12:10 oster Exp $       */
3 /*
4  * Copyright (c) 1995 Carnegie-Mellon University.
5  * All rights reserved.
6  *
7  * Author: Mark Holland
8  *
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.
14  *
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.
18  *
19  * Carnegie Mellon requests users of this software to return to
20  *
21  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
22  *  School of Computer Science
23  *  Carnegie Mellon University
24  *  Pittsburgh PA 15213-3890
25  *
26  * any improvements or extensions that they make and grant Carnegie the
27  * rights to redistribute these changes.
28  */
29
30 /**********************************************
31  * rf_raid.h -- main header file for RAID driver
32  **********************************************/
33
34
35 #ifndef _RF__RF_RAID_H_
36 #define _RF__RF_RAID_H_
37
38 #include <dev/raidframe/rf_archs.h>
39 #include <dev/raidframe/rf_types.h>
40 #include <dev/raidframe/rf_threadstuff.h>
41
42 #include <dev/raidframe/rf_bsd.h>
43
44 #include <sys/disklabel.h>
45 #include <sys/types.h>
46
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>
55
56 #if RF_INCLUDE_PARITYLOGGING > 0
57 #include <dev/raidframe/rf_paritylog.h>
58 #endif                          /* RF_INCLUDE_PARITYLOGGING > 0 */
59
60 #define RF_MAX_DISKS 128        /* max disks per array */
61 #if defined(__NetBSD__)
62 #define RF_DEV2RAIDID(_dev)  (DISKUNIT(_dev))
63 #endif
64
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
69
70
71 /*
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.
74  */
75 typedef enum RF_RowStatus_e {
76         rf_rs_optimal,
77         rf_rs_degraded,
78         rf_rs_reconstructing,
79         rf_rs_reconfigured
80 }       RF_RowStatus_t;
81
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 */
88 };
89
90 struct RF_ThroughputStats_s {
91         RF_DECLARE_MUTEX(mutex) /* a mutex used to lock the configuration
92                                  * stuff */
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 */
100 };
101
102 struct RF_Raid_s {
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 
106          * change now. 
107          */
108         u_int   numRow;         /* number of rows of disks, typically == # of
109                                  * ranks */
110         u_int   numCol;         /* number of columns of disks, typically == #
111                                  * of disks/rank */
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
115                                          * array */
116         RF_SectorCount_t sectorsPerDisk;        /* number of sectors on each
117                                                  * disk */
118         u_int   logBytesPerSector;      /* base-2 log of the number of bytes
119                                          * in a sector */
120         u_int   bytesPerSector; /* bytes in a sector */
121         RF_int32 sectorMask;    /* mask of bytes-per-sector */
122
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
127                                    component queues. */
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 */
142
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. */
147
148         int     openings;       /* Number of IO's which can be scheduled
149                                    simultaneously (high-level - not a 
150                                    per-component limit)*/
151
152         int maxOutstanding;   /* maxOutstanding requests (per-component) */
153         int autoconfigure;    /* automatically configure this RAID set. 
154                                  0 == no, 1 == yes */
155         int root_partition;   /* Use this set as /
156                                  0 == no, 1 == yes*/
157         int last_unit;        /* last unit number (e.g. 0 for /dev/raid0) 
158                                  of this component.  Used for autoconfigure
159                                  only. */
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. */
165
166         /*
167          * Cleanup stuff
168          */
169         RF_ShutdownList_t *shutdownList;        /* shutdown activities */
170         RF_AllocListElem_t *cleanupList;        /* memory to be freed at
171                                                  * shutdown time */
172
173         /*
174          * Recon stuff
175          */
176         RF_HeadSepLimit_t headSepLimit;
177         int     numFloatingReconBufs;
178         int     reconInProgress;
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 */
183
184         /*
185          * Array-quiescence stuff
186          */
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;
194
195         /*
196          * Statistics
197          */
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;
205
206         int     recon_in_progress;
207         int     parity_rewrite_in_progress;
208         int     copyback_in_progress;
209
210         /*
211          * Engine thread control
212          */
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;
221         int     shutdown_engine;
222         int     dags_in_flight; /* debug */
223
224         /*
225          * PSS (Parity Stripe Status) stuff
226          */
227         RF_FreeList_t *pss_freelist;
228         long    pssTableSize;
229
230         /*
231          * Reconstruction stuff
232          */
233         int     procsInBufWait;
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)
239         /*
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...)
244          */
245                 RF_DECLARE_COND(outstandingCond)
246         int     waitShutdown;
247         int     nAccOutstanding;
248
249         RF_DiskId_t **diskids;
250         RF_DiskId_t *sparediskids;
251
252         int     raidid;
253         RF_AccTotals_t acc_totals;
254         int     keep_acc_totals;
255
256         struct raidcinfo **raid_cinfo;  /* array of component info */
257
258         int     terminate_disk_queues;
259
260         /*
261          * XXX
262          *
263          * config-specific information should be moved
264          * somewhere else, or at least hung off this
265          * in some generic way
266          */
267
268         /* used by rf_compute_workload_shift */
269         RF_RowCol_t hist_diskreq[RF_MAXROW][RF_MAXCOL];
270
271         /* used by declustering */
272         int     noRotate;
273
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 */
279         int     numParityLogs;
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
286                                                          * region log */
287         RF_RegionBufferQueue_t parityBufferPool;        /* buffers for holding
288                                                          * parity */
289         caddr_t parityLogBufferHeap;    /* pool of unused parity logs */
290         RF_Thread_t pLogDiskThreadHandle;
291
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?
296          */
297         void    *sc;
298 };
299 #endif                          /* !_RF__RF_RAID_H_ */