Skip to content

Commit

Permalink
block: fix oops with block tag queueing
Browse files Browse the repository at this point in the history
commit e8939a50466fd963eb1ba9118c34b9ffb7ff6aa6
Author: Tejun Heo <tj@kernel.org>
Date:   Fri May 8 11:54:16 2009 +0900

    block: implement and enforce request peek/start/fetch

Added a BUG_ON(blk_queued_rq(req)) to the top of blk_finish_req().
Unfortunately, this checks whether req->queuelist is empty.  This list
is doing double duty both as the queue list and the tag list, so tagged
requests come in here with this not empty and boom (the tag list is
emptied by blk_queue_end_tag() lower down).

Fix this by moving the BUG_ON to below the end tag we also seem
vulnerable to this in blk_requeue_request() as well.  I think all uses
of blk_queued_rq() need auditing because the check is clearly wrong in
the tagged case.

Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
  • Loading branch information
James Bottomley authored and Jens Axboe committed May 27, 2009
1 parent 3b77f77 commit ba396a6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions block/blk-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -956,15 +956,15 @@ EXPORT_SYMBOL(blk_make_request);
*/
void blk_requeue_request(struct request_queue *q, struct request *rq)
{
BUG_ON(blk_queued_rq(rq));

blk_delete_timer(rq);
blk_clear_rq_complete(rq);
trace_block_rq_requeue(q, rq);

if (blk_rq_tagged(rq))
blk_queue_end_tag(q, rq);

BUG_ON(blk_queued_rq(rq));

elv_requeue_request(q, rq);
}
EXPORT_SYMBOL(blk_requeue_request);
Expand Down Expand Up @@ -2042,11 +2042,11 @@ static bool blk_update_bidi_request(struct request *rq, int error,
*/
static void blk_finish_request(struct request *req, int error)
{
BUG_ON(blk_queued_rq(req));

if (blk_rq_tagged(req))
blk_queue_end_tag(req->q, req);

BUG_ON(blk_queued_rq(req));

if (unlikely(laptop_mode) && blk_fs_request(req))
laptop_io_completion();

Expand Down

0 comments on commit ba396a6

Please sign in to comment.