diff options
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/md.c | 8 | ||||
-rw-r--r-- | drivers/md/multipath.c | 3 | ||||
-rw-r--r-- | drivers/md/raid1.c | 13 | ||||
-rw-r--r-- | drivers/md/raid10.c | 26 | ||||
-rw-r--r-- | drivers/md/raid5.c | 67 |
5 files changed, 75 insertions, 42 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c index 1c2f9048e1ae..a4c219e3c859 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -5784,8 +5784,7 @@ static int add_new_disk(struct mddev * mddev, mdu_disk_info_t *info) | |||
5784 | super_types[mddev->major_version]. | 5784 | super_types[mddev->major_version]. |
5785 | validate_super(mddev, rdev); | 5785 | validate_super(mddev, rdev); |
5786 | if ((info->state & (1<<MD_DISK_SYNC)) && | 5786 | if ((info->state & (1<<MD_DISK_SYNC)) && |
5787 | (!test_bit(In_sync, &rdev->flags) || | 5787 | rdev->raid_disk != info->raid_disk) { |
5788 | rdev->raid_disk != info->raid_disk)) { | ||
5789 | /* This was a hot-add request, but events doesn't | 5788 | /* This was a hot-add request, but events doesn't |
5790 | * match, so reject it. | 5789 | * match, so reject it. |
5791 | */ | 5790 | */ |
@@ -6751,7 +6750,7 @@ struct md_thread *md_register_thread(void (*run) (struct mddev *), struct mddev | |||
6751 | thread->tsk = kthread_run(md_thread, thread, | 6750 | thread->tsk = kthread_run(md_thread, thread, |
6752 | "%s_%s", | 6751 | "%s_%s", |
6753 | mdname(thread->mddev), | 6752 | mdname(thread->mddev), |
6754 | name ?: mddev->pers->name); | 6753 | name); |
6755 | if (IS_ERR(thread->tsk)) { | 6754 | if (IS_ERR(thread->tsk)) { |
6756 | kfree(thread); | 6755 | kfree(thread); |
6757 | return NULL; | 6756 | return NULL; |
@@ -7298,6 +7297,7 @@ void md_do_sync(struct mddev *mddev) | |||
7298 | int skipped = 0; | 7297 | int skipped = 0; |
7299 | struct md_rdev *rdev; | 7298 | struct md_rdev *rdev; |
7300 | char *desc; | 7299 | char *desc; |
7300 | struct blk_plug plug; | ||
7301 | 7301 | ||
7302 | /* just incase thread restarts... */ | 7302 | /* just incase thread restarts... */ |
7303 | if (test_bit(MD_RECOVERY_DONE, &mddev->recovery)) | 7303 | if (test_bit(MD_RECOVERY_DONE, &mddev->recovery)) |
@@ -7447,6 +7447,7 @@ void md_do_sync(struct mddev *mddev) | |||
7447 | } | 7447 | } |
7448 | mddev->curr_resync_completed = j; | 7448 | mddev->curr_resync_completed = j; |
7449 | 7449 | ||
7450 | blk_start_plug(&plug); | ||
7450 | while (j < max_sectors) { | 7451 | while (j < max_sectors) { |
7451 | sector_t sectors; | 7452 | sector_t sectors; |
7452 | 7453 | ||
@@ -7552,6 +7553,7 @@ void md_do_sync(struct mddev *mddev) | |||
7552 | * this also signals 'finished resyncing' to md_stop | 7553 | * this also signals 'finished resyncing' to md_stop |
7553 | */ | 7554 | */ |
7554 | out: | 7555 | out: |
7556 | blk_finish_plug(&plug); | ||
7555 | wait_event(mddev->recovery_wait, !atomic_read(&mddev->recovery_active)); | 7557 | wait_event(mddev->recovery_wait, !atomic_read(&mddev->recovery_active)); |
7556 | 7558 | ||
7557 | /* tell personality that we are finished */ | 7559 | /* tell personality that we are finished */ |
diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c index 9339e67fcc79..61a1833ebaf3 100644 --- a/drivers/md/multipath.c +++ b/drivers/md/multipath.c | |||
@@ -474,7 +474,8 @@ static int multipath_run (struct mddev *mddev) | |||
474 | } | 474 | } |
475 | 475 | ||
476 | { | 476 | { |
477 | mddev->thread = md_register_thread(multipathd, mddev, NULL); | 477 | mddev->thread = md_register_thread(multipathd, mddev, |
478 | "multipath"); | ||
478 | if (!mddev->thread) { | 479 | if (!mddev->thread) { |
479 | printk(KERN_ERR "multipath: couldn't allocate thread" | 480 | printk(KERN_ERR "multipath: couldn't allocate thread" |
480 | " for %s\n", mdname(mddev)); | 481 | " for %s\n", mdname(mddev)); |
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index a9c7981ddd24..8c2754f835ef 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c | |||
@@ -517,8 +517,8 @@ static int read_balance(struct r1conf *conf, struct r1bio *r1_bio, int *max_sect | |||
517 | int bad_sectors; | 517 | int bad_sectors; |
518 | 518 | ||
519 | int disk = start_disk + i; | 519 | int disk = start_disk + i; |
520 | if (disk >= conf->raid_disks) | 520 | if (disk >= conf->raid_disks * 2) |
521 | disk -= conf->raid_disks; | 521 | disk -= conf->raid_disks * 2; |
522 | 522 | ||
523 | rdev = rcu_dereference(conf->mirrors[disk].rdev); | 523 | rdev = rcu_dereference(conf->mirrors[disk].rdev); |
524 | if (r1_bio->bios[disk] == IO_BLOCKED | 524 | if (r1_bio->bios[disk] == IO_BLOCKED |
@@ -883,7 +883,6 @@ static void make_request(struct mddev *mddev, struct bio * bio) | |||
883 | const unsigned long do_sync = (bio->bi_rw & REQ_SYNC); | 883 | const unsigned long do_sync = (bio->bi_rw & REQ_SYNC); |
884 | const unsigned long do_flush_fua = (bio->bi_rw & (REQ_FLUSH | REQ_FUA)); | 884 | const unsigned long do_flush_fua = (bio->bi_rw & (REQ_FLUSH | REQ_FUA)); |
885 | struct md_rdev *blocked_rdev; | 885 | struct md_rdev *blocked_rdev; |
886 | int plugged; | ||
887 | int first_clone; | 886 | int first_clone; |
888 | int sectors_handled; | 887 | int sectors_handled; |
889 | int max_sectors; | 888 | int max_sectors; |
@@ -1034,7 +1033,6 @@ read_again: | |||
1034 | * the bad blocks. Each set of writes gets it's own r1bio | 1033 | * the bad blocks. Each set of writes gets it's own r1bio |
1035 | * with a set of bios attached. | 1034 | * with a set of bios attached. |
1036 | */ | 1035 | */ |
1037 | plugged = mddev_check_plugged(mddev); | ||
1038 | 1036 | ||
1039 | disks = conf->raid_disks * 2; | 1037 | disks = conf->raid_disks * 2; |
1040 | retry_write: | 1038 | retry_write: |
@@ -1191,6 +1189,8 @@ read_again: | |||
1191 | bio_list_add(&conf->pending_bio_list, mbio); | 1189 | bio_list_add(&conf->pending_bio_list, mbio); |
1192 | conf->pending_count++; | 1190 | conf->pending_count++; |
1193 | spin_unlock_irqrestore(&conf->device_lock, flags); | 1191 | spin_unlock_irqrestore(&conf->device_lock, flags); |
1192 | if (!mddev_check_plugged(mddev)) | ||
1193 | md_wakeup_thread(mddev->thread); | ||
1194 | } | 1194 | } |
1195 | /* Mustn't call r1_bio_write_done before this next test, | 1195 | /* Mustn't call r1_bio_write_done before this next test, |
1196 | * as it could result in the bio being freed. | 1196 | * as it could result in the bio being freed. |
@@ -1213,9 +1213,6 @@ read_again: | |||
1213 | 1213 | ||
1214 | /* In case raid1d snuck in to freeze_array */ | 1214 | /* In case raid1d snuck in to freeze_array */ |
1215 | wake_up(&conf->wait_barrier); | 1215 | wake_up(&conf->wait_barrier); |
1216 | |||
1217 | if (do_sync || !bitmap || !plugged) | ||
1218 | md_wakeup_thread(mddev->thread); | ||
1219 | } | 1216 | } |
1220 | 1217 | ||
1221 | static void status(struct seq_file *seq, struct mddev *mddev) | 1218 | static void status(struct seq_file *seq, struct mddev *mddev) |
@@ -2621,7 +2618,7 @@ static struct r1conf *setup_conf(struct mddev *mddev) | |||
2621 | goto abort; | 2618 | goto abort; |
2622 | } | 2619 | } |
2623 | err = -ENOMEM; | 2620 | err = -ENOMEM; |
2624 | conf->thread = md_register_thread(raid1d, mddev, NULL); | 2621 | conf->thread = md_register_thread(raid1d, mddev, "raid1"); |
2625 | if (!conf->thread) { | 2622 | if (!conf->thread) { |
2626 | printk(KERN_ERR | 2623 | printk(KERN_ERR |
2627 | "md/raid1:%s: couldn't allocate thread\n", | 2624 | "md/raid1:%s: couldn't allocate thread\n", |
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 99ae6068e456..acf5a828c7e1 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c | |||
@@ -1039,7 +1039,6 @@ static void make_request(struct mddev *mddev, struct bio * bio) | |||
1039 | const unsigned long do_fua = (bio->bi_rw & REQ_FUA); | 1039 | const unsigned long do_fua = (bio->bi_rw & REQ_FUA); |
1040 | unsigned long flags; | 1040 | unsigned long flags; |
1041 | struct md_rdev *blocked_rdev; | 1041 | struct md_rdev *blocked_rdev; |
1042 | int plugged; | ||
1043 | int sectors_handled; | 1042 | int sectors_handled; |
1044 | int max_sectors; | 1043 | int max_sectors; |
1045 | int sectors; | 1044 | int sectors; |
@@ -1239,7 +1238,6 @@ read_again: | |||
1239 | * of r10_bios is recored in bio->bi_phys_segments just as with | 1238 | * of r10_bios is recored in bio->bi_phys_segments just as with |
1240 | * the read case. | 1239 | * the read case. |
1241 | */ | 1240 | */ |
1242 | plugged = mddev_check_plugged(mddev); | ||
1243 | 1241 | ||
1244 | r10_bio->read_slot = -1; /* make sure repl_bio gets freed */ | 1242 | r10_bio->read_slot = -1; /* make sure repl_bio gets freed */ |
1245 | raid10_find_phys(conf, r10_bio); | 1243 | raid10_find_phys(conf, r10_bio); |
@@ -1396,6 +1394,8 @@ retry_write: | |||
1396 | bio_list_add(&conf->pending_bio_list, mbio); | 1394 | bio_list_add(&conf->pending_bio_list, mbio); |
1397 | conf->pending_count++; | 1395 | conf->pending_count++; |
1398 | spin_unlock_irqrestore(&conf->device_lock, flags); | 1396 | spin_unlock_irqrestore(&conf->device_lock, flags); |
1397 | if (!mddev_check_plugged(mddev, 0, 0)) | ||
1398 | md_wakeup_thread(mddev->thread); | ||
1399 | 1399 | ||
1400 | if (!r10_bio->devs[i].repl_bio) | 1400 | if (!r10_bio->devs[i].repl_bio) |
1401 | continue; | 1401 | continue; |
@@ -1423,6 +1423,8 @@ retry_write: | |||
1423 | bio_list_add(&conf->pending_bio_list, mbio); | 1423 | bio_list_add(&conf->pending_bio_list, mbio); |
1424 | conf->pending_count++; | 1424 | conf->pending_count++; |
1425 | spin_unlock_irqrestore(&conf->device_lock, flags); | 1425 | spin_unlock_irqrestore(&conf->device_lock, flags); |
1426 | if (!mddev_check_plugged(mddev)) | ||
1427 | md_wakeup_thread(mddev->thread); | ||
1426 | } | 1428 | } |
1427 | 1429 | ||
1428 | /* Don't remove the bias on 'remaining' (one_write_done) until | 1430 | /* Don't remove the bias on 'remaining' (one_write_done) until |
@@ -1448,9 +1450,6 @@ retry_write: | |||
1448 | 1450 | ||
1449 | /* In case raid10d snuck in to freeze_array */ | 1451 | /* In case raid10d snuck in to freeze_array */ |
1450 | wake_up(&conf->wait_barrier); | 1452 | wake_up(&conf->wait_barrier); |
1451 | |||
1452 | if (do_sync || !mddev->bitmap || !plugged) | ||
1453 | md_wakeup_thread(mddev->thread); | ||
1454 | } | 1453 | } |
1455 | 1454 | ||
1456 | static void status(struct seq_file *seq, struct mddev *mddev) | 1455 | static void status(struct seq_file *seq, struct mddev *mddev) |
@@ -2310,7 +2309,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10 | |||
2310 | if (r10_sync_page_io(rdev, | 2309 | if (r10_sync_page_io(rdev, |
2311 | r10_bio->devs[sl].addr + | 2310 | r10_bio->devs[sl].addr + |
2312 | sect, | 2311 | sect, |
2313 | s<<9, conf->tmppage, WRITE) | 2312 | s, conf->tmppage, WRITE) |
2314 | == 0) { | 2313 | == 0) { |
2315 | /* Well, this device is dead */ | 2314 | /* Well, this device is dead */ |
2316 | printk(KERN_NOTICE | 2315 | printk(KERN_NOTICE |
@@ -2349,7 +2348,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10 | |||
2349 | switch (r10_sync_page_io(rdev, | 2348 | switch (r10_sync_page_io(rdev, |
2350 | r10_bio->devs[sl].addr + | 2349 | r10_bio->devs[sl].addr + |
2351 | sect, | 2350 | sect, |
2352 | s<<9, conf->tmppage, | 2351 | s, conf->tmppage, |
2353 | READ)) { | 2352 | READ)) { |
2354 | case 0: | 2353 | case 0: |
2355 | /* Well, this device is dead */ | 2354 | /* Well, this device is dead */ |
@@ -2512,7 +2511,7 @@ read_more: | |||
2512 | slot = r10_bio->read_slot; | 2511 | slot = r10_bio->read_slot; |
2513 | printk_ratelimited( | 2512 | printk_ratelimited( |
2514 | KERN_ERR | 2513 | KERN_ERR |
2515 | "md/raid10:%s: %s: redirecting" | 2514 | "md/raid10:%s: %s: redirecting " |
2516 | "sector %llu to another mirror\n", | 2515 | "sector %llu to another mirror\n", |
2517 | mdname(mddev), | 2516 | mdname(mddev), |
2518 | bdevname(rdev->bdev, b), | 2517 | bdevname(rdev->bdev, b), |
@@ -2661,7 +2660,8 @@ static void raid10d(struct mddev *mddev) | |||
2661 | blk_start_plug(&plug); | 2660 | blk_start_plug(&plug); |
2662 | for (;;) { | 2661 | for (;;) { |
2663 | 2662 | ||
2664 | flush_pending_writes(conf); | 2663 | if (atomic_read(&mddev->plug_cnt) == 0) |
2664 | flush_pending_writes(conf); | ||
2665 | 2665 | ||
2666 | spin_lock_irqsave(&conf->device_lock, flags); | 2666 | spin_lock_irqsave(&conf->device_lock, flags); |
2667 | if (list_empty(head)) { | 2667 | if (list_empty(head)) { |
@@ -2890,6 +2890,12 @@ static sector_t sync_request(struct mddev *mddev, sector_t sector_nr, | |||
2890 | /* want to reconstruct this device */ | 2890 | /* want to reconstruct this device */ |
2891 | rb2 = r10_bio; | 2891 | rb2 = r10_bio; |
2892 | sect = raid10_find_virt(conf, sector_nr, i); | 2892 | sect = raid10_find_virt(conf, sector_nr, i); |
2893 | if (sect >= mddev->resync_max_sectors) { | ||
2894 | /* last stripe is not complete - don't | ||
2895 | * try to recover this sector. | ||
2896 | */ | ||
2897 | continue; | ||
2898 | } | ||
2893 | /* Unless we are doing a full sync, or a replacement | 2899 | /* Unless we are doing a full sync, or a replacement |
2894 | * we only need to recover the block if it is set in | 2900 | * we only need to recover the block if it is set in |
2895 | * the bitmap | 2901 | * the bitmap |
@@ -3421,7 +3427,7 @@ static struct r10conf *setup_conf(struct mddev *mddev) | |||
3421 | spin_lock_init(&conf->resync_lock); | 3427 | spin_lock_init(&conf->resync_lock); |
3422 | init_waitqueue_head(&conf->wait_barrier); | 3428 | init_waitqueue_head(&conf->wait_barrier); |
3423 | 3429 | ||
3424 | conf->thread = md_register_thread(raid10d, mddev, NULL); | 3430 | conf->thread = md_register_thread(raid10d, mddev, "raid10"); |
3425 | if (!conf->thread) | 3431 | if (!conf->thread) |
3426 | goto out; | 3432 | goto out; |
3427 | 3433 | ||
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index d26767246d26..04348d76bb30 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c | |||
@@ -196,12 +196,14 @@ static void __release_stripe(struct r5conf *conf, struct stripe_head *sh) | |||
196 | BUG_ON(!list_empty(&sh->lru)); | 196 | BUG_ON(!list_empty(&sh->lru)); |
197 | BUG_ON(atomic_read(&conf->active_stripes)==0); | 197 | BUG_ON(atomic_read(&conf->active_stripes)==0); |
198 | if (test_bit(STRIPE_HANDLE, &sh->state)) { | 198 | if (test_bit(STRIPE_HANDLE, &sh->state)) { |
199 | if (test_bit(STRIPE_DELAYED, &sh->state)) | 199 | if (test_bit(STRIPE_DELAYED, &sh->state) && |
200 | !test_bit(STRIPE_PREREAD_ACTIVE, &sh->state)) | ||
200 | list_add_tail(&sh->lru, &conf->delayed_list); | 201 | list_add_tail(&sh->lru, &conf->delayed_list); |
201 | else if (test_bit(STRIPE_BIT_DELAY, &sh->state) && | 202 | else if (test_bit(STRIPE_BIT_DELAY, &sh->state) && |
202 | sh->bm_seq - conf->seq_write > 0) | 203 | sh->bm_seq - conf->seq_write > 0) |
203 | list_add_tail(&sh->lru, &conf->bitmap_list); | 204 | list_add_tail(&sh->lru, &conf->bitmap_list); |
204 | else { | 205 | else { |
206 | clear_bit(STRIPE_DELAYED, &sh->state); | ||
205 | clear_bit(STRIPE_BIT_DELAY, &sh->state); | 207 | clear_bit(STRIPE_BIT_DELAY, &sh->state); |
206 | list_add_tail(&sh->lru, &conf->handle_list); | 208 | list_add_tail(&sh->lru, &conf->handle_list); |
207 | } | 209 | } |
@@ -606,6 +608,12 @@ static void ops_run_io(struct stripe_head *sh, struct stripe_head_state *s) | |||
606 | * a chance*/ | 608 | * a chance*/ |
607 | md_check_recovery(conf->mddev); | 609 | md_check_recovery(conf->mddev); |
608 | } | 610 | } |
611 | /* | ||
612 | * Because md_wait_for_blocked_rdev | ||
613 | * will dec nr_pending, we must | ||
614 | * increment it first. | ||
615 | */ | ||
616 | atomic_inc(&rdev->nr_pending); | ||
609 | md_wait_for_blocked_rdev(rdev, conf->mddev); | 617 | md_wait_for_blocked_rdev(rdev, conf->mddev); |
610 | } else { | 618 | } else { |
611 | /* Acknowledged bad block - skip the write */ | 619 | /* Acknowledged bad block - skip the write */ |
@@ -1737,6 +1745,7 @@ static void raid5_end_read_request(struct bio * bi, int error) | |||
1737 | } else { | 1745 | } else { |
1738 | const char *bdn = bdevname(rdev->bdev, b); | 1746 | const char *bdn = bdevname(rdev->bdev, b); |
1739 | int retry = 0; | 1747 | int retry = 0; |
1748 | int set_bad = 0; | ||
1740 | 1749 | ||
1741 | clear_bit(R5_UPTODATE, &sh->dev[i].flags); | 1750 | clear_bit(R5_UPTODATE, &sh->dev[i].flags); |
1742 | atomic_inc(&rdev->read_errors); | 1751 | atomic_inc(&rdev->read_errors); |
@@ -1748,7 +1757,8 @@ static void raid5_end_read_request(struct bio * bi, int error) | |||
1748 | mdname(conf->mddev), | 1757 | mdname(conf->mddev), |
1749 | (unsigned long long)s, | 1758 | (unsigned long long)s, |
1750 | bdn); | 1759 | bdn); |
1751 | else if (conf->mddev->degraded >= conf->max_degraded) | 1760 | else if (conf->mddev->degraded >= conf->max_degraded) { |
1761 | set_bad = 1; | ||
1752 | printk_ratelimited( | 1762 | printk_ratelimited( |
1753 | KERN_WARNING | 1763 | KERN_WARNING |
1754 | "md/raid:%s: read error not correctable " | 1764 | "md/raid:%s: read error not correctable " |
@@ -1756,8 +1766,9 @@ static void raid5_end_read_request(struct bio * bi, int error) | |||
1756 | mdname(conf->mddev), | 1766 | mdname(conf->mddev), |
1757 | (unsigned long long)s, | 1767 | (unsigned long long)s, |
1758 | bdn); | 1768 | bdn); |
1759 | else if (test_bit(R5_ReWrite, &sh->dev[i].flags)) | 1769 | } else if (test_bit(R5_ReWrite, &sh->dev[i].flags)) { |
1760 | /* Oh, no!!! */ | 1770 | /* Oh, no!!! */ |
1771 | set_bad = 1; | ||
1761 | printk_ratelimited( | 1772 | printk_ratelimited( |
1762 | KERN_WARNING | 1773 | KERN_WARNING |
1763 | "md/raid:%s: read error NOT corrected!! " | 1774 | "md/raid:%s: read error NOT corrected!! " |
@@ -1765,7 +1776,7 @@ static void raid5_end_read_request(struct bio * bi, int error) | |||
1765 | mdname(conf->mddev), | 1776 | mdname(conf->mddev), |
1766 | (unsigned long long)s, | 1777 | (unsigned long long)s, |
1767 | bdn); | 1778 | bdn); |
1768 | else if (atomic_read(&rdev->read_errors) | 1779 | } else if (atomic_read(&rdev->read_errors) |
1769 | > conf->max_nr_stripes) | 1780 | > conf->max_nr_stripes) |
1770 | printk(KERN_WARNING | 1781 | printk(KERN_WARNING |
1771 | "md/raid:%s: Too many read errors, failing device %s.\n", | 1782 | "md/raid:%s: Too many read errors, failing device %s.\n", |
@@ -1777,7 +1788,11 @@ static void raid5_end_read_request(struct bio * bi, int error) | |||
1777 | else { | 1788 | else { |
1778 | clear_bit(R5_ReadError, &sh->dev[i].flags); | 1789 | clear_bit(R5_ReadError, &sh->dev[i].flags); |
1779 | clear_bit(R5_ReWrite, &sh->dev[i].flags); | 1790 | clear_bit(R5_ReWrite, &sh->dev[i].flags); |
1780 | md_error(conf->mddev, rdev); | 1791 | if (!(set_bad |
1792 | && test_bit(In_sync, &rdev->flags) | ||
1793 | && rdev_set_badblocks( | ||
1794 | rdev, sh->sector, STRIPE_SECTORS, 0))) | ||
1795 | md_error(conf->mddev, rdev); | ||
1781 | } | 1796 | } |
1782 | } | 1797 | } |
1783 | rdev_dec_pending(rdev, conf->mddev); | 1798 | rdev_dec_pending(rdev, conf->mddev); |
@@ -3582,8 +3597,18 @@ static void handle_stripe(struct stripe_head *sh) | |||
3582 | 3597 | ||
3583 | finish: | 3598 | finish: |
3584 | /* wait for this device to become unblocked */ | 3599 | /* wait for this device to become unblocked */ |
3585 | if (conf->mddev->external && unlikely(s.blocked_rdev)) | 3600 | if (unlikely(s.blocked_rdev)) { |
3586 | md_wait_for_blocked_rdev(s.blocked_rdev, conf->mddev); | 3601 | if (conf->mddev->external) |
3602 | md_wait_for_blocked_rdev(s.blocked_rdev, | ||
3603 | conf->mddev); | ||
3604 | else | ||
3605 | /* Internal metadata will immediately | ||
3606 | * be written by raid5d, so we don't | ||
3607 | * need to wait here. | ||
3608 | */ | ||
3609 | rdev_dec_pending(s.blocked_rdev, | ||
3610 | conf->mddev); | ||
3611 | } | ||
3587 | 3612 | ||
3588 | if (s.handle_bad_blocks) | 3613 | if (s.handle_bad_blocks) |
3589 | for (i = disks; i--; ) { | 3614 | for (i = disks; i--; ) { |
@@ -3881,8 +3906,6 @@ static int chunk_aligned_read(struct mddev *mddev, struct bio * raid_bio) | |||
3881 | raid_bio->bi_next = (void*)rdev; | 3906 | raid_bio->bi_next = (void*)rdev; |
3882 | align_bi->bi_bdev = rdev->bdev; | 3907 | align_bi->bi_bdev = rdev->bdev; |
3883 | align_bi->bi_flags &= ~(1 << BIO_SEG_VALID); | 3908 | align_bi->bi_flags &= ~(1 << BIO_SEG_VALID); |
3884 | /* No reshape active, so we can trust rdev->data_offset */ | ||
3885 | align_bi->bi_sector += rdev->data_offset; | ||
3886 | 3909 | ||
3887 | if (!bio_fits_rdev(align_bi) || | 3910 | if (!bio_fits_rdev(align_bi) || |
3888 | is_badblock(rdev, align_bi->bi_sector, align_bi->bi_size>>9, | 3911 | is_badblock(rdev, align_bi->bi_sector, align_bi->bi_size>>9, |
@@ -3893,6 +3916,9 @@ static int chunk_aligned_read(struct mddev *mddev, struct bio * raid_bio) | |||
3893 | return 0; | 3916 | return 0; |
3894 | } | 3917 | } |
3895 | 3918 | ||
3919 | /* No reshape active, so we can trust rdev->data_offset */ | ||
3920 | align_bi->bi_sector += rdev->data_offset; | ||
3921 | |||
3896 | spin_lock_irq(&conf->device_lock); | 3922 | spin_lock_irq(&conf->device_lock); |
3897 | wait_event_lock_irq(conf->wait_for_stripe, | 3923 | wait_event_lock_irq(conf->wait_for_stripe, |
3898 | conf->quiesce == 0, | 3924 | conf->quiesce == 0, |
@@ -3971,7 +3997,6 @@ static void make_request(struct mddev *mddev, struct bio * bi) | |||
3971 | struct stripe_head *sh; | 3997 | struct stripe_head *sh; |
3972 | const int rw = bio_data_dir(bi); | 3998 | const int rw = bio_data_dir(bi); |
3973 | int remaining; | 3999 | int remaining; |
3974 | int plugged; | ||
3975 | 4000 | ||
3976 | if (unlikely(bi->bi_rw & REQ_FLUSH)) { | 4001 | if (unlikely(bi->bi_rw & REQ_FLUSH)) { |
3977 | md_flush_request(mddev, bi); | 4002 | md_flush_request(mddev, bi); |
@@ -3990,7 +4015,6 @@ static void make_request(struct mddev *mddev, struct bio * bi) | |||
3990 | bi->bi_next = NULL; | 4015 | bi->bi_next = NULL; |
3991 | bi->bi_phys_segments = 1; /* over-loaded to count active stripes */ | 4016 | bi->bi_phys_segments = 1; /* over-loaded to count active stripes */ |
3992 | 4017 | ||
3993 | plugged = mddev_check_plugged(mddev); | ||
3994 | for (;logical_sector < last_sector; logical_sector += STRIPE_SECTORS) { | 4018 | for (;logical_sector < last_sector; logical_sector += STRIPE_SECTORS) { |
3995 | DEFINE_WAIT(w); | 4019 | DEFINE_WAIT(w); |
3996 | int previous; | 4020 | int previous; |
@@ -4092,6 +4116,7 @@ static void make_request(struct mddev *mddev, struct bio * bi) | |||
4092 | if ((bi->bi_rw & REQ_SYNC) && | 4116 | if ((bi->bi_rw & REQ_SYNC) && |
4093 | !test_and_set_bit(STRIPE_PREREAD_ACTIVE, &sh->state)) | 4117 | !test_and_set_bit(STRIPE_PREREAD_ACTIVE, &sh->state)) |
4094 | atomic_inc(&conf->preread_active_stripes); | 4118 | atomic_inc(&conf->preread_active_stripes); |
4119 | mddev_check_plugged(mddev); | ||
4095 | release_stripe(sh); | 4120 | release_stripe(sh); |
4096 | } else { | 4121 | } else { |
4097 | /* cannot get stripe for read-ahead, just give-up */ | 4122 | /* cannot get stripe for read-ahead, just give-up */ |
@@ -4099,10 +4124,7 @@ static void make_request(struct mddev *mddev, struct bio * bi) | |||
4099 | finish_wait(&conf->wait_for_overlap, &w); | 4124 | finish_wait(&conf->wait_for_overlap, &w); |
4100 | break; | 4125 | break; |
4101 | } | 4126 | } |
4102 | |||
4103 | } | 4127 | } |
4104 | if (!plugged) | ||
4105 | md_wakeup_thread(mddev->thread); | ||
4106 | 4128 | ||
4107 | spin_lock_irq(&conf->device_lock); | 4129 | spin_lock_irq(&conf->device_lock); |
4108 | remaining = raid5_dec_bi_phys_segments(bi); | 4130 | remaining = raid5_dec_bi_phys_segments(bi); |
@@ -4823,6 +4845,7 @@ static struct r5conf *setup_conf(struct mddev *mddev) | |||
4823 | int raid_disk, memory, max_disks; | 4845 | int raid_disk, memory, max_disks; |
4824 | struct md_rdev *rdev; | 4846 | struct md_rdev *rdev; |
4825 | struct disk_info *disk; | 4847 | struct disk_info *disk; |
4848 | char pers_name[6]; | ||
4826 | 4849 | ||
4827 | if (mddev->new_level != 5 | 4850 | if (mddev->new_level != 5 |
4828 | && mddev->new_level != 4 | 4851 | && mddev->new_level != 4 |
@@ -4946,7 +4969,8 @@ static struct r5conf *setup_conf(struct mddev *mddev) | |||
4946 | printk(KERN_INFO "md/raid:%s: allocated %dkB\n", | 4969 | printk(KERN_INFO "md/raid:%s: allocated %dkB\n", |
4947 | mdname(mddev), memory); | 4970 | mdname(mddev), memory); |
4948 | 4971 | ||
4949 | conf->thread = md_register_thread(raid5d, mddev, NULL); | 4972 | sprintf(pers_name, "raid%d", mddev->new_level); |
4973 | conf->thread = md_register_thread(raid5d, mddev, pers_name); | ||
4950 | if (!conf->thread) { | 4974 | if (!conf->thread) { |
4951 | printk(KERN_ERR | 4975 | printk(KERN_ERR |
4952 | "md/raid:%s: couldn't allocate thread.\n", | 4976 | "md/raid:%s: couldn't allocate thread.\n", |
@@ -5465,10 +5489,9 @@ static int raid5_add_disk(struct mddev *mddev, struct md_rdev *rdev) | |||
5465 | if (rdev->saved_raid_disk >= 0 && | 5489 | if (rdev->saved_raid_disk >= 0 && |
5466 | rdev->saved_raid_disk >= first && | 5490 | rdev->saved_raid_disk >= first && |
5467 | conf->disks[rdev->saved_raid_disk].rdev == NULL) | 5491 | conf->disks[rdev->saved_raid_disk].rdev == NULL) |
5468 | disk = rdev->saved_raid_disk; | 5492 | first = rdev->saved_raid_disk; |
5469 | else | 5493 | |
5470 | disk = first; | 5494 | for (disk = first; disk <= last; disk++) { |
5471 | for ( ; disk <= last ; disk++) { | ||
5472 | p = conf->disks + disk; | 5495 | p = conf->disks + disk; |
5473 | if (p->rdev == NULL) { | 5496 | if (p->rdev == NULL) { |
5474 | clear_bit(In_sync, &rdev->flags); | 5497 | clear_bit(In_sync, &rdev->flags); |
@@ -5477,8 +5500,11 @@ static int raid5_add_disk(struct mddev *mddev, struct md_rdev *rdev) | |||
5477 | if (rdev->saved_raid_disk != disk) | 5500 | if (rdev->saved_raid_disk != disk) |
5478 | conf->fullsync = 1; | 5501 | conf->fullsync = 1; |
5479 | rcu_assign_pointer(p->rdev, rdev); | 5502 | rcu_assign_pointer(p->rdev, rdev); |
5480 | break; | 5503 | goto out; |
5481 | } | 5504 | } |
5505 | } | ||
5506 | for (disk = first; disk <= last; disk++) { | ||
5507 | p = conf->disks + disk; | ||
5482 | if (test_bit(WantReplacement, &p->rdev->flags) && | 5508 | if (test_bit(WantReplacement, &p->rdev->flags) && |
5483 | p->replacement == NULL) { | 5509 | p->replacement == NULL) { |
5484 | clear_bit(In_sync, &rdev->flags); | 5510 | clear_bit(In_sync, &rdev->flags); |
@@ -5490,6 +5516,7 @@ static int raid5_add_disk(struct mddev *mddev, struct md_rdev *rdev) | |||
5490 | break; | 5516 | break; |
5491 | } | 5517 | } |
5492 | } | 5518 | } |
5519 | out: | ||
5493 | print_raid5_conf(conf); | 5520 | print_raid5_conf(conf); |
5494 | return err; | 5521 | return err; |
5495 | } | 5522 | } |