So that we can reuse __elv_merge() to merge bio into requests from sw queue in the following patches. Signed-off-by: Ming Lei <ming.lei@xxxxxxxxxx> --- block/elevator.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/block/elevator.c b/block/elevator.c index 7423e9c9cb27..4ac437b5fc0c 100644 --- a/block/elevator.c +++ b/block/elevator.c @@ -409,8 +409,9 @@ void elv_dispatch_add_tail(struct request_queue *q, struct request *rq) } EXPORT_SYMBOL(elv_dispatch_add_tail); -enum elv_merge elv_merge(struct request_queue *q, struct request **req, - struct bio *bio) +static enum elv_merge __elv_merge(struct request_queue *q, + struct request **req, struct bio *bio, + struct hlist_head *hash, struct request *last_merge) { struct elevator_queue *e = q->elevator; struct request *__rq; @@ -427,11 +428,11 @@ enum elv_merge elv_merge(struct request_queue *q, struct request **req, /* * First try one-hit cache. */ - if (q->last_merge && elv_bio_merge_ok(q->last_merge, bio)) { - enum elv_merge ret = blk_try_merge(q->last_merge, bio); + if (last_merge && elv_bio_merge_ok(last_merge, bio)) { + enum elv_merge ret = blk_try_merge(last_merge, bio); if (ret != ELEVATOR_NO_MERGE) { - *req = q->last_merge; + *req = last_merge; return ret; } } @@ -442,7 +443,7 @@ enum elv_merge elv_merge(struct request_queue *q, struct request **req, /* * See if our hash lookup can find a potential backmerge. */ - __rq = elv_rqhash_find(q, bio->bi_iter.bi_sector); + __rq = rqhash_find(hash, bio->bi_iter.bi_sector); if (__rq && elv_bio_merge_ok(__rq, bio)) { *req = __rq; return ELEVATOR_BACK_MERGE; @@ -456,6 +457,12 @@ enum elv_merge elv_merge(struct request_queue *q, struct request **req, return ELEVATOR_NO_MERGE; } +enum elv_merge elv_merge(struct request_queue *q, struct request **req, + struct bio *bio) +{ + return __elv_merge(q, req, bio, q->elevator->hash, q->last_merge); +} + /* * Attempt to do an insertion back merge. Only check for the case where * we can append 'rq' to an existing request, so we can throw 'rq' away -- 2.9.5