summaryrefslogtreecommitdiffstats
path: root/drivers/md/dm.c
diff options
context:
space:
mode:
authorMikulas Patocka <mpatocka@redhat.com>2009-04-09 00:27:15 +0100
committerAlasdair G Kergon <agk@redhat.com>2009-04-09 00:27:15 +0100
commit92c639021ca6e962645114f02e356e7feb131d0b (patch)
treeeee01e9394b09fb3929fd4f3682815e91b87c764 /drivers/md/dm.c
parent3b00b2036fac7a7667d0676a0f80eee575b8c32b (diff)
downloadtalos-obmc-linux-92c639021ca6e962645114f02e356e7feb131d0b.tar.gz
talos-obmc-linux-92c639021ca6e962645114f02e356e7feb131d0b.zip
dm: remove dm_request loop
Remove queue_io return value and a loop in dm_request. IO may be submitted to a worker thread with queue_io(). queue_io() sets DMF_QUEUE_IO_TO_THREAD so that all further IO is queued for the thread. When the thread finishes its work, it clears DMF_QUEUE_IO_TO_THREAD and from this point on, requests are submitted from dm_request again. This will be used for processing barriers. Remove the loop in dm_request. queue_io() can submit I/Os to the worker thread even if DMF_QUEUE_IO_TO_THREAD was not set. Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Diffstat (limited to 'drivers/md/dm.c')
-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)
/*
* Add the bio to the list of deferred io.
*/
-static int queue_io(struct mapped_device *md, struct bio *bio)
+static void queue_io(struct mapped_device *md, struct bio *bio)
{
down_write(&md->io_lock);
- if (!test_bit(DMF_QUEUE_IO_TO_THREAD, &md->flags)) {
- up_write(&md->io_lock);
- return 1;
- }
-
spin_lock_irq(&md->deferred_lock);
bio_list_add(&md->deferred, bio);
spin_unlock_irq(&md->deferred_lock);
+ if (!test_and_set_bit(DMF_QUEUE_IO_TO_THREAD, &md->flags))
+ queue_work(md->wq, &md->work);
+
up_write(&md->io_lock);
- return 0; /* deferred successfully */
}
/*
@@ -953,7 +950,7 @@ static int dm_request(struct request_queue *q, struct bio *bio)
* If we're suspended or the thread is processing barriers
* we have to queue this io for later.
*/
- while (test_bit(DMF_QUEUE_IO_TO_THREAD, &md->flags)) {
+ if (unlikely(test_bit(DMF_QUEUE_IO_TO_THREAD, &md->flags))) {
up_read(&md->io_lock);
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)
return 0;
}
- if (!queue_io(md, bio))
- return 0;
+ queue_io(md, bio);
- /*
- * We're in a while loop, because someone could suspend
- * before we get to the following read lock.
- */
- down_read(&md->io_lock);
+ return 0;
}
__split_and_process_bio(md, bio);
OpenPOWER on IntegriCloud