public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Elias Oltmanns <eo@nebensachen.de>
To: Jens Axboe <jens.axboe@oracle.com>
Cc: linux-kernel@vger.kernel.org
Subject: Block: Fix handling of stopped queues and a plugging issue
Date: Thu, 02 Oct 2008 17:59:18 +0200	[thread overview]
Message-ID: <87zllnound.fsf@denkblock.local> (raw)

Make sure that ->request_fn() really isn't called on queues that are
supposed to be stopped. While at it, don't remove the plug in
__blk_run_queue() unconditionally since this might lead to system hangs.

Signed-off-by: Elias Oltmanns <eo@nebensachen.de>
---
Applies to your devel tree.

 block/blk-core.c |    6 +++---
 block/elevator.c |   12 +++++++-----
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/block/blk-core.c b/block/blk-core.c
index 2d053b5..ecc5443 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -404,14 +404,14 @@ EXPORT_SYMBOL(blk_sync_queue);
  */
 void __blk_run_queue(struct request_queue *q)
 {
-	blk_remove_plug(q);
-
 	/*
 	 * Only recurse once to avoid overrunning the stack, let the unplug
 	 * handling reinvoke the handler shortly if we already got there.
 	 */
-	if (!elv_queue_empty(q))
+	if (!elv_queue_empty(q) && likely(!blk_queue_stopped(q))) {
+		blk_remove_plug(q);
 		blk_invoke_request_fn(q);
+	}
 }
 EXPORT_SYMBOL(__blk_run_queue);
 
diff --git a/block/elevator.c b/block/elevator.c
index 0451892..43a4257 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -611,8 +611,10 @@ void elv_insert(struct request_queue *q, struct request *rq, int where)
 		 *   with anything.  There's no point in delaying queue
 		 *   processing.
 		 */
-		blk_remove_plug(q);
-		q->request_fn(q);
+		if (likely(!blk_queue_stopped(q))) {
+			blk_remove_plug(q);
+			q->request_fn(q);
+		}
 		break;
 
 	case ELEVATOR_INSERT_SORT:
@@ -950,7 +952,8 @@ void elv_completed_request(struct request_queue *q, struct request *rq)
 		    blk_ordered_cur_seq(q) == QUEUE_ORDSEQ_DRAIN &&
 		    blk_ordered_req_seq(first_rq) > QUEUE_ORDSEQ_DRAIN) {
 			blk_ordered_complete_seq(q, QUEUE_ORDSEQ_DRAIN, 0);
-			q->request_fn(q);
+			if (likely(!blk_queue_stopped(q)))
+				q->request_fn(q);
 		}
 	}
 }
@@ -1109,8 +1112,7 @@ static int elevator_switch(struct request_queue *q, struct elevator_type *new_e)
 	elv_drain_elevator(q);
 
 	while (q->rq.elvpriv) {
-		blk_remove_plug(q);
-		q->request_fn(q);
+		blk_start_queueing(q);
 		spin_unlock_irq(q->queue_lock);
 		msleep(10);
 		spin_lock_irq(q->queue_lock);

             reply	other threads:[~2008-10-02 15:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-02 15:59 Elias Oltmanns [this message]
2008-10-10  9:07 ` Block: Fix handling of stopped queues and a plugging issue Elias Oltmanns
2008-10-10  9:17 ` Jens Axboe
2008-10-11 17:36   ` Elias Oltmanns

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87zllnound.fsf@denkblock.local \
    --to=eo@nebensachen.de \
    --cc=jens.axboe@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox