Skip to content

Commit 2230237

Browse files
Shaohua Liaxboe
authored andcommitted
blk-mq: blk_mq_tag_to_rq should handle flush request
flush request is special, which borrows the tag from the parent request. Hence blk_mq_tag_to_rq needs special handling to return the flush request from the tag. Signed-off-by: Shaohua Li <shli@fusionio.com> Signed-off-by: Jens Axboe <axboe@fb.com>
1 parent da52f22 commit 2230237

3 files changed

Lines changed: 13 additions & 5 deletions

File tree

‎block/blk-flush.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,10 @@ static void flush_end_io(struct request *flush_rq, int error)
223223
struct request *rq, *n;
224224
unsigned long flags = 0;
225225

226-
if (q->mq_ops)
226+
if (q->mq_ops) {
227227
spin_lock_irqsave(&q->mq_flush_lock, flags);
228+
q->flush_rq->cmd_flags = 0;
229+
}
228230

229231
running = &q->flush_queue[q->flush_running_idx];
230232
BUG_ON(q->flush_pending_idx == q->flush_running_idx);

‎block/blk-mq.c‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -541,9 +541,15 @@ void blk_mq_kick_requeue_list(struct request_queue *q)
541541
}
542542
EXPORT_SYMBOL(blk_mq_kick_requeue_list);
543543

544-
struct request *blk_mq_tag_to_rq(struct blk_mq_tags *tags, unsigned int tag)
544+
struct request *blk_mq_tag_to_rq(struct blk_mq_hw_ctx *hctx, unsigned int tag)
545545
{
546-
return tags->rqs[tag];
546+
struct request_queue *q = hctx->queue;
547+
548+
if ((q->flush_rq->cmd_flags & REQ_FLUSH_SEQ) &&
549+
q->flush_rq->tag == tag)
550+
return q->flush_rq;
551+
552+
return hctx->tags->rqs[tag];
547553
}
548554
EXPORT_SYMBOL(blk_mq_tag_to_rq);
549555

@@ -572,7 +578,7 @@ static void blk_mq_timeout_check(void *__data, unsigned long *free_tags)
572578
if (tag >= hctx->tags->nr_tags)
573579
break;
574580

575-
rq = blk_mq_tag_to_rq(hctx->tags, tag++);
581+
rq = blk_mq_tag_to_rq(hctx, tag++);
576582
if (rq->q != hctx->queue)
577583
continue;
578584
if (!test_bit(REQ_ATOM_STARTED, &rq->atomic_flags))

‎include/linux/blk-mq.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ void blk_mq_free_request(struct request *rq);
154154
bool blk_mq_can_queue(struct blk_mq_hw_ctx *);
155155
struct request *blk_mq_alloc_request(struct request_queue *q, int rw,
156156
gfp_t gfp, bool reserved);
157-
struct request *blk_mq_tag_to_rq(struct blk_mq_tags *tags, unsigned int tag);
157+
struct request *blk_mq_tag_to_rq(struct blk_mq_hw_ctx *hctx, unsigned int tag);
158158

159159
struct blk_mq_hw_ctx *blk_mq_map_queue(struct request_queue *, const int ctx_index);
160160
struct blk_mq_hw_ctx *blk_mq_alloc_single_hw_queue(struct blk_mq_tag_set *, unsigned int, int);

0 commit comments

Comments
 (0)