Skip to content

Commit 2318373

Browse files
committed
Merge branch 'for-6.11/block' into for-next
* for-6.11/block: block/mq-deadline: Fix the tag reservation code block: Call .limit_depth() after .hctx has been set
2 parents f759ab2 + 39823b4 commit 2318373

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

block/blk-mq.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,10 @@ static struct request *__blk_mq_alloc_requests(struct blk_mq_alloc_data *data)
448448
if (data->cmd_flags & REQ_NOWAIT)
449449
data->flags |= BLK_MQ_REQ_NOWAIT;
450450

451+
retry:
452+
data->ctx = blk_mq_get_ctx(q);
453+
data->hctx = blk_mq_map_queue(q, data->cmd_flags, data->ctx);
454+
451455
if (q->elevator) {
452456
/*
453457
* All requests use scheduler tags when an I/O scheduler is
@@ -469,13 +473,9 @@ static struct request *__blk_mq_alloc_requests(struct blk_mq_alloc_data *data)
469473
if (ops->limit_depth)
470474
ops->limit_depth(data->cmd_flags, data);
471475
}
472-
}
473-
474-
retry:
475-
data->ctx = blk_mq_get_ctx(q);
476-
data->hctx = blk_mq_map_queue(q, data->cmd_flags, data->ctx);
477-
if (!(data->rq_flags & RQF_SCHED_TAGS))
476+
} else {
478477
blk_mq_tag_busy(data->hctx);
478+
}
479479

480480
if (data->flags & BLK_MQ_REQ_RESERVED)
481481
data->rq_flags |= RQF_RESV;

block/mq-deadline.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,20 @@ static struct request *dd_dispatch_request(struct blk_mq_hw_ctx *hctx)
487487
return rq;
488488
}
489489

490+
/*
491+
* 'depth' is a number in the range 1..INT_MAX representing a number of
492+
* requests. Scale it with a factor (1 << bt->sb.shift) / q->nr_requests since
493+
* 1..(1 << bt->sb.shift) is the range expected by sbitmap_get_shallow().
494+
* Values larger than q->nr_requests have the same effect as q->nr_requests.
495+
*/
496+
static int dd_to_word_depth(struct blk_mq_hw_ctx *hctx, unsigned int qdepth)
497+
{
498+
struct sbitmap_queue *bt = &hctx->sched_tags->bitmap_tags;
499+
const unsigned int nrr = hctx->queue->nr_requests;
500+
501+
return ((qdepth << bt->sb.shift) + nrr - 1) / nrr;
502+
}
503+
490504
/*
491505
* Called by __blk_mq_alloc_request(). The shallow_depth value set by this
492506
* function is used by __blk_mq_get_tag().
@@ -503,7 +517,7 @@ static void dd_limit_depth(blk_opf_t opf, struct blk_mq_alloc_data *data)
503517
* Throttle asynchronous requests and writes such that these requests
504518
* do not block the allocation of synchronous requests.
505519
*/
506-
data->shallow_depth = dd->async_depth;
520+
data->shallow_depth = dd_to_word_depth(data->hctx, dd->async_depth);
507521
}
508522

509523
/* Called by blk_mq_update_nr_requests(). */
@@ -513,9 +527,9 @@ static void dd_depth_updated(struct blk_mq_hw_ctx *hctx)
513527
struct deadline_data *dd = q->elevator->elevator_data;
514528
struct blk_mq_tags *tags = hctx->sched_tags;
515529

516-
dd->async_depth = max(1UL, 3 * q->nr_requests / 4);
530+
dd->async_depth = q->nr_requests;
517531

518-
sbitmap_queue_min_shallow_depth(&tags->bitmap_tags, dd->async_depth);
532+
sbitmap_queue_min_shallow_depth(&tags->bitmap_tags, 1);
519533
}
520534

521535
/* Called by blk_mq_init_hctx() and blk_mq_init_sched(). */

0 commit comments

Comments
 (0)