Blame view

drivers/md/raid5.h 19.9 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
2
  #ifndef _RAID5_H
  #define _RAID5_H
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
3
  #include <linux/raid/xor.h>
ad283ea4a   Dan Williams   async_tx: add sum...
4
  #include <linux/dmaengine.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
5
6
7
  
  /*
   *
c4c1663be   NeilBrown   md/raid5: replace...
8
   * Each stripe contains one buffer per device.  Each buffer can be in
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
9
   * one of a number of states stored in "flags".  Changes between
c4c1663be   NeilBrown   md/raid5: replace...
10
11
12
   * these states happen *almost* exclusively under the protection of the
   * STRIPE_ACTIVE flag.  Some very specific changes can happen in bi_end_io, and
   * these are not protected by STRIPE_ACTIVE.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
   *
   * The flag bits that are used to represent these states are:
   *   R5_UPTODATE and R5_LOCKED
   *
   * State Empty == !UPTODATE, !LOCK
   *        We have no data, and there is no active request
   * State Want == !UPTODATE, LOCK
   *        A read request is being submitted for this block
   * State Dirty == UPTODATE, LOCK
   *        Some new data is in this buffer, and it is being written out
   * State Clean == UPTODATE, !LOCK
   *        We have valid data which is the same as on disc
   *
   * The possible state transitions are:
   *
   *  Empty -> Want   - on read or write to get old data for  parity calc
ede7ee8b4   NeilBrown   md/raid5: raid5.h...
29
   *  Empty -> Dirty  - on compute_parity to satisfy write/sync request.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
   *  Empty -> Clean  - on compute_block when computing a block for failed drive
   *  Want  -> Empty  - on failed read
   *  Want  -> Clean  - on successful completion of read request
   *  Dirty -> Clean  - on successful completion of write request
   *  Dirty -> Clean  - on failed write
   *  Clean -> Dirty  - on compute_parity to satisfy write/sync (RECONSTRUCT or RMW)
   *
   * The Want->Empty, Want->Clean, Dirty->Clean, transitions
   * all happen in b_end_io at interrupt time.
   * Each sets the Uptodate bit before releasing the Lock bit.
   * This leaves one multi-stage transition:
   *    Want->Dirty->Clean
   * This is safe because thinking that a Clean buffer is actually dirty
   * will at worst delay some action, and the stripe will be scheduled
   * for attention after the transition is complete.
   *
   * There is one possibility that is not covered by these states.  That
   * is if one drive has failed and there is a spare being rebuilt.  We
   * can't distinguish between a clean block that has been generated
   * from parity calculations, and a clean block that has been
   * successfully written to the spare ( or to parity when resyncing).
   * To distingush these states we have a stripe bit STRIPE_INSYNC that
   * is set whenever a write is scheduled to the spare, or to the parity
   * disc if there is no spare.  A sync request clears this bit, and
   * when we find it set with no buffers locked, we know the sync is
   * complete.
   *
   * Buffers for the md device that arrive via make_request are attached
   * to the appropriate stripe in one of two lists linked on b_reqnext.
   * One list (bh_read) for read requests, one (bh_write) for write.
   * There should never be more than one buffer on the two lists
   * together, but we are not guaranteed of that so we allow for more.
   *
   * If a buffer is on the read list when the associated cache buffer is
   * Uptodate, the data is copied into the read buffer and it's b_end_io
   * routine is called.  This may happen in the end_request routine only
   * if the buffer has just successfully been read.  end_request should
   * remove the buffers from the list and then set the Uptodate bit on
   * the buffer.  Other threads may do this only if they first check
   * that the Uptodate bit is set.  Once they have checked that they may
   * take buffers off the read queue.
   *
   * When a buffer on the write list is committed for write it is copied
   * into the cache buffer, which is then marked dirty, and moved onto a
   * third list, the written list (bh_written).  Once both the parity
   * block and the cached buffer are successfully written, any buffer on
   * a written list can be returned with b_end_io.
   *
c4c1663be   NeilBrown   md/raid5: replace...
78
79
80
81
   * The write list and read list both act as fifos.  The read list,
   * write list and written list are protected by the device_lock.
   * The device_lock is only for list manipulations and will only be
   * held for a very short time.  It can be claimed from interrupts.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
82
83
84
85
86
87
88
89
90
91
92
93
94
95
   *
   *
   * Stripes in the stripe cache can be on one of two lists (or on
   * neither).  The "inactive_list" contains stripes which are not
   * currently being used for any request.  They can freely be reused
   * for another stripe.  The "handle_list" contains stripes that need
   * to be handled in some way.  Both of these are fifo queues.  Each
   * stripe is also (potentially) linked to a hash bucket in the hash
   * table so that it can be found by sector number.  Stripes that are
   * not hashed must be on the inactive_list, and will normally be at
   * the front.  All stripes start life this way.
   *
   * The inactive_list, handle_list and hash bucket lists are all protected by the
   * device_lock.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
   *  - stripes have a reference counter. If count==0, they are on a list.
   *  - If a stripe might need handling, STRIPE_HANDLE is set.
   *  - When refcount reaches zero, then if STRIPE_HANDLE it is put on
   *    handle_list else inactive_list
   *
   * This, combined with the fact that STRIPE_HANDLE is only ever
   * cleared while a stripe has a non-zero count means that if the
   * refcount is 0 and STRIPE_HANDLE is set, then it is on the
   * handle_list and if recount is 0 and STRIPE_HANDLE is not set, then
   * the stripe is on inactive_list.
   *
   * The possible transitions are:
   *  activate an unhashed/inactive stripe (get_active_stripe())
   *     lockdev check-hash unlink-stripe cnt++ clean-stripe hash-stripe unlockdev
   *  activate a hashed, possibly active stripe (get_active_stripe())
   *     lockdev check-hash if(!cnt++)unlink-stripe unlockdev
   *  attach a request to an active stripe (add_stripe_bh())
   *     lockdev attach-buffer unlockdev
   *  handle a stripe (handle_stripe())
c4c1663be   NeilBrown   md/raid5: replace...
115
   *     setSTRIPE_ACTIVE,  clrSTRIPE_HANDLE ...
91c009248   Dan Williams   md: raid5_run_ops...
116
117
   *		(lockdev check-buffers unlockdev) ..
   *		change-state ..
c4c1663be   NeilBrown   md/raid5: replace...
118
   *		record io/ops needed clearSTRIPE_ACTIVE schedule io/ops
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
119
120
121
122
123
   *  release an active stripe (release_stripe())
   *     lockdev if (!--cnt) { if  STRIPE_HANDLE, add to handle_list else add to inactive-list } unlockdev
   *
   * The refcount counts each thread that have activated the stripe,
   * plus raid5d if it is handling it, plus one for each active request
91c009248   Dan Williams   md: raid5_run_ops...
124
125
126
   * on a cached buffer, and plus one if the stripe is undergoing stripe
   * operations.
   *
c4c1663be   NeilBrown   md/raid5: replace...
127
   * The stripe operations are:
91c009248   Dan Williams   md: raid5_run_ops...
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
   * -copying data between the stripe cache and user application buffers
   * -computing blocks to save a disk access, or to recover a missing block
   * -updating the parity on a write operation (reconstruct write and
   *  read-modify-write)
   * -checking parity correctness
   * -running i/o to disk
   * These operations are carried out by raid5_run_ops which uses the async_tx
   * api to (optionally) offload operations to dedicated hardware engines.
   * When requesting an operation handle_stripe sets the pending bit for the
   * operation and increments the count.  raid5_run_ops is then run whenever
   * the count is non-zero.
   * There are some critical dependencies between the operations that prevent some
   * from being requested while another is in flight.
   * 1/ Parity check operations destroy the in cache version of the parity block,
   *    so we prevent parity dependent operations like writes and compute_blocks
   *    from starting while a check is in progress.  Some dma engines can perform
   *    the check without damaging the parity block, in these cases the parity
   *    block is re-marked up to date (assuming the check was successful) and is
   *    not re-read from disk.
   * 2/ When a write operation is requested we immediately lock the affected
   *    blocks, and mark them as not up to date.  This causes new read requests
   *    to be held off, as well as parity checks and compute block operations.
   * 3/ Once a compute block operation has been requested handle_stripe treats
   *    that block as if it is up to date.  raid5_run_ops guaruntees that any
   *    operation that is dependent on the compute block result is initiated after
   *    the compute block completes.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
154
   */
