diff mbox series

[5/9] blk-mq: move .queue_rq code into one helper

Message ID 20200513095443.2038859-6-ming.lei@redhat.com (mailing list archive)
State New, archived
Headers show
Series blk-mq: support batching dispatch from scheduler | expand

Commit Message

Ming Lei May 13, 2020, 9:54 a.m. UTC
Move code for queueing rq into one helper, so that blk_mq_dispatch_rq_list
gets a bit simpified, and easier to read.

No functional change.

Cc: Sagi Grimberg <sagi@grimberg.me>
Cc: Baolin Wang <baolin.wang7@gmail.com>
Cc: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
 block/blk-mq.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

Comments

Christoph Hellwig May 13, 2020, 12:38 p.m. UTC | #1
On Wed, May 13, 2020 at 05:54:39PM +0800, Ming Lei wrote:
> Move code for queueing rq into one helper, so that blk_mq_dispatch_rq_list
> gets a bit simpified, and easier to read.
> 
> No functional change.

I don't see much benefit.  Especially moving the list_del out of the
main function doesn't really help readability.
diff mbox series

Patch

diff --git a/block/blk-mq.c b/block/blk-mq.c
index c06421faa555..34fd09adb7fc 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -1220,6 +1220,17 @@  static enum prep_dispatch blk_mq_prep_dispatch_rq(struct request *rq,
 	return PREP_DISPATCH_OK;
 }
 
+static blk_status_t blk_mq_dispatch_rq(struct request *rq, bool is_last)
+{
+	struct blk_mq_queue_data bd;
+
+	list_del_init(&rq->queuelist);
+	bd.rq = rq;
+	bd.last = is_last;
+
+	return rq->q->mq_ops->queue_rq(rq->mq_hctx, &bd);
+}
+
 /*
  * Returns true if we did some work AND can potentially do more.
  */
@@ -1243,8 +1254,6 @@  bool blk_mq_dispatch_rq_list(struct blk_mq_hw_ctx *hctx, struct list_head *list,
 	 */
 	errors = queued = 0;
 	do {
-		struct blk_mq_queue_data bd;
-
 		rq = list_first_entry(list, struct request, queuelist);
 
 		WARN_ON_ONCE(hctx != rq->mq_hctx);
@@ -1252,12 +1261,7 @@  bool blk_mq_dispatch_rq_list(struct blk_mq_hw_ctx *hctx, struct list_head *list,
 		if (prep != PREP_DISPATCH_OK)
 			break;
 
-		list_del_init(&rq->queuelist);
-
-		bd.rq = rq;
-		bd.last = !!list_empty(list);
-
-		ret = q->mq_ops->queue_rq(hctx, &bd);
+		ret = blk_mq_dispatch_rq(rq, list_is_singular(list));
 		if (ret == BLK_STS_RESOURCE || ret == BLK_STS_DEV_RESOURCE) {
 			blk_mq_handle_dev_resource(rq, list);
 			break;