Skip to content

Commit cd19181

Browse files
Ming Leiaxboe
authored andcommitted
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. Cc: Jeff Moyer <jmoyer@redhat.com> Cc: Christoph Hellwig <hch@lst.de> Signed-off-by: Ming Lei <ming.lei@redhat.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 3c94d83 commit cd19181

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

block/blk-mq.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2833,7 +2833,8 @@ struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set,
28332833
q->tag_set = set;
28342834

28352835
q->queue_flags |= QUEUE_FLAG_MQ_DEFAULT;
2836-
if (set->nr_maps > HCTX_TYPE_POLL)
2836+
if (set->nr_maps > HCTX_TYPE_POLL &&
2837+
set->map[HCTX_TYPE_POLL].nr_queues)
28372838
blk_queue_flag_set(QUEUE_FLAG_POLL, q);
28382839

28392840
if (!(set->flags & BLK_MQ_F_SG_MERGE))

block/blk-sysfs.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,8 @@ static ssize_t queue_poll_store(struct request_queue *q, const char *page,
402402
unsigned long poll_on;
403403
ssize_t ret;
404404

405-
if (!q->tag_set || q->tag_set->nr_maps <= HCTX_TYPE_POLL)
405+
if (!q->tag_set || q->tag_set->nr_maps <= HCTX_TYPE_POLL ||
406+
!q->tag_set->map[HCTX_TYPE_POLL].nr_queues)
406407
return -EINVAL;
407408

408409
ret = queue_var_store(&poll_on, page, count);

0 commit comments

Comments
 (0)