<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">From: Mikulas Patocka &lt;mpatocka@redhat.com&gt;

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 &lt;mpatocka@redhat.com&gt;
Signed-off-by: Alasdair G Kergon &lt;agk@redhat.com&gt;

---
 drivers/md/dm.c |   22 +++++++---------------
 1 files changed, 7 insertions(+), 15 deletions(-)

Index: linux-2.6.30-rc1/drivers/md/dm.c
===================================================================
--- linux-2.6.30-rc1.orig/drivers/md/dm.c	2009-04-08 22:28:06.000000000 +0100
+++ linux-2.6.30-rc1/drivers/md/dm.c	2009-04-08 22:28:08.000000000 +0100
@@ -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(&amp;md-&gt;io_lock);
 
-	if (!test_bit(DMF_QUEUE_IO_TO_THREAD, &amp;md-&gt;flags)) {
-		up_write(&amp;md-&gt;io_lock);
-		return 1;
-	}
-
 	spin_lock_irq(&amp;md-&gt;deferred_lock);
 	bio_list_add(&amp;md-&gt;deferred, bio);
 	spin_unlock_irq(&amp;md-&gt;deferred_lock);
 
+	if (!test_and_set_bit(DMF_QUEUE_IO_TO_THREAD, &amp;md-&gt;flags))
+		queue_work(md-&gt;wq, &amp;md-&gt;work);
+
 	up_write(&amp;md-&gt;io_lock);
-	return 0;		/* deferred successfully */
 }
 
 /*
@@ -953,7 +950,7 @@ static int dm_request(struct request_que
 	 * 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, &amp;md-&gt;flags)) {
+	if (unlikely(test_bit(DMF_QUEUE_IO_TO_THREAD, &amp;md-&gt;flags))) {
 		up_read(&amp;md-&gt;io_lock);
 
 		if (unlikely(test_bit(DMF_BLOCK_IO_FOR_SUSPEND, &amp;md-&gt;flags)) &amp;&amp;
@@ -962,14 +959,9 @@ static int dm_request(struct request_que
 			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(&amp;md-&gt;io_lock);
+		return 0;
 	}
 
 	__split_and_process_bio(md, bio);
</pre></body></html>