diff options
-rw-r--r-- | block/blk-merge.c | 31 | ||||
-rw-r--r-- | block/blk.h | 4 |
2 files changed, 18 insertions, 17 deletions
diff --git a/block/blk-merge.c b/block/blk-merge.c index 6aa43dec5af4..3826fc32b72c 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c | |||
@@ -659,31 +659,32 @@ static void blk_account_io_merge(struct request *req) | |||
659 | } | 659 | } |
660 | 660 | ||
661 | /* | 661 | /* |
662 | * Has to be called with the request spinlock acquired | 662 | * For non-mq, this has to be called with the request spinlock acquired. |
663 | * For mq with scheduling, the appropriate queue wide lock should be held. | ||
663 | */ | 664 | */ |
664 | static int attempt_merge(struct request_queue *q, struct request *req, | 665 | static struct request *attempt_merge(struct request_queue *q, |
665 | struct request *next) | 666 | struct request *req, struct request *next) |
666 | { | 667 | { |
667 | if (!rq_mergeable(req) || !rq_mergeable(next)) | 668 | if (!rq_mergeable(req) || !rq_mergeable(next)) |
668 | return 0; | 669 | return NULL; |
669 | 670 | ||
670 | if (req_op(req) != req_op(next)) | 671 | if (req_op(req) != req_op(next)) |
671 | return 0; | 672 | return NULL; |
672 | 673 | ||
673 | /* | 674 | /* |
674 | * not contiguous | 675 | * not contiguous |
675 | */ | 676 | */ |
676 | if (blk_rq_pos(req) + blk_rq_sectors(req) != blk_rq_pos(next)) | 677 | if (blk_rq_pos(req) + blk_rq_sectors(req) != blk_rq_pos(next)) |
677 | return 0; | 678 | return NULL; |
678 | 679 | ||
679 | if (rq_data_dir(req) != rq_data_dir(next) | 680 | if (rq_data_dir(req) != rq_data_dir(next) |
680 | || req->rq_disk != next->rq_disk | 681 | || req->rq_disk != next->rq_disk |
681 | || req_no_special_merge(next)) | 682 | || req_no_special_merge(next)) |
682 | return 0; | 683 | return NULL; |
683 | 684 | ||
684 | if (req_op(req) == REQ_OP_WRITE_SAME && | 685 | if (req_op(req) == REQ_OP_WRITE_SAME && |
685 | !blk_write_same_mergeable(req->bio, next->bio)) | 686 | !blk_write_same_mergeable(req->bio, next->bio)) |
686 | return 0; | 687 | return NULL; |
687 | 688 | ||
688 | /* | 689 | /* |
689 | * If we are allowed to merge, then append bio list | 690 | * If we are allowed to merge, then append bio list |
@@ -692,7 +693,7 @@ static int attempt_merge(struct request_queue *q, struct request *req, | |||
692 | * counts here. | 693 | * counts here. |
693 | */ | 694 | */ |
694 | if (!ll_merge_requests_fn(q, req, next)) | 695 | if (!ll_merge_requests_fn(q, req, next)) |
695 | return 0; | 696 | return NULL; |
696 | 697 | ||
697 | /* | 698 | /* |
698 | * If failfast settings disagree or any of the two is already | 699 | * If failfast settings disagree or any of the two is already |
@@ -735,27 +736,27 @@ static int attempt_merge(struct request_queue *q, struct request *req, | |||
735 | /* owner-ship of bio passed from next to req */ | 736 | /* owner-ship of bio passed from next to req */ |
736 | next->bio = NULL; | 737 | next->bio = NULL; |
737 | __blk_put_request(q, next); | 738 | __blk_put_request(q, next); |
738 | return 1; | 739 | return next; |
739 | } | 740 | } |
740 | 741 | ||
741 | int attempt_back_merge(struct request_queue *q, struct request *rq) | 742 | struct request *attempt_back_merge(struct request_queue *q, struct request *rq) |
742 | { | 743 | { |
743 | struct request *next = elv_latter_request(q, rq); | 744 | struct request *next = elv_latter_request(q, rq); |
744 | 745 | ||
745 | if (next) | 746 | if (next) |
746 | return attempt_merge(q, rq, next); | 747 | return attempt_merge(q, rq, next); |
747 | 748 | ||
748 | return 0; | 749 | return NULL; |
749 | } | 750 | } |
750 | 751 | ||
751 | int attempt_front_merge(struct request_queue *q, struct request *rq) | 752 | struct request *attempt_front_merge(struct request_queue *q, struct request *rq) |
752 | { | 753 | { |
753 | struct request *prev = elv_former_request(q, rq); | 754 | struct request *prev = elv_former_request(q, rq); |
754 | 755 | ||
755 | if (prev) | 756 | if (prev) |
756 | return attempt_merge(q, prev, rq); | 757 | return attempt_merge(q, prev, rq); |
757 | 758 | ||
758 | return 0; | 759 | return NULL; |
759 | } | 760 | } |
760 | 761 | ||
761 | int blk_attempt_req_merge(struct request_queue *q, struct request *rq, | 762 | int blk_attempt_req_merge(struct request_queue *q, struct request *rq, |
@@ -767,7 +768,7 @@ int blk_attempt_req_merge(struct request_queue *q, struct request *rq, | |||
767 | if (!e->type->ops.sq.elevator_allow_rq_merge_fn(q, rq, next)) | 768 | if (!e->type->ops.sq.elevator_allow_rq_merge_fn(q, rq, next)) |
768 | return 0; | 769 | return 0; |
769 | 770 | ||
770 | return attempt_merge(q, rq, next); | 771 | return attempt_merge(q, rq, next) != NULL; |
771 | } | 772 | } |
772 | 773 | ||
773 | bool blk_rq_merge_ok(struct request *rq, struct bio *bio) | 774 | bool blk_rq_merge_ok(struct request *rq, struct bio *bio) |
diff --git a/block/blk.h b/block/blk.h index 6aa53a4aad88..4972b98d47e1 100644 --- a/block/blk.h +++ b/block/blk.h | |||
@@ -208,8 +208,8 @@ int ll_back_merge_fn(struct request_queue *q, struct request *req, | |||
208 | struct bio *bio); | 208 | struct bio *bio); |
209 | int ll_front_merge_fn(struct request_queue *q, struct request *req, | 209 | int ll_front_merge_fn(struct request_queue *q, struct request *req, |
210 | struct bio *bio); | 210 | struct bio *bio); |
211 | int attempt_back_merge(struct request_queue *q, struct request *rq); | 211 | struct request *attempt_back_merge(struct request_queue *q, struct request *rq); |
212 | int attempt_front_merge(struct request_queue *q, struct request *rq); | 212 | struct request *attempt_front_merge(struct request_queue *q, struct request *rq); |
213 | int blk_attempt_req_merge(struct request_queue *q, struct request *rq, | 213 | int blk_attempt_req_merge(struct request_queue *q, struct request *rq, |
214 | struct request *next); | 214 | struct request *next); |
215 | void blk_recalc_rq_segments(struct request *rq); | 215 | void blk_recalc_rq_segments(struct request *rq); |