aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/md/dm.c22
1 files changed, 7 insertions, 15 deletions
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 9746c1eb9ef7..db022e5f3912 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -436,21 +436,18 @@ static void end_io_acct(struct dm_io *io)
436/* 436/*
437 * Add the bio to the list of deferred io. 437 * Add the bio to the list of deferred io.
438 */ 438 */
439static int queue_io(struct mapped_device *md, struct bio *bio) 439static void queue_io(struct mapped_device *md, struct bio *bio)
440{ 440{
441 down_write(&md->io_lock); 441 down_write(&md->io_lock);
442 442
443 if (!test_bit(DMF_QUEUE_IO_TO_THREAD, &md->flags)) {
444 up_write(&md->io_lock);
445 return 1;
446 }
447
448 spin_lock_irq(&md->deferred_lock); 443 spin_lock_irq(&md->deferred_lock);
449 bio_list_add(&md->deferred, bio); 444 bio_list_add(&md->deferred, bio);
450 spin_unlock_irq(&md->deferred_lock); 445 spin_unlock_irq(&md->deferred_lock);
451 446
447 if (!test_and_set_bit(DMF_QUEUE_IO_TO_THREAD, &md->flags))
448 queue_work(md->wq, &md->work);
449
452 up_write(&md->io_lock); 450 up_write(&md->io_lock);
453 return 0; /* deferred successfully */
454} 451}
455 452
456/* 453/*
@@ -953,7 +950,7 @@ static int dm_request(struct request_queue *q, struct bio *bio)
953 * If we're suspended or the thread is processing barriers 950 * If we're suspended or the thread is processing barriers
954 * we have to queue this io for later. 951 * we have to queue this io for later.
955 */ 952 */
956 while (test_bit(DMF_QUEUE_IO_TO_THREAD, &md->flags)) { 953 if (unlikely(test_bit(DMF_QUEUE_IO_TO_THREAD, &md->flags))) {
957 up_read(&md->io_lock); 954 up_read(&md->io_lock);
958 955
959 if (unlikely(test_bit(DMF_BLOCK_IO_FOR_SUSPEND, &md->flags)) && 956 if (unlikely(test_bit(DMF_BLOCK_IO_FOR_SUSPEND, &md->flags)) &&
@@ -962,14 +959,9 @@ static int dm_request(struct request_queue *q, struct bio *bio)
962 return 0; 959 return 0;
963 } 960 }
964 961
965 if (!queue_io(md, bio)) 962 queue_io(md, bio);
966 return 0;
967 963
968 /* 964 return 0;
969 * We're in a while loop, because someone could suspend
970 * before we get to the following read lock.
971 */
972 down_read(&md->io_lock);
973 } 965 }
974 966
975 __split_and_process_bio(md, bio); 967 __split_and_process_bio(md, bio);