ecc65c9b3   Dan Williams   md: replace STRIP...
155
  /*
c4c1663be   NeilBrown   md/raid5: replace...
156
157
   * Operations state - intermediate states that are visible outside of 
   *   STRIPE_ACTIVE.
ecc65c9b3   Dan Williams   md: replace STRIP...
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
   * In general _idle indicates nothing is running, _run indicates a data
   * processing operation is active, and _result means the data processing result
   * is stable and can be acted upon.  For simple operations like biofill and
   * compute that only have an _idle and _run state they are indicated with
   * sh->state flags (STRIPE_BIOFILL_RUN and STRIPE_COMPUTE_RUN)
   */
  /**
   * enum check_states - handles syncing / repairing a stripe
   * @check_state_idle - check operations are quiesced
   * @check_state_run - check operation is running
   * @check_state_result - set outside lock when check result is valid
   * @check_state_compute_run - check failed and we are repairing
   * @check_state_compute_result - set outside lock when compute result is valid
   */
  enum check_states {
  	check_state_idle = 0,
ac6b53b6e   Dan Williams   md/raid6: asynchr...
174
175
176
  	check_state_run, /* xor parity check */
  	check_state_run_q, /* q-parity check */
  	check_state_run_pq, /* pq dual parity check */
ecc65c9b3   Dan Williams   md: replace STRIP...
177
178
179
180
181
182
183
184
185
186
  	check_state_check_result,
  	check_state_compute_run, /* parity repair */
  	check_state_compute_result,
  };
  
  /**
   * enum reconstruct_states - handles writing or expanding a stripe
   */
  enum reconstruct_states {
  	reconstruct_state_idle = 0,
d8ee0728b   Dan Williams   md: replace R5_Wa...
187
  	reconstruct_state_prexor_drain_run,	/* prexor-write */
ecc65c9b3   Dan Williams   md: replace STRIP...
188
189
  	reconstruct_state_drain_run,		/* write */
  	reconstruct_state_run,			/* expand */
d8ee0728b   Dan Williams   md: replace R5_Wa...
190
  	reconstruct_state_prexor_drain_result,
ecc65c9b3   Dan Williams   md: replace STRIP...
191
192
193
  	reconstruct_state_drain_result,
  	reconstruct_state_result,
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
194
  struct stripe_head {
fccddba06   NeilBrown   [PATCH] md: tidy ...
195
  	struct hlist_node	hash;
d0dabf7e5   NeilBrown   md/raid6: remove ...
196
  	struct list_head	lru;	      /* inactive_list or handle_list */
d1688a6d5   NeilBrown   md/raid5: typedef...
197
  	struct r5conf		*raid_conf;
86b42c713   NeilBrown   md/raid5: clearly...
198
199
  	short			generation;	/* increments with every
  						 * reshape */
d0dabf7e5   NeilBrown   md/raid6: remove ...
200
201
202
  	sector_t		sector;		/* sector of this row */
  	short			pd_idx;		/* parity disk index */
  	short			qd_idx;		/* 'Q' disk index for raid6 */
67cc2b816   NeilBrown   md/raid5: finish ...
203
  	short			ddf_layout;/* use DDF ordering to calculate Q */
d0dabf7e5   NeilBrown   md/raid6: remove ...
204
205
  	unsigned long		state;		/* state flags */
  	atomic_t		count;	      /* nr of active thread/requests */
72626685d   NeilBrown   [PATCH] md: add w...
206
  	int			bm_seq;	/* sequence number for bitmap flushes */
d0dabf7e5   NeilBrown   md/raid6: remove ...
207
  	int			disks;		/* disks in stripe */
ecc65c9b3   Dan Williams   md: replace STRIP...
208
  	enum check_states	check_state;
600aa1099   Dan Williams   md: replace STRIP...
209
  	enum reconstruct_states reconstruct_state;
417b8d4ac   Dan Williams   md/raid456: downl...
210
211
  	/**
  	 * struct stripe_operations
91c009248   Dan Williams   md: raid5_run_ops...
212
  	 * @target - STRIPE_OP_COMPUTE_BLK target
417b8d4ac   Dan Williams   md/raid456: downl...
213
214
215
  	 * @target2 - 2nd compute target in the raid6 case
  	 * @zero_sum_result - P and Q verification flags
  	 * @request - async service request flags for raid_run_ops
91c009248   Dan Williams   md: raid5_run_ops...
216
217
  	 */
  	struct stripe_operations {
ac6b53b6e   Dan Williams   md/raid6: asynchr...
218
  		int 		     target, target2;
ad283ea4a   Dan Williams   async_tx: add sum...
219
  		enum sum_check_flags zero_sum_result;
417b8d4ac   Dan Williams   md/raid456: downl...
220
221
222
223
  		#ifdef CONFIG_MULTICORE_RAID456
  		unsigned long	     request;
  		wait_queue_head_t    wait_for_ops;
  		#endif
91c009248   Dan Williams   md: raid5_run_ops...
224
  	} ops;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
225
  	struct r5dev {
671488cc2   NeilBrown   md/raid5: allow e...
226
227
228
229
230
  		/* rreq and rvec are used for the replacement device when
  		 * writing data to both devices.
  		 */
  		struct bio	req, rreq;
  		struct bio_vec	vec, rvec;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
231
  		struct page	*page;
91c009248   Dan Williams   md: raid5_run_ops...
232
  		struct bio	*toread, *read, *towrite, *written;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
233
234
235
236
  		sector_t	sector;			/* sector of this page */
  		unsigned long	flags;
  	} dev[1]; /* allocated with extra space depending of RAID geometry */
  };
a44568564   Dan Williams   raid5: refactor h...
237
238
  
  /* stripe_head_state - collects and tracks the dynamic state of a stripe_head
c4c1663be   NeilBrown   md/raid5: replace...
239
   *     for handle_stripe.
a44568564   Dan Williams   raid5: refactor h...
240
241
   */
  struct stripe_head_state {
9a3e1101b   NeilBrown   md/raid5: detect...
242
243
244
245
246
247
248
  	/* 'syncing' means that we need to read all devices, either
  	 * to check/correct parity, or to reconstruct a missing device.
  	 * 'replacing' means we are replacing one or more drives and
  	 * the source is valid at this point so we don't need to
  	 * read all devices, just the replacement targets.
  	 */
  	int syncing, expanding, expanded, replacing;
a44568564   Dan Williams   raid5: refactor h...
249
  	int locked, uptodate, to_read, to_write, failed, written;
b5e98d65d   Dan Williams   md: handle_stripe...
250
  	int to_fill, compute, req_compute, non_overwrite;
f2b3b44de   NeilBrown   md/raid5: unify s...
251
  	int failed_num[2];
f2b3b44de   NeilBrown   md/raid5: unify s...
252
  	int p_failed, q_failed;
c5709ef6a   NeilBrown   md/raid5: add so...
253
254
255
256
  	int dec_preread_active;
  	unsigned long ops_request;
  
  	struct bio *return_bi;
3cb030020   NeilBrown   md: removing type...
257
  	struct md_rdev *blocked_rdev;
bc2607f39   NeilBrown   md/raid5: write e...
258
  	int handle_bad_blocks;
a44568564   Dan Williams   raid5: refactor h...
259
  };
671488cc2   NeilBrown   md/raid5: allow e...
260
261
262
263
  /* Flags for struct r5dev.flags */
  enum r5dev_flags {
  	R5_UPTODATE,	/* page contains current data */
  	R5_LOCKED,	/* IO has been submitted on "req" */
977df3625   NeilBrown   md/raid5: writes ...
264
  	R5_DOUBLE_LOCKED,/* Cannot clear R5_LOCKED until 2 writes complete */
671488cc2   NeilBrown   md/raid5: allow e...
265
  	R5_OVERWRITE,	/* towrite covers whole page */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
266
  /* and some that are internal to handle_stripe */
671488cc2   NeilBrown   md/raid5: allow e...
267
268
269
270
271
272
273
  	R5_Insync,	/* rdev && rdev->in_sync at start */
  	R5_Wantread,	/* want to schedule a read */
  	R5_Wantwrite,
  	R5_Overlap,	/* There is a pending overlapping request
  			 * on this block */
  	R5_ReadError,	/* seen a read error here recently */
  	R5_ReWrite,	/* have tried to over-write the readerror */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
274

671488cc2   NeilBrown   md/raid5: allow e...
275
276
277
278
279
280
281
282
283
284
285
286
287
288
  	R5_Expanded,	/* This block now has post-expand data */
  	R5_Wantcompute,	/* compute_block in progress treat as
  			 * uptodate
  			 */
  	R5_Wantfill,	/* dev->toread contains a bio that needs
  			 * filling
  			 */
  	R5_Wantdrain,	/* dev->towrite needs to be drained */
  	R5_WantFUA,	/* Write should be FUA */
  	R5_WriteError,	/* got a write error - need to record it */
  	R5_MadeGood,	/* A bad block has been fixed by writing to it */
  	R5_ReadRepl,	/* Will/did read from replacement rather than orig */
  	R5_MadeGoodRepl,/* A bad block on the replacement device has been
  			 * fixed by writing to it */
9a3e1101b   NeilBrown   md/raid5: detect...
289
290
291
292
293
  	R5_NeedReplace,	/* This device has a replacement which is not
  			 * up-to-date at this stripe. */
  	R5_WantReplace, /* We need to update the replacement, we have read
  			 * data in, and now is a good time to write it out.
  			 */
671488cc2   NeilBrown   md/raid5: allow e...
294
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
295
296
297
298
  
  /*
   * Stripe state
   */
83206d66b   NeilBrown   md/raid5: Remove ...
299
  enum {
c4c1663be   NeilBrown   md/raid5: replace...
300
  	STRIPE_ACTIVE,
83206d66b   NeilBrown   md/raid5: Remove ...
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
  	STRIPE_HANDLE,
  	STRIPE_SYNC_REQUESTED,
  	STRIPE_SYNCING,
  	STRIPE_INSYNC,
  	STRIPE_PREREAD_ACTIVE,
  	STRIPE_DELAYED,
  	STRIPE_DEGRADED,
  	STRIPE_BIT_DELAY,
  	STRIPE_EXPANDING,
  	STRIPE_EXPAND_SOURCE,
  	STRIPE_EXPAND_READY,
  	STRIPE_IO_STARTED,	/* do not count towards 'bypass_count' */
  	STRIPE_FULL_WRITE,	/* all blocks are set to be overwritten */
  	STRIPE_BIOFILL_RUN,
  	STRIPE_COMPUTE_RUN,
  	STRIPE_OPS_REQ_PENDING,
  };
417b8d4ac   Dan Williams   md/raid456: downl...
318

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
319
  /*
ecc65c9b3   Dan Williams   md: replace STRIP...
320
   * Operation request flags
91c009248   Dan Williams   md: raid5_run_ops...
321
   */
ede7ee8b4   NeilBrown   md/raid5: raid5.h...
322
323
324
325
326
327
328
329
  enum {
  	STRIPE_OP_BIOFILL,
  	STRIPE_OP_COMPUTE_BLK,
  	STRIPE_OP_PREXOR,
  	STRIPE_OP_BIODRAIN,
  	STRIPE_OP_RECONSTRUCT,
  	STRIPE_OP_CHECK,
  };
91c009248   Dan Williams   md: raid5_run_ops...
330
  /*
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
   * Plugging:
   *
   * To improve write throughput, we need to delay the handling of some
   * stripes until there has been a chance that several write requests
   * for the one stripe have all been collected.
   * In particular, any write request that would require pre-reading
   * is put on a "delayed" queue until there are no stripes currently
   * in a pre-read phase.  Further, if the "delayed" queue is empty when
   * a stripe is put on it then we "plug" the queue and do not process it
   * until an unplug call is made. (the unplug_io_fn() is called).
   *
   * When preread is initiated on a stripe, we set PREREAD_ACTIVE and add
   * it to the count of prereading stripes.
   * When write is initiated, or the stripe refcnt == 0 (just in case) we
   * clear the PREREAD_ACTIVE flag and decrement the count
b5c124af6   NeilBrown   [PATCH] md: fix a...
346
347
348
   * Whenever the 'handle' queue is empty and the device is not plugged, we
   * move any strips from delayed to handle and clear the DELAYED flag and set
   * PREREAD_ACTIVE.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
349
350
   * In stripe_handle, if we find pre-reading is necessary, we do it if
   * PREREAD_ACTIVE is set, else we set DELAYED which will send it to the delayed queue.
c4c1663be   NeilBrown   md/raid5: replace...
351
   * HANDLE gets cleared if stripe_handle leaves nothing locked.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
352
   */
ef740c372   Christoph Hellwig   md: move headers ...
353

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
354
355
  
  struct disk_info {
671488cc2   NeilBrown   md/raid5: allow e...
356
  	struct md_rdev	*rdev, *replacement;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
357
  };
d1688a6d5   NeilBrown   md/raid5: typedef...
358
  struct r5conf {
fccddba06   NeilBrown   [PATCH] md: tidy ...
359
  	struct hlist_head	*stripe_hashtbl;
fd01b88c7   NeilBrown   md: remove typede...
360
  	struct mddev		*mddev;
09c9e5fa1   Andre Noll   md: convert conf-...
361
362
  	int			chunk_sectors;
  	int			level, algorithm;
16a53ecc3   NeilBrown   [PATCH] md: merge...
363
  	int			max_degraded;
02c2de8cc   NeilBrown   [PATCH] md: remov...
364
  	int			raid_disks;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
365
  	int			max_nr_stripes;
fef9c61fd   NeilBrown   md/raid5: change ...
366
367
368
369
370
371
372
373
374
375
  	/* reshape_progress is the leading edge of a 'reshape'
  	 * It has value MaxSector when no reshape is happening
  	 * If delta_disks < 0, it is the last sector we started work on,
  	 * else is it the next sector to work on.
  	 */
  	sector_t		reshape_progress;
  	/* reshape_safe is the trailing edge of a reshape.  We know that
  	 * before (or after) this address, all reshape has completed.
  	 */
  	sector_t		reshape_safe;
7ecaa1e6a   NeilBrown   [PATCH] md: Infra...
376
  	int			previous_raid_disks;
09c9e5fa1   Andre Noll   md: convert conf-...
377
378
  	int			prev_chunk_sectors;
  	int			prev_algo;
86b42c713   NeilBrown   md/raid5: clearly...
379
  	short			generation; /* increments with every reshape */
c8f517c44   NeilBrown   md/raid5 revise r...
380
381
  	unsigned long		reshape_checkpoint; /* Time we last updated
  						     * metadata */
7ecaa1e6a   NeilBrown   [PATCH] md: Infra...
382

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
383
  	struct list_head	handle_list; /* stripes needing handling */
8b3e6cdc5   Dan Williams   md: introduce get...
384
  	struct list_head	hold_list; /* preread ready stripes */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
385
  	struct list_head	delayed_list; /* stripes that have plugged requests */
72626685d   NeilBrown   [PATCH] md: add w...
386
  	struct list_head	bitmap_list; /* stripes delaying awaiting bitmap update */
46031f9a3   Raz Ben-Jehuda(caro)   [PATCH] md: allow...
387
388
  	struct bio		*retry_read_aligned; /* currently retrying aligned bios   */
  	struct bio		*retry_read_aligned_list; /* aligned bios retry list  */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
389
  	atomic_t		preread_active_stripes; /* stripes with scheduled io */
46031f9a3   Raz Ben-Jehuda(caro)   [PATCH] md: allow...
390
  	atomic_t		active_aligned_reads;
8b3e6cdc5   Dan Williams   md: introduce get...
391
392
393
394
  	atomic_t		pending_full_writes; /* full write backlog */
  	int			bypass_count; /* bypassed prereads */
  	int			bypass_threshold; /* preread nice */
  	struct list_head	*last_hold; /* detect hold_list promotions */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
395

f67055780   NeilBrown   [PATCH] md: Check...
396
  	atomic_t		reshape_stripes; /* stripes with pending writes for reshape */
ad01c9e37   NeilBrown   [PATCH] md: Allow...
397
398
399
400
  	/* unfortunately we need two cache names as we temporarily have
  	 * two caches.
  	 */
  	int			active_name;
f4be6b43f   NeilBrown   md/raid5: ensure ...
401
  	char			cache_name[2][32];
e18b890bb   Christoph Lameter   [PATCH] slab: rem...
402
  	struct kmem_cache		*slab_cache; /* for allocating stripes */
72626685d   NeilBrown   [PATCH] md: add w...
403
404
405
406
407
408
409
410
  
  	int			seq_flush, seq_write;
  	int			quiesce;
  
  	int			fullsync;  /* set to 1 if a full sync is needed,
  					    * (fresh device added).
  					    * Cleared when a sync completes.
  					    */
7f0da59bd   NeilBrown   md/raid5: use bad...
411
  	int			recovery_disabled;
36d1c6476   Dan Williams   md/raid6: move th...
412
413
414
  	/* per cpu variables */
  	struct raid5_percpu {
  		struct page	*spare_page; /* Used when checking P/Q in raid6 */
d6f38f31f   Dan Williams   md/raid5,6: add p...
415
416
417
418
  		void		*scribble;   /* space for constructing buffer
  					      * lists and performing address
  					      * conversions
  					      */
a29d8b8e2   Tejun Heo   percpu: add __per...
419
  	} __percpu *percpu;
d6f38f31f   Dan Williams   md/raid5,6: add p...
420
421
422
423
  	size_t			scribble_len; /* size of scribble region must be
  					       * associated with conf to handle
  					       * cpu hotplug while reshaping
  					       */
36d1c6476   Dan Williams   md/raid6: move th...
424
425
426
  #ifdef CONFIG_HOTPLUG_CPU
  	struct notifier_block	cpu_notify;
  #endif
ca65b73bd   NeilBrown   [PATCH] md: fix r...
427

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
428
429
430
431
432
433
434
435
436
  	/*
  	 * Free stripes pool
  	 */
  	atomic_t		active_stripes;
  	struct list_head	inactive_list;
  	wait_queue_head_t	wait_for_stripe;
  	wait_queue_head_t	wait_for_overlap;
  	int			inactive_blocked;	/* release of inactive stripes blocked,
  							 * waiting for 25% to be free
ad01c9e37   NeilBrown   [PATCH] md: Allow...
437
438
  							 */
  	int			pool_size; /* number of disks in stripeheads in pool */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
439
  	spinlock_t		device_lock;
b55e6bfcd   NeilBrown   [PATCH] md: Split...
440
  	struct disk_info	*disks;
91adb5647   NeilBrown   md/raid5: refacto...
441
442
443
444
  
  	/* When taking over an array from a different personality, we store
  	 * the new thread here until we fully activate the array.
  	 */
2b8bf3451   NeilBrown   md: remove typede...
445
  	struct md_thread	*thread;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
446
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
447
448
449
  /*
   * Our supported algorithms
   */
99c0fb5f9   NeilBrown   md/raid5: Add sup...
450
451
452
453
  #define ALGORITHM_LEFT_ASYMMETRIC	0 /* Rotating Parity N with Data Restart */
  #define ALGORITHM_RIGHT_ASYMMETRIC	1 /* Rotating Parity 0 with Data Restart */
  #define ALGORITHM_LEFT_SYMMETRIC	2 /* Rotating Parity N with Data Continuation */
  #define ALGORITHM_RIGHT_SYMMETRIC	3 /* Rotating Parity 0 with Data Continuation */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
454

99c0fb5f9   NeilBrown   md/raid5: Add sup...
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
  /* Define non-rotating (raid4) algorithms.  These allow
   * conversion of raid4 to raid5.
   */
  #define ALGORITHM_PARITY_0		4 /* P or P,Q are initial devices */
  #define ALGORITHM_PARITY_N		5 /* P or P,Q are final devices. */
  
  /* DDF RAID6 layouts differ from md/raid6 layouts in two ways.
   * Firstly, the exact positioning of the parity block is slightly
   * different between the 'LEFT_*' modes of md and the "_N_*" modes
   * of DDF.
   * Secondly, or order of datablocks over which the Q syndrome is computed
   * is different.
   * Consequently we have different layouts for DDF/raid6 than md/raid6.
   * These layouts are from the DDFv1.2 spec.
   * Interestingly DDFv1.2-Errata-A does not specify N_CONTINUE but
   * leaves RLQ=3 as 'Vendor Specific'
   */
  
  #define ALGORITHM_ROTATING_ZERO_RESTART	8 /* DDF PRL=6 RLQ=1 */
  #define ALGORITHM_ROTATING_N_RESTART	9 /* DDF PRL=6 RLQ=2 */
  #define ALGORITHM_ROTATING_N_CONTINUE	10 /*DDF PRL=6 RLQ=3 */
  
  
  /* For every RAID5 algorithm we define a RAID6 algorithm
   * with exactly the same layout for data and parity, and
   * with the Q block always on the last device (N-1).
   * This allows trivial conversion from RAID5 to RAID6
   */
  #define ALGORITHM_LEFT_ASYMMETRIC_6	16
  #define ALGORITHM_RIGHT_ASYMMETRIC_6	17
  #define ALGORITHM_LEFT_SYMMETRIC_6	18
  #define ALGORITHM_RIGHT_SYMMETRIC_6	19
  #define ALGORITHM_PARITY_0_6		20
  #define ALGORITHM_PARITY_N_6		ALGORITHM_PARITY_N
  
  static inline int algorithm_valid_raid5(int layout)
  {
  	return (layout >= 0) &&
  		(layout <= 5);
  }
  static inline int algorithm_valid_raid6(int layout)
  {
  	return (layout >= 0 && layout <= 5)
  		||
e4424fee1   NeilBrown   md: fix problems ...
499
  		(layout >= 8 && layout <= 10)
99c0fb5f9   NeilBrown   md/raid5: Add sup...
500
501
502
503
504
505
506
507
  		||
  		(layout >= 16 && layout <= 20);
  }
  
  static inline int algorithm_is_DDF(int layout)
  {
  	return layout >= 8 && layout <= 10;
  }
11d8a6e37   NeilBrown   md/raid5: export ...
508

fd01b88c7   NeilBrown   md: remove typede...
509
  extern int md_raid5_congested(struct mddev *mddev, int bits);
d1688a6d5   NeilBrown   md/raid5: typedef...
510
  extern void md_raid5_kick_device(struct r5conf *conf);
fd01b88c7   NeilBrown   md: remove typede...
511
  extern int raid5_set_cache_size(struct mddev *mddev, int size);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
512
  #endif