diff options
Diffstat (limited to 'drivers/md/raid5.h')
-rw-r--r-- | drivers/md/raid5.h | 98 |
1 files changed, 55 insertions, 43 deletions
diff --git a/drivers/md/raid5.h b/drivers/md/raid5.h index e10c5531f9c5..8d8e13934a48 100644 --- a/drivers/md/raid5.h +++ b/drivers/md/raid5.h | |||
@@ -27,7 +27,7 @@ | |||
27 | * The possible state transitions are: | 27 | * The possible state transitions are: |
28 | * | 28 | * |
29 | * Empty -> Want - on read or write to get old data for parity calc | 29 | * Empty -> Want - on read or write to get old data for parity calc |
30 | * Empty -> Dirty - on compute_parity to satisfy write/sync request.(RECONSTRUCT_WRITE) | 30 | * Empty -> Dirty - on compute_parity to satisfy write/sync request. |
31 | * Empty -> Clean - on compute_block when computing a block for failed drive | 31 | * Empty -> Clean - on compute_block when computing a block for failed drive |
32 | * Want -> Empty - on failed read | 32 | * Want -> Empty - on failed read |
33 | * Want -> Clean - on successful completion of read request | 33 | * Want -> Clean - on successful completion of read request |
@@ -226,8 +226,11 @@ struct stripe_head { | |||
226 | #endif | 226 | #endif |
227 | } ops; | 227 | } ops; |
228 | struct r5dev { | 228 | struct r5dev { |
229 | struct bio req; | 229 | /* rreq and rvec are used for the replacement device when |
230 | struct bio_vec vec; | 230 | * writing data to both devices. |
231 | */ | ||
232 | struct bio req, rreq; | ||
233 | struct bio_vec vec, rvec; | ||
231 | struct page *page; | 234 | struct page *page; |
232 | struct bio *toread, *read, *towrite, *written; | 235 | struct bio *toread, *read, *towrite, *written; |
233 | sector_t sector; /* sector of this page */ | 236 | sector_t sector; /* sector of this page */ |
@@ -239,7 +242,13 @@ struct stripe_head { | |||
239 | * for handle_stripe. | 242 | * for handle_stripe. |
240 | */ | 243 | */ |
241 | struct stripe_head_state { | 244 | struct stripe_head_state { |
242 | int syncing, expanding, expanded; | 245 | /* 'syncing' means that we need to read all devices, either |
246 | * to check/correct parity, or to reconstruct a missing device. | ||
247 | * 'replacing' means we are replacing one or more drives and | ||
248 | * the source is valid at this point so we don't need to | ||
249 | * read all devices, just the replacement targets. | ||
250 | */ | ||
251 | int syncing, expanding, expanded, replacing; | ||
243 | int locked, uptodate, to_read, to_write, failed, written; | 252 | int locked, uptodate, to_read, to_write, failed, written; |
244 | int to_fill, compute, req_compute, non_overwrite; | 253 | int to_fill, compute, req_compute, non_overwrite; |
245 | int failed_num[2]; | 254 | int failed_num[2]; |
@@ -252,38 +261,41 @@ struct stripe_head_state { | |||
252 | int handle_bad_blocks; | 261 | int handle_bad_blocks; |
253 | }; | 262 | }; |
254 | 263 | ||
255 | /* Flags */ | 264 | /* Flags for struct r5dev.flags */ |
256 | #define R5_UPTODATE 0 /* page contains current data */ | 265 | enum r5dev_flags { |
257 | #define R5_LOCKED 1 /* IO has been submitted on "req" */ | 266 | R5_UPTODATE, /* page contains current data */ |
258 | #define R5_OVERWRITE 2 /* towrite covers whole page */ | 267 | R5_LOCKED, /* IO has been submitted on "req" */ |
268 | R5_DOUBLE_LOCKED,/* Cannot clear R5_LOCKED until 2 writes complete */ | ||
269 | R5_OVERWRITE, /* towrite covers whole page */ | ||
259 | /* and some that are internal to handle_stripe */ | 270 | /* and some that are internal to handle_stripe */ |
260 | #define R5_Insync 3 /* rdev && rdev->in_sync at start */ | 271 | R5_Insync, /* rdev && rdev->in_sync at start */ |
261 | #define R5_Wantread 4 /* want to schedule a read */ | 272 | R5_Wantread, /* want to schedule a read */ |
262 | #define R5_Wantwrite 5 | 273 | R5_Wantwrite, |
263 | #define R5_Overlap 7 /* There is a pending overlapping request on this block */ | 274 | R5_Overlap, /* There is a pending overlapping request |
264 | #define R5_ReadError 8 /* seen a read error here recently */ | 275 | * on this block */ |
265 | #define R5_ReWrite 9 /* have tried to over-write the readerror */ | 276 | R5_ReadError, /* seen a read error here recently */ |
277 | R5_ReWrite, /* have tried to over-write the readerror */ | ||
266 | 278 | ||
267 | #define R5_Expanded 10 /* This block now has post-expand data */ | 279 | R5_Expanded, /* This block now has post-expand data */ |
268 | #define R5_Wantcompute 11 /* compute_block in progress treat as | 280 | R5_Wantcompute, /* compute_block in progress treat as |
269 | * uptodate | 281 | * uptodate |
270 | */ | 282 | */ |
271 | #define R5_Wantfill 12 /* dev->toread contains a bio that needs | 283 | R5_Wantfill, /* dev->toread contains a bio that needs |
272 | * filling | 284 | * filling |
273 | */ | 285 | */ |
274 | #define R5_Wantdrain 13 /* dev->towrite needs to be drained */ | 286 | R5_Wantdrain, /* dev->towrite needs to be drained */ |
275 | #define R5_WantFUA 14 /* Write should be FUA */ | 287 | R5_WantFUA, /* Write should be FUA */ |
276 | #define R5_WriteError 15 /* got a write error - need to record it */ | 288 | R5_WriteError, /* got a write error - need to record it */ |
277 | #define R5_MadeGood 16 /* A bad block has been fixed by writing to it*/ | 289 | R5_MadeGood, /* A bad block has been fixed by writing to it */ |
278 | /* | 290 | R5_ReadRepl, /* Will/did read from replacement rather than orig */ |
279 | * Write method | 291 | R5_MadeGoodRepl,/* A bad block on the replacement device has been |
280 | */ | 292 | * fixed by writing to it */ |
281 | #define RECONSTRUCT_WRITE 1 | 293 | R5_NeedReplace, /* This device has a replacement which is not |
282 | #define READ_MODIFY_WRITE 2 | 294 | * up-to-date at this stripe. */ |
283 | /* not a write method, but a compute_parity mode */ | 295 | R5_WantReplace, /* We need to update the replacement, we have read |
284 | #define CHECK_PARITY 3 | 296 | * data in, and now is a good time to write it out. |
285 | /* Additional compute_parity mode -- updates the parity w/o LOCKING */ | 297 | */ |
286 | #define UPDATE_PARITY 4 | 298 | }; |
287 | 299 | ||
288 | /* | 300 | /* |
289 | * Stripe state | 301 | * Stripe state |
@@ -311,13 +323,14 @@ enum { | |||
311 | /* | 323 | /* |
312 | * Operation request flags | 324 | * Operation request flags |
313 | */ | 325 | */ |
314 | #define STRIPE_OP_BIOFILL 0 | 326 | enum { |
315 | #define STRIPE_OP_COMPUTE_BLK 1 | 327 | STRIPE_OP_BIOFILL, |
316 | #define STRIPE_OP_PREXOR 2 | 328 | STRIPE_OP_COMPUTE_BLK, |
317 | #define STRIPE_OP_BIODRAIN 3 | 329 | STRIPE_OP_PREXOR, |
318 | #define STRIPE_OP_RECONSTRUCT 4 | 330 | STRIPE_OP_BIODRAIN, |
319 | #define STRIPE_OP_CHECK 5 | 331 | STRIPE_OP_RECONSTRUCT, |
320 | 332 | STRIPE_OP_CHECK, | |
333 | }; | ||
321 | /* | 334 | /* |
322 | * Plugging: | 335 | * Plugging: |
323 | * | 336 | * |
@@ -344,13 +357,12 @@ enum { | |||
344 | 357 | ||
345 | 358 | ||
346 | struct disk_info { | 359 | struct disk_info { |
347 | struct md_rdev *rdev; | 360 | struct md_rdev *rdev, *replacement; |
348 | }; | 361 | }; |
349 | 362 | ||
350 | struct r5conf { | 363 | struct r5conf { |
351 | struct hlist_head *stripe_hashtbl; | 364 | struct hlist_head *stripe_hashtbl; |
352 | struct mddev *mddev; | 365 | struct mddev *mddev; |
353 | struct disk_info *spare; | ||
354 | int chunk_sectors; | 366 | int chunk_sectors; |
355 | int level, algorithm; | 367 | int level, algorithm; |
356 | int max_degraded; | 368 | int max_degraded; |