Commit c3b328ac authored by NeilBrown's avatar NeilBrown

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: default avatarNeilBrown <neilb@suse.de>
parent 7c13edc8
...@@ -565,12 +565,6 @@ static void flush_pending_writes(conf_t *conf) ...@@ -565,12 +565,6 @@ static void flush_pending_writes(conf_t *conf)
spin_unlock_irq(&conf->device_lock); spin_unlock_irq(&conf->device_lock);
} }
static void md_kick_device(mddev_t *mddev)
{
blk_flush_plug(current);
md_wakeup_thread(mddev->thread);
}
/* Barriers.... /* Barriers....
* Sometimes we need to suspend IO while we do something else, * Sometimes we need to suspend IO while we do something else,
* either some resync/recovery, or reconfigure the array. * either some resync/recovery, or reconfigure the array.
...@@ -600,7 +594,7 @@ static void raise_barrier(conf_t *conf) ...@@ -600,7 +594,7 @@ static void raise_barrier(conf_t *conf)
/* Wait until no block IO is waiting */ /* Wait until no block IO is waiting */
wait_event_lock_irq(conf->wait_barrier, !conf->nr_waiting, wait_event_lock_irq(conf->wait_barrier, !conf->nr_waiting,
conf->resync_lock, md_kick_device(conf->mddev)); conf->resync_lock, );
/* block any new IO from starting */ /* block any new IO from starting */
conf->barrier++; conf->barrier++;
...@@ -608,7 +602,7 @@ static void raise_barrier(conf_t *conf) ...@@ -608,7 +602,7 @@ static void raise_barrier(conf_t *conf)
/* Now wait for all pending IO to complete */ /* Now wait for all pending IO to complete */
wait_event_lock_irq(conf->wait_barrier, wait_event_lock_irq(conf->wait_barrier,
!conf->nr_pending && conf->barrier < RESYNC_DEPTH, !conf->nr_pending && conf->barrier < RESYNC_DEPTH,
conf->resync_lock, md_kick_device(conf->mddev)); conf->resync_lock, );
spin_unlock_irq(&conf->resync_lock); spin_unlock_irq(&conf->resync_lock);
} }
...@@ -630,7 +624,7 @@ static void wait_barrier(conf_t *conf) ...@@ -630,7 +624,7 @@ static void wait_barrier(conf_t *conf)
conf->nr_waiting++; conf->nr_waiting++;
wait_event_lock_irq(conf->wait_barrier, !conf->barrier, wait_event_lock_irq(conf->wait_barrier, !conf->barrier,
conf->resync_lock, conf->resync_lock,
md_kick_device(conf->mddev)); );
conf->nr_waiting--; conf->nr_waiting--;
} }
conf->nr_pending++; conf->nr_pending++;
...@@ -666,8 +660,7 @@ static void freeze_array(conf_t *conf) ...@@ -666,8 +660,7 @@ static void freeze_array(conf_t *conf)
wait_event_lock_irq(conf->wait_barrier, wait_event_lock_irq(conf->wait_barrier,
conf->nr_pending == conf->nr_queued+1, conf->nr_pending == conf->nr_queued+1,
conf->resync_lock, conf->resync_lock,
({ flush_pending_writes(conf); flush_pending_writes(conf));
md_kick_device(conf->mddev); }));
spin_unlock_irq(&conf->resync_lock); spin_unlock_irq(&conf->resync_lock);
} }
static void unfreeze_array(conf_t *conf) static void unfreeze_array(conf_t *conf)
...@@ -729,6 +722,7 @@ static int make_request(mddev_t *mddev, struct bio * bio) ...@@ -729,6 +722,7 @@ static int make_request(mddev_t *mddev, struct bio * bio)
const unsigned long do_sync = (bio->bi_rw & REQ_SYNC); const unsigned long do_sync = (bio->bi_rw & REQ_SYNC);
const unsigned long do_flush_fua = (bio->bi_rw & (REQ_FLUSH | REQ_FUA)); const unsigned long do_flush_fua = (bio->bi_rw & (REQ_FLUSH | REQ_FUA));
mdk_rdev_t *blocked_rdev; mdk_rdev_t *blocked_rdev;
int plugged;
/* /*
* Register the new request and wait if the reconstruction * Register the new request and wait if the reconstruction
...@@ -820,6 +814,8 @@ static int make_request(mddev_t *mddev, struct bio * bio) ...@@ -820,6 +814,8 @@ static int make_request(mddev_t *mddev, struct bio * bio)
* inc refcount on their rdev. Record them by setting * inc refcount on their rdev. Record them by setting
* bios[x] to bio * bios[x] to bio
*/ */
plugged = mddev_check_plugged(mddev);
disks = conf->raid_disks; disks = conf->raid_disks;
retry_write: retry_write:
blocked_rdev = NULL; blocked_rdev = NULL;
...@@ -925,7 +921,7 @@ static int make_request(mddev_t *mddev, struct bio * bio) ...@@ -925,7 +921,7 @@ static int make_request(mddev_t *mddev, struct bio * bio)
/* In case raid1d snuck in to freeze_array */ /* In case raid1d snuck in to freeze_array */
wake_up(&conf->wait_barrier); wake_up(&conf->wait_barrier);
if (do_sync || !bitmap) if (do_sync || !bitmap || !plugged)
md_wakeup_thread(mddev->thread); md_wakeup_thread(mddev->thread);
return 0; return 0;
...@@ -1524,7 +1520,8 @@ static void raid1d(mddev_t *mddev) ...@@ -1524,7 +1520,8 @@ static void raid1d(mddev_t *mddev)
for (;;) { for (;;) {
char b[BDEVNAME_SIZE]; char b[BDEVNAME_SIZE];
flush_pending_writes(conf); if (atomic_read(&mddev->plug_cnt) == 0)
flush_pending_writes(conf);
spin_lock_irqsave(&conf->device_lock, flags); spin_lock_irqsave(&conf->device_lock, flags);
if (list_empty(head)) { if (list_empty(head)) {
...@@ -2042,7 +2039,6 @@ static int stop(mddev_t *mddev) ...@@ -2042,7 +2039,6 @@ static int stop(mddev_t *mddev)
md_unregister_thread(mddev->thread); md_unregister_thread(mddev->thread);
mddev->thread = NULL; mddev->thread = NULL;
blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/
if (conf->r1bio_pool) if (conf->r1bio_pool)
mempool_destroy(conf->r1bio_pool); mempool_destroy(conf->r1bio_pool);
kfree(conf->mirrors); kfree(conf->mirrors);
......
...@@ -634,12 +634,6 @@ static void flush_pending_writes(conf_t *conf) ...@@ -634,12 +634,6 @@ static void flush_pending_writes(conf_t *conf)
spin_unlock_irq(&conf->device_lock); spin_unlock_irq(&conf->device_lock);
} }
static void md_kick_device(mddev_t *mddev)
{
blk_flush_plug(current);
md_wakeup_thread(mddev->thread);
}
/* Barriers.... /* Barriers....
* Sometimes we need to suspend IO while we do something else, * Sometimes we need to suspend IO while we do something else,
* either some resync/recovery, or reconfigure the array. * either some resync/recovery, or reconfigure the array.
...@@ -669,15 +663,15 @@ static void raise_barrier(conf_t *conf, int force) ...@@ -669,15 +663,15 @@ static void raise_barrier(conf_t *conf, int force)
/* Wait until no block IO is waiting (unless 'force') */ /* Wait until no block IO is waiting (unless 'force') */
wait_event_lock_irq(conf->wait_barrier, force || !conf->nr_waiting, wait_event_lock_irq(conf->wait_barrier, force || !conf->nr_waiting,
conf->resync_lock, md_kick_device(conf->mddev)); conf->resync_lock, );
/* block any new IO from starting */ /* block any new IO from starting */
conf->barrier++; conf->barrier++;
/* No wait for all pending IO to complete */ /* Now wait for all pending IO to complete */
wait_event_lock_irq(conf->wait_barrier, wait_event_lock_irq(conf->wait_barrier,
!conf->nr_pending && conf->barrier < RESYNC_DEPTH, !conf->nr_pending && conf->barrier < RESYNC_DEPTH,
conf->resync_lock, md_kick_device(conf->mddev)); conf->resync_lock, );
spin_unlock_irq(&conf->resync_lock); spin_unlock_irq(&conf->resync_lock);
} }
...@@ -698,7 +692,7 @@ static void wait_barrier(conf_t *conf) ...@@ -698,7 +692,7 @@ static void wait_barrier(conf_t *conf)
conf->nr_waiting++; conf->nr_waiting++;
wait_event_lock_irq(conf->wait_barrier, !conf->barrier, wait_event_lock_irq(conf->wait_barrier, !conf->barrier,
conf->resync_lock, conf->resync_lock,
md_kick_device(conf->mddev)); );
conf->nr_waiting--; conf->nr_waiting--;
} }
conf->nr_pending++; conf->nr_pending++;
...@@ -734,8 +728,8 @@ static void freeze_array(conf_t *conf) ...@@ -734,8 +728,8 @@ static void freeze_array(conf_t *conf)
wait_event_lock_irq(conf->wait_barrier, wait_event_lock_irq(conf->wait_barrier,
conf->nr_pending == conf->nr_queued+1, conf->nr_pending == conf->nr_queued+1,
conf->resync_lock, conf->resync_lock,
({ flush_pending_writes(conf); flush_pending_writes(conf));
md_kick_device(conf->mddev); }));
spin_unlock_irq(&conf->resync_lock); spin_unlock_irq(&conf->resync_lock);
} }
...@@ -762,6 +756,7 @@ static int make_request(mddev_t *mddev, struct bio * bio) ...@@ -762,6 +756,7 @@ static int make_request(mddev_t *mddev, struct bio * bio)
const unsigned long do_fua = (bio->bi_rw & REQ_FUA); const unsigned long do_fua = (bio->bi_rw & REQ_FUA);
unsigned long flags; unsigned long flags;
mdk_rdev_t *blocked_rdev; mdk_rdev_t *blocked_rdev;
int plugged;
if (unlikely(bio->bi_rw & REQ_FLUSH)) { if (unlikely(bio->bi_rw & REQ_FLUSH)) {
md_flush_request(mddev, bio); md_flush_request(mddev, bio);
...@@ -870,6 +865,8 @@ static int make_request(mddev_t *mddev, struct bio * bio) ...@@ -870,6 +865,8 @@ static int make_request(mddev_t *mddev, struct bio * bio)
* inc refcount on their rdev. Record them by setting * inc refcount on their rdev. Record them by setting
* bios[x] to bio * bios[x] to bio
*/ */
plugged = mddev_check_plugged(mddev);
raid10_find_phys(conf, r10_bio); raid10_find_phys(conf, r10_bio);
retry_write: retry_write:
blocked_rdev = NULL; blocked_rdev = NULL;
...@@ -946,9 +943,8 @@ static int make_request(mddev_t *mddev, struct bio * bio) ...@@ -946,9 +943,8 @@ static int make_request(mddev_t *mddev, struct bio * bio)
/* In case raid10d snuck in to freeze_array */ /* In case raid10d snuck in to freeze_array */
wake_up(&conf->wait_barrier); wake_up(&conf->wait_barrier);
if (do_sync || !mddev->bitmap) if (do_sync || !mddev->bitmap || !plugged)
md_wakeup_thread(mddev->thread); md_wakeup_thread(mddev->thread);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment