blk-mq: enable IO poll if .nr_queues of type poll > 0
PATCH 1/1 blk-mq: enable IO poll if .nr_queues of type poll > 0
The queue mapping of type poll only exists when set->map[HCTX_TYPE_POLL].nr_queues is bigger than zero, so enhance the constraint by checking .nr_queues of type poll before enabling IO poll.
Otherwise IO race & timeout can be observed when running block/007.
--- block/blk-mq.c | 3 ++- block/blk-sysfs.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)
block/blk-mq.c +2 -1
@@ -2833,7 +2833,8 @@ struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set, q->tag_set = set; q->queue_flags |=QUEUE_FLAG_MQ_DEFAULT ; -if (set->nr_maps >HCTX_TYPE_POLL ) +if (set->nr_maps >HCTX_TYPE_POLL && + set->map[HCTX_TYPE_POLL ].nr_queues)blk_queue_flag_set (QUEUE_FLAG_POLL , q);if (!(set->flags &BLK_MQ_F_SG_MERGE ))
block/blk-sysfs.c +2 -1
@@ -402,7 +402,8 @@ static ssize_t queue_poll_store(struct request_queue *q, const char *page,unsigned long poll_on;ssize_t ret; -if (!q->tag_set || q->tag_set->nr_maps <=HCTX_TYPE_POLL ) +if (!q->tag_set || q->tag_set->nr_maps <=HCTX_TYPE_POLL || + !q->tag_set->map[HCTX_TYPE_POLL ].nr_queues)return -EINVAL ; ret =queue_var_store (&poll_on, page, count);
Signature · 1 line
2.9.5
Jens Axboe
maintainerQuoted 5 lines · Ming Lei
The queue mapping of type poll only exists when set->map[HCTX_TYPE_POLL].nr_queues is bigger than zero, so enhance the constraint by checking .nr_queues of type poll before enabling IO poll.
Otherwise IO race & timeout can be observed when running block/007.
Looks good to me, but we might consider having a helper for this, since we have this check in 3 places now. But for now this is good, thanks Ming.
Signature · 1 line
Jens Axboe
Quoted 10 lines · Jens Axboe
Quoted 5 lines · Ming Lei
The queue mapping of type poll only exists when set->map[HCTX_TYPE_POLL].nr_queues is bigger than zero, so enhance the constraint by checking .nr_queues of type poll before enabling IO poll.
Otherwise IO race & timeout can be observed when running block/007.
Looks good to me, but we might consider having a helper for this, since we have this check in 3 places now. But for now this is good, thanks Ming.
Jens, if you want this I can drop the nvme patch to set nr_maps to 2 as it wouldn't be needed. Not sure which one is more elegant, but I guess Mings version is a little more fool proof.
Quoted 8 lines · Christoph Hellwig
Quoted 7 lines · Jens Axboe
Quoted 5 lines · Ming Lei
The queue mapping of type poll only exists when set->map[HCTX_TYPE_POLL].nr_queues is bigger than zero, so enhance the constraint by checking .nr_queues of type poll before enabling IO poll.
Otherwise IO race & timeout can be observed when running block/007.
Quoted 7 lines
Quoted 3 lines
Looks good to me, but we might consider having a helper for this, since we have this check in 3 places now. But for now this is good, thanks Ming.
Jens, if you want this I can drop the nvme patch to set
nr_mapsto 2 as it wouldn't be needed. Not sure which one is more elegant, but I guess Mings version is a little more fool proof.
For READ queue type, its .nr_maps can be 3 and .nr_queues is zero, so if check on the two queue type is kept as consistent, we may get good code readability, IMO.
As Jens mentioned, we may introduce blk_mq_queue_type_supported() helper to cover both.
Thanks,
Ming
Jens Axboe
maintainerQuoted 17 lines · Ming Lei
Quoted 8 lines · Christoph Hellwig
Quoted 7 lines · Jens Axboe
Quoted 5 lines · Ming Lei
The queue mapping of type poll only exists when set->map[HCTX_TYPE_POLL].nr_queues is bigger than zero, so enhance the constraint by checking .nr_queues of type poll before enabling IO poll.
Otherwise IO race & timeout can be observed when running block/007.
Quoted 7 lines
Quoted 3 lines
Looks good to me, but we might consider having a helper for this, since we have this check in 3 places now. But for now this is good, thanks Ming.
Jens, if you want this I can drop the nvme patch to set
nr_mapsto 2 as it wouldn't be needed. Not sure which one is more elegant, but I guess Mings version is a little more fool proof.
Quoted 6 lines
For READ queue type, its .nr_maps can be 3 and .nr_queues is zero, so if check on the two queue type is kept as consistent, we may get good code readability, IMO.
As Jens mentioned, we may introduce
blk_mq_queue_type_supported()helper to cover both.
I think that would be preferable.
Signature · 1 line
Jens Axboe