aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/raid1.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2011-04-18 04:25:43 -0400
committerNeilBrown <neilb@suse.de>2011-04-18 04:25:43 -0400
commitc3b328ac846bcf6b9a62c5563380a81ab723006d (patch)
treef9b78651beec3d66cf2ab7cf7a8080fa1cfe5b99 /drivers/md/raid1.c
parent7c13edc87510f665da3094174e1fd633e06649f4 (diff)
md: fix up raid1/raid10 unplugging.
We just need to make sure that an unplug event wakes up the md thread, which is exactly what mddev_check_plugged does. Also remove some plug-related code that is no longer needed. Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/md/raid1.c')
-rw-r--r--drivers/md/raid1.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 5449cd5e3141..2b7a7ff401dc 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -565,12 +565,6 @@ static void flush_pending_writes(conf_t *conf)
565 spin_unlock_irq(&conf->device_lock); 565 spin_unlock_irq(&conf->device_lock);
566} 566}
567 567
568static void md_kick_device(mddev_t *mddev)
569{
570 blk_flush_plug(current);
571 md_wakeup_thread(mddev->thread);
572}
573
574/* Barriers.... 568/* Barriers....
575 * Sometimes we need to suspend IO while we do something else, 569 * Sometimes we need to suspend IO while we do something else,
576 * either some resync/recovery, or reconfigure the array. 570 * either some resync/recovery, or reconfigure the array.
@@ -600,7 +594,7 @@ static void raise_barrier(conf_t *conf)
600 594
601 /* Wait until no block IO is waiting */ 595 /* Wait until no block IO is waiting */
602 wait_event_lock_irq(conf->wait_barrier, !conf->nr_waiting, 596 wait_event_lock_irq(conf->wait_barrier, !conf->nr_waiting,
603 conf->resync_lock, md_kick_device(conf->mddev)); 597 conf->resync_lock, );
604 598
605 /* block any new IO from starting */ 599 /* block any new IO from starting */
606 conf->barrier++; 600 conf->barrier++;
@@ -608,7 +602,7 @@ static void raise_barrier(conf_t *conf)
608 /* Now wait for all pending IO to complete */ 602 /* Now wait for all pending IO to complete */
609 wait_event_lock_irq(conf->wait_barrier, 603 wait_event_lock_irq(conf->wait_barrier,
610 !conf->nr_pending && conf->barrier < RESYNC_DEPTH, 604 !conf->nr_pending && conf->barrier < RESYNC_DEPTH,
611 conf->resync_lock, md_kick_device(conf->mddev)); 605 conf->resync_lock, );
612 606
613 spin_unlock_irq(&conf->resync_lock); 607 spin_unlock_irq(&conf->resync_lock);
614} 608}
@@ -630,7 +624,7 @@ static void wait_barrier(conf_t *conf)
630 conf->nr_waiting++; 624 conf->nr_waiting++;
631 wait_event_lock_irq(conf->wait_barrier, !conf->barrier, 625 wait_event_lock_irq(conf->wait_barrier, !conf->barrier,
632 conf->resync_lock, 626 conf->resync_lock,
633 md_kick_device(conf->mddev)); 627 );
634 conf->nr_waiting--; 628 conf->nr_waiting--;
635 } 629 }
636 conf->nr_pending++; 630 conf->nr_pending++;
@@ -666,8 +660,7 @@ static void freeze_array(conf_t *conf)
666 wait_event_lock_irq(conf->wait_barrier, 660 wait_event_lock_irq(conf->wait_barrier,
667 conf->nr_pending == conf->nr_queued+1, 661 conf->nr_pending == conf->nr_queued+1,
668 conf->resync_lock, 662 conf->resync_lock,
669 ({ flush_pending_writes(conf); 663 flush_pending_writes(conf));
670 md_kick_device(conf->mddev); }));
671 spin_unlock_irq(&conf->resync_lock); 664 spin_unlock_irq(&conf->resync_lock);
672} 665}
673static void unfreeze_array(conf_t *conf) 666static void unfreeze_array(conf_t *conf)
@@ -729,6 +722,7 @@ static int make_request(mddev_t *mddev, struct bio * bio)
729 const unsigned long do_sync = (bio->bi_rw & REQ_SYNC); 722 const unsigned long do_sync = (bio->bi_rw & REQ_SYNC);
730 const unsigned long do_flush_fua = (bio->bi_rw & (REQ_FLUSH | REQ_FUA)); 723 const unsigned long do_flush_fua = (bio->bi_rw & (REQ_FLUSH | REQ_FUA));
731 mdk_rdev_t *blocked_rdev; 724 mdk_rdev_t *blocked_rdev;
725 int plugged;
732 726
733 /* 727 /*
734 * Register the new request and wait if the reconstruction 728 * Register the new request and wait if the reconstruction
@@ -820,6 +814,8 @@ static int make_request(mddev_t *mddev, struct bio * bio)
820 * inc refcount on their rdev. Record them by setting 814 * inc refcount on their rdev. Record them by setting
821 * bios[x] to bio 815 * bios[x] to bio
822 */ 816 */
817 plugged = mddev_check_plugged(mddev);
818
823 disks = conf->raid_disks; 819 disks = conf->raid_disks;
824 retry_write: 820 retry_write:
825 blocked_rdev = NULL; 821 blocked_rdev = NULL;
@@ -925,7 +921,7 @@ static int make_request(mddev_t *mddev, struct bio * bio)
925 /* In case raid1d snuck in to freeze_array */ 921 /* In case raid1d snuck in to freeze_array */
926 wake_up(&conf->wait_barrier); 922 wake_up(&conf->wait_barrier);
927 923
928 if (do_sync || !bitmap) 924 if (do_sync || !bitmap || !plugged)
929 md_wakeup_thread(mddev->thread); 925 md_wakeup_thread(mddev->thread);
930 926
931 return 0; 927 return 0;
@@ -1524,7 +1520,8 @@ static void raid1d(mddev_t *mddev)
1524 for (;;) { 1520 for (;;) {
1525 char b[BDEVNAME_SIZE]; 1521 char b[BDEVNAME_SIZE];
1526 1522
1527 flush_pending_writes(conf); 1523 if (atomic_read(&mddev->plug_cnt) == 0)
1524 flush_pending_writes(conf);
1528 1525
1529 spin_lock_irqsave(&conf->device_lock, flags); 1526 spin_lock_irqsave(&conf->device_lock, flags);
1530 if (list_empty(head)) { 1527 if (list_empty(head)) {
@@ -2042,7 +2039,6 @@ static int stop(mddev_t *mddev)
2042 2039
2043 md_unregister_thread(mddev->thread); 2040 md_unregister_thread(mddev->thread);
2044 mddev->thread = NULL; 2041 mddev->thread = NULL;
2045 blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/
2046 if (conf->r1bio_pool) 2042 if (conf->r1bio_pool)
2047 mempool_destroy(conf->r1bio_pool); 2043 mempool_destroy(conf->r1bio_pool);
2048 kfree(conf->mirrors); 2044 kfree(conf->mirrors);