public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] blk: fix possible queue stall in blk_do_ordered
@ 2006-01-12 15:29 Tejun Heo
  2006-01-12 16:09 ` Mark Lord
  0 siblings, 1 reply; 3+ messages in thread
From: Tejun Heo @ 2006-01-12 15:29 UTC (permalink / raw)
  To: axboe; +Cc: linux-kernel

Previously, if a fs request which was being drained failed and got
requeued, blk_do_ordered() didn't allow it to be reissued, which
causes queue stall.  This patch makes blk_do_ordered() use the
sequence of each request to determine whether a request can be issued
or not.  This fixes the bug and simplifies code.

Signed-off-by: Tejun Heo <htejun@gmail.com>

--

Jens, this fix is not very urgent.  The bug is not likely to be
triggered easily.  I think pushing this to -mm first would be better.

Thanks.

Signed-off-by: Tejun Heo <htejun@gmail.com>

diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c
index ec27dda..701808e 100644
--- a/block/ll_rw_blk.c
+++ b/block/ll_rw_blk.c
@@ -494,7 +494,7 @@ static inline struct request *start_orde
 
 int blk_do_ordered(request_queue_t *q, struct request **rqp)
 {
-	struct request *rq = *rqp, *allowed_rq;
+	struct request *rq = *rqp;
 	int is_barrier = blk_fs_request(rq) && blk_barrier_rq(rq);
 
 	if (!q->ordseq) {
@@ -518,32 +518,26 @@ int blk_do_ordered(request_queue_t *q, s
 		}
 	}
 
+	/*
+	 * Ordered sequence in progress
+	 */
+
+	/* Special requests are not subject to ordering rules. */
+	if (!blk_fs_request(rq) &&
+	    rq != &q->pre_flush_rq && rq != &q->post_flush_rq)
+		return 1;
+
 	if (q->ordered & QUEUE_ORDERED_TAG) {
+		/* Ordered by tag.  Blocking the next barrier is enough. */
 		if (is_barrier && rq != &q->bar_rq)
 			*rqp = NULL;
-		return 1;
+	} else {
+		/* Ordered by draining.  Wait for turn. */
+		WARN_ON(blk_ordered_req_seq(rq) < blk_ordered_cur_seq(q));
+		if (blk_ordered_req_seq(rq) > blk_ordered_cur_seq(q))
+			*rqp = NULL;
 	}
 
-	switch (blk_ordered_cur_seq(q)) {
-	case QUEUE_ORDSEQ_PREFLUSH:
-		allowed_rq = &q->pre_flush_rq;
-		break;
-	case QUEUE_ORDSEQ_BAR:
-		allowed_rq = &q->bar_rq;
-		break;
-	case QUEUE_ORDSEQ_POSTFLUSH:
-		allowed_rq = &q->post_flush_rq;
-		break;
-	default:
-		allowed_rq = NULL;
-		break;
-	}
-
-	if (rq != allowed_rq &&
-	    (blk_fs_request(rq) || rq == &q->pre_flush_rq ||
-	     rq == &q->post_flush_rq))
-		*rqp = NULL;
-
 	return 1;
 }
 

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] blk: fix possible queue stall in blk_do_ordered
  2006-01-12 15:29 [PATCH] blk: fix possible queue stall in blk_do_ordered Tejun Heo
@ 2006-01-12 16:09 ` Mark Lord
  2006-01-12 16:26   ` Tejun Heo
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Lord @ 2006-01-12 16:09 UTC (permalink / raw)
  To: Tejun Heo; +Cc: axboe, linux-kernel

Tejun Heo wrote:
> Previously, if a fs request which was being drained failed and got
> requeued, blk_do_ordered() didn't allow it to be reissued, which
> causes queue stall.  This patch makes blk_do_ordered() use the
> sequence of each request to determine whether a request can be issued
> or not.  This fixes the bug and simplifies code.

What kernel(s) is this against?  The patch seems to fail on 2.6.15.

Thanks

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] blk: fix possible queue stall in blk_do_ordered
  2006-01-12 16:09 ` Mark Lord
@ 2006-01-12 16:26   ` Tejun Heo
  0 siblings, 0 replies; 3+ messages in thread
From: Tejun Heo @ 2006-01-12 16:26 UTC (permalink / raw)
  To: Mark Lord; +Cc: axboe, linux-kernel

Mark Lord wrote:
> Tejun Heo wrote:
> 
>> Previously, if a fs request which was being drained failed and got
>> requeued, blk_do_ordered() didn't allow it to be reissued, which
>> causes queue stall.  This patch makes blk_do_ordered() use the
>> sequence of each request to determine whether a request can be issued
>> or not.  This fixes the bug and simplifies code.
> 
> 
> What kernel(s) is this against?  The patch seems to fail on 2.6.15.
> 
> Thanks

It's against v2.6.15-mm2.  It's sort of a follow-up patch for the following.

http://marc.theaimsgroup.com/?l=linux-kernel&m=113707430626490&w=2

-- 
tejun

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-01-12 16:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-01-12 15:29 [PATCH] blk: fix possible queue stall in blk_do_ordered Tejun Heo
2006-01-12 16:09 ` Mark Lord
2006-01-12 16:26   ` Tejun Heo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox