aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2015-10-26 18:41:48 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-10-26 18:41:48 -0400
commitce6f9886037f5566cb8e440b9caa5e7d7334e53b (patch)
tree8863ad5efdde5c026dc8f0f1e70fdafbe2f8f796
parent896066ee1cf4d653057dac4e952f49c96ad16fa7 (diff)
parent8bce6d35b308d73cdb2ee273c95d711a55be688c (diff)
Merge tag 'md/4.3-rc6-fixes' of git://neil.brown.name/md
Pull md fixes from Neil Brown: "Some raid1/raid10 fixes. I meant to get this to you before -rc7, but what with all the travel plans.. Two fixes for bugs that are in both raid1 and raid10. Both related to bad-block-lists and at least one needs to be back ported to 3.1. Also a revision for the "new" layout in raid10. This "new" code (which aims to improve robustness) actually reduces robustness in some cases. It probably isn't in use at all as not public user-space code makes use of these new layouts. However just in case someone has their own code, it would be good to get the WARNing out for them sooner" * tag 'md/4.3-rc6-fixes' of git://neil.brown.name/md: md/raid10: fix the 'new' raid10 layout to work correctly. md/raid10: don't clear bitmap bit when bad-block-list write fails. md/raid1: don't clear bitmap bit when bad-block-list write fails. md/raid10: submit_bio_wait() returns 0 on success md/raid1: submit_bio_wait() returns 0 on success
-rw-r--r--drivers/md/raid1.c13
-rw-r--r--drivers/md/raid10.c39
2 files changed, 41 insertions, 11 deletions
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index ddd8a5f572aa..d9d031ede4bf 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -2195,7 +2195,7 @@ static int narrow_write_error(struct r1bio *r1_bio, int i)
2195 bio_trim(wbio, sector - r1_bio->sector, sectors); 2195 bio_trim(wbio, sector - r1_bio->sector, sectors);
2196 wbio->bi_iter.bi_sector += rdev->data_offset; 2196 wbio->bi_iter.bi_sector += rdev->data_offset;
2197 wbio->bi_bdev = rdev->bdev; 2197 wbio->bi_bdev = rdev->bdev;
2198 if (submit_bio_wait(WRITE, wbio) == 0) 2198 if (submit_bio_wait(WRITE, wbio) < 0)
2199 /* failure! */ 2199 /* failure! */
2200 ok = rdev_set_badblocks(rdev, sector, 2200 ok = rdev_set_badblocks(rdev, sector,
2201 sectors, 0) 2201 sectors, 0)
@@ -2258,15 +2258,16 @@ static void handle_write_finished(struct r1conf *conf, struct r1bio *r1_bio)
2258 rdev_dec_pending(conf->mirrors[m].rdev, 2258 rdev_dec_pending(conf->mirrors[m].rdev,
2259 conf->mddev); 2259 conf->mddev);
2260 } 2260 }
2261 if (test_bit(R1BIO_WriteError, &r1_bio->state))
2262 close_write(r1_bio);
2263 if (fail) { 2261 if (fail) {
2264 spin_lock_irq(&conf->device_lock); 2262 spin_lock_irq(&conf->device_lock);
2265 list_add(&r1_bio->retry_list, &conf->bio_end_io_list); 2263 list_add(&r1_bio->retry_list, &conf->bio_end_io_list);
2266 spin_unlock_irq(&conf->device_lock); 2264 spin_unlock_irq(&conf->device_lock);
2267 md_wakeup_thread(conf->mddev->thread); 2265 md_wakeup_thread(conf->mddev->thread);
2268 } else 2266 } else {
2267 if (test_bit(R1BIO_WriteError, &r1_bio->state))
2268 close_write(r1_bio);
2269 raid_end_bio_io(r1_bio); 2269 raid_end_bio_io(r1_bio);
2270 }
2270} 2271}
2271 2272
2272static void handle_read_error(struct r1conf *conf, struct r1bio *r1_bio) 2273static void handle_read_error(struct r1conf *conf, struct r1bio *r1_bio)
@@ -2385,6 +2386,10 @@ static void raid1d(struct md_thread *thread)
2385 r1_bio = list_first_entry(&tmp, struct r1bio, 2386 r1_bio = list_first_entry(&tmp, struct r1bio,
2386 retry_list); 2387 retry_list);
2387 list_del(&r1_bio->retry_list); 2388 list_del(&r1_bio->retry_list);
2389 if (mddev->degraded)
2390 set_bit(R1BIO_Degraded, &r1_bio->state);
2391 if (test_bit(R1BIO_WriteError, &r1_bio->state))
2392 close_write(r1_bio);
2388 raid_end_bio_io(r1_bio); 2393 raid_end_bio_io(r1_bio);
2389 } 2394 }
2390 } 2395 }
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 9f69dc526f8c..96f365968306 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -39,6 +39,7 @@
39 * far_copies (stored in second byte of layout) 39 * far_copies (stored in second byte of layout)
40 * far_offset (stored in bit 16 of layout ) 40 * far_offset (stored in bit 16 of layout )
41 * use_far_sets (stored in bit 17 of layout ) 41 * use_far_sets (stored in bit 17 of layout )
42 * use_far_sets_bugfixed (stored in bit 18 of layout )
42 * 43 *
43 * The data to be stored is divided into chunks using chunksize. Each device 44 * The data to be stored is divided into chunks using chunksize. Each device
44 * is divided into far_copies sections. In each section, chunks are laid out 45 * is divided into far_copies sections. In each section, chunks are laid out
@@ -1497,6 +1498,8 @@ static void status(struct seq_file *seq, struct mddev *mddev)
1497 seq_printf(seq, " %d offset-copies", conf->geo.far_copies); 1498 seq_printf(seq, " %d offset-copies", conf->geo.far_copies);
1498 else 1499 else
1499 seq_printf(seq, " %d far-copies", conf->geo.far_copies); 1500 seq_printf(seq, " %d far-copies", conf->geo.far_copies);
1501 if (conf->geo.far_set_size != conf->geo.raid_disks)
1502 seq_printf(seq, " %d devices per set", conf->geo.far_set_size);
1500 } 1503 }
1501 seq_printf(seq, " [%d/%d] [", conf->geo.raid_disks, 1504 seq_printf(seq, " [%d/%d] [", conf->geo.raid_disks,
1502 conf->geo.raid_disks - mddev->degraded); 1505 conf->geo.raid_disks - mddev->degraded);
@@ -2467,7 +2470,7 @@ static int narrow_write_error(struct r10bio *r10_bio, int i)
2467 choose_data_offset(r10_bio, rdev) + 2470 choose_data_offset(r10_bio, rdev) +
2468 (sector - r10_bio->sector)); 2471 (sector - r10_bio->sector));
2469 wbio->bi_bdev = rdev->bdev; 2472 wbio->bi_bdev = rdev->bdev;
2470 if (submit_bio_wait(WRITE, wbio) == 0) 2473 if (submit_bio_wait(WRITE, wbio) < 0)
2471 /* Failure! */ 2474 /* Failure! */
2472 ok = rdev_set_badblocks(rdev, sector, 2475 ok = rdev_set_badblocks(rdev, sector,
2473 sectors, 0) 2476 sectors, 0)
@@ -2654,16 +2657,17 @@ static void handle_write_completed(struct r10conf *conf, struct r10bio *r10_bio)
2654 rdev_dec_pending(rdev, conf->mddev); 2657 rdev_dec_pending(rdev, conf->mddev);
2655 } 2658 }
2656 } 2659 }
2657 if (test_bit(R10BIO_WriteError,
2658 &r10_bio->state))
2659 close_write(r10_bio);
2660 if (fail) { 2660 if (fail) {
2661 spin_lock_irq(&conf->device_lock); 2661 spin_lock_irq(&conf->device_lock);
2662 list_add(&r10_bio->retry_list, &conf->bio_end_io_list); 2662 list_add(&r10_bio->retry_list, &conf->bio_end_io_list);
2663 spin_unlock_irq(&conf->device_lock); 2663 spin_unlock_irq(&conf->device_lock);
2664 md_wakeup_thread(conf->mddev->thread); 2664 md_wakeup_thread(conf->mddev->thread);
2665 } else 2665 } else {
2666 if (test_bit(R10BIO_WriteError,
2667 &r10_bio->state))
2668 close_write(r10_bio);
2666 raid_end_bio_io(r10_bio); 2669 raid_end_bio_io(r10_bio);
2670 }
2667 } 2671 }
2668} 2672}
2669 2673
@@ -2691,6 +2695,12 @@ static void raid10d(struct md_thread *thread)
2691 r10_bio = list_first_entry(&tmp, struct r10bio, 2695 r10_bio = list_first_entry(&tmp, struct r10bio,
2692 retry_list); 2696 retry_list);
2693 list_del(&r10_bio->retry_list); 2697 list_del(&r10_bio->retry_list);
2698 if (mddev->degraded)
2699 set_bit(R10BIO_Degraded, &r10_bio->state);
2700
2701 if (test_bit(R10BIO_WriteError,
2702 &r10_bio->state))
2703 close_write(r10_bio);
2694 raid_end_bio_io(r10_bio); 2704 raid_end_bio_io(r10_bio);
2695 } 2705 }
2696 } 2706 }
@@ -3387,7 +3397,7 @@ static int setup_geo(struct geom *geo, struct mddev *mddev, enum geo_type new)
3387 disks = mddev->raid_disks + mddev->delta_disks; 3397 disks = mddev->raid_disks + mddev->delta_disks;
3388 break; 3398 break;
3389 } 3399 }
3390 if (layout >> 18) 3400 if (layout >> 19)
3391 return -1; 3401 return -1;
3392 if (chunk < (PAGE_SIZE >> 9) || 3402 if (chunk < (PAGE_SIZE >> 9) ||
3393 !is_power_of_2(chunk)) 3403 !is_power_of_2(chunk))
@@ -3399,7 +3409,22 @@ static int setup_geo(struct geom *geo, struct mddev *mddev, enum geo_type new)
3399 geo->near_copies = nc; 3409 geo->near_copies = nc;
3400 geo->far_copies = fc; 3410 geo->far_copies = fc;
3401 geo->far_offset = fo; 3411 geo->far_offset = fo;
3402 geo->far_set_size = (layout & (1<<17)) ? disks / fc : disks; 3412 switch (layout >> 17) {
3413 case 0: /* original layout. simple but not always optimal */
3414 geo->far_set_size = disks;
3415 break;
3416 case 1: /* "improved" layout which was buggy. Hopefully no-one is
3417 * actually using this, but leave code here just in case.*/
3418 geo->far_set_size = disks/fc;
3419 WARN(geo->far_set_size < fc,
3420 "This RAID10 layout does not provide data safety - please backup and create new array\n");
3421 break;
3422 case 2: /* "improved" layout fixed to match documentation */
3423 geo->far_set_size = fc * nc;
3424 break;
3425 default: /* Not a valid layout */
3426 return -1;
3427 }
3403 geo->chunk_mask = chunk - 1; 3428 geo->chunk_mask = chunk - 1;
3404 geo->chunk_shift = ffz(~chunk); 3429 geo->chunk_shift = ffz(~chunk);
3405 return nc*fc; 3430 return nc*fc;