[v2,01/11] block: factor out requeue handling from dispatch code
diff mbox series

Message ID 20200324152454.4954-2-johannes.thumshirn@wdc.com
State New
Headers show
Series
  • Introduce Zone Append for writing to zoned block devices
Related show

Commit Message

Johannes Thumshirn March 24, 2020, 3:24 p.m. UTC
Factor out the requeue handling from the dispatch code, this will make
subsequent addition of different requeueing schemes easier.

Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
 block/blk-mq.c | 29 ++++++++++++++++++-----------
 1 file changed, 18 insertions(+), 11 deletions(-)

Comments

Christoph Hellwig March 25, 2020, 8:40 a.m. UTC | #1
On Wed, Mar 25, 2020 at 12:24:44AM +0900, Johannes Thumshirn wrote:
> Factor out the requeue handling from the dispatch code, this will make
> subsequent addition of different requeueing schemes easier.
> 
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> Reviewed-by: Christoph Hellwig <hch@lst.de>

Jens, can you pick this up?  I think it already is a nice improvement
even without the rest of the series.
Jens Axboe March 25, 2020, 3:40 p.m. UTC | #2
On 3/25/20 2:40 AM, Christoph Hellwig wrote:
> On Wed, Mar 25, 2020 at 12:24:44AM +0900, Johannes Thumshirn wrote:
>> Factor out the requeue handling from the dispatch code, this will make
>> subsequent addition of different requeueing schemes easier.
>>
>> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
>> Reviewed-by: Christoph Hellwig <hch@lst.de>
> 
> Jens, can you pick this up?  I think it already is a nice improvement
> even without the rest of the series.

Sure, applied for 5.7.

Patch
diff mbox series

diff --git a/block/blk-mq.c b/block/blk-mq.c
index 5b2e6550e0b6..745ec592a513 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -1178,6 +1178,23 @@  static void blk_mq_update_dispatch_busy(struct blk_mq_hw_ctx *hctx, bool busy)
 
 #define BLK_MQ_RESOURCE_DELAY	3		/* ms units */
 
+static void blk_mq_handle_dev_resource(struct request *rq,
+				       struct list_head *list)
+{
+	struct request *next =
+		list_first_entry_or_null(list, struct request, queuelist);
+
+	/*
+	 * If an I/O scheduler has been configured and we got a driver tag for
+	 * the next request already, free it.
+	 */
+	if (next)
+		blk_mq_put_driver_tag(next);
+
+	list_add(&rq->queuelist, list);
+	__blk_mq_requeue_request(rq);
+}
+
 /*
  * Returns true if we did some work AND can potentially do more.
  */
@@ -1245,17 +1262,7 @@  bool blk_mq_dispatch_rq_list(struct request_queue *q, struct list_head *list,
 
 		ret = q->mq_ops->queue_rq(hctx, &bd);
 		if (ret == BLK_STS_RESOURCE || ret == BLK_STS_DEV_RESOURCE) {
-			/*
-			 * If an I/O scheduler has been configured and we got a
-			 * driver tag for the next request already, free it
-			 * again.
-			 */
-			if (!list_empty(list)) {
-				nxt = list_first_entry(list, struct request, queuelist);
-				blk_mq_put_driver_tag(nxt);
-			}
-			list_add(&rq->queuelist, list);
-			__blk_mq_requeue_request(rq);
+			blk_mq_handle_dev_resource(rq, list);
 			break;
 		}