Commit 9c558734 authored by Jens Axboe's avatar Jens Axboe

blk-mq: abstract out blk-mq-sched rq list iteration bio merge helper

No functional changes in this patch, just a prep patch for utilizing
this in an IO scheduler.
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
Reviewed-by: default avatarOmar Sandoval <osandov@fb.com>
parent 5de815a7
...@@ -268,19 +268,16 @@ bool blk_mq_sched_try_merge(struct request_queue *q, struct bio *bio, ...@@ -268,19 +268,16 @@ bool blk_mq_sched_try_merge(struct request_queue *q, struct bio *bio,
EXPORT_SYMBOL_GPL(blk_mq_sched_try_merge); EXPORT_SYMBOL_GPL(blk_mq_sched_try_merge);
/* /*
* Reverse check our software queue for entries that we could potentially * Iterate list of requests and see if we can merge this bio with any
* merge with. Currently includes a hand-wavy stop count of 8, to not spend * of them.
* too much time checking for merges.
*/ */
static bool blk_mq_attempt_merge(struct request_queue *q, bool blk_mq_bio_list_merge(struct request_queue *q, struct list_head *list,
struct blk_mq_ctx *ctx, struct bio *bio) struct bio *bio)
{ {
struct request *rq; struct request *rq;
int checked = 8; int checked = 8;
lockdep_assert_held(&ctx->lock); list_for_each_entry_reverse(rq, list, queuelist) {
list_for_each_entry_reverse(rq, &ctx->rq_list, queuelist) {
bool merged = false; bool merged = false;
if (!checked--) if (!checked--)
...@@ -305,13 +302,30 @@ static bool blk_mq_attempt_merge(struct request_queue *q, ...@@ -305,13 +302,30 @@ static bool blk_mq_attempt_merge(struct request_queue *q,
continue; continue;
} }
if (merged)
ctx->rq_merged++;
return merged; return merged;
} }
return false; return false;
} }
EXPORT_SYMBOL_GPL(blk_mq_bio_list_merge);
/*
* Reverse check our software queue for entries that we could potentially
* merge with. Currently includes a hand-wavy stop count of 8, to not spend
* too much time checking for merges.
*/
static bool blk_mq_attempt_merge(struct request_queue *q,
struct blk_mq_ctx *ctx, struct bio *bio)
{
lockdep_assert_held(&ctx->lock);
if (blk_mq_bio_list_merge(q, &ctx->rq_list, bio)) {
ctx->rq_merged++;
return true;
}
return false;
}
bool __blk_mq_sched_bio_merge(struct request_queue *q, struct bio *bio) bool __blk_mq_sched_bio_merge(struct request_queue *q, struct bio *bio)
{ {
......
...@@ -259,7 +259,8 @@ void blk_mq_add_to_requeue_list(struct request *rq, bool at_head, ...@@ -259,7 +259,8 @@ void blk_mq_add_to_requeue_list(struct request *rq, bool at_head,
void blk_mq_kick_requeue_list(struct request_queue *q); void blk_mq_kick_requeue_list(struct request_queue *q);
void blk_mq_delay_kick_requeue_list(struct request_queue *q, unsigned long msecs); void blk_mq_delay_kick_requeue_list(struct request_queue *q, unsigned long msecs);
void blk_mq_complete_request(struct request *rq); void blk_mq_complete_request(struct request *rq);
bool blk_mq_bio_list_merge(struct request_queue *q, struct list_head *list,
struct bio *bio);
bool blk_mq_queue_stopped(struct request_queue *q); bool blk_mq_queue_stopped(struct request_queue *q);
void blk_mq_stop_hw_queue(struct blk_mq_hw_ctx *hctx); void blk_mq_stop_hw_queue(struct blk_mq_hw_ctx *hctx);
void blk_mq_start_hw_queue(struct blk_mq_hw_ctx *hctx); void blk_mq_start_hw_queue(struct blk_mq_hw_ctx *hctx);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment