Skip to content

Commit 376f7ef

Browse files
Christoph Hellwigaxboe
authored andcommitted
block: only allow polling if a poll queue_map exists
This avoids having to have differnet mq_ops for different setups with or without poll queues. Reviewed-by: Sagi Grimberg <sagi@grimberg.me> Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 529262d commit 376f7ef

2 files changed

Lines changed: 10 additions & 21 deletions

File tree

‎block/blk-sysfs.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ 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->mq_ops || !q->mq_ops->poll)
405+
if (!q->tag_set || q->tag_set->nr_maps <= HCTX_TYPE_POLL)
406406
return -EINVAL;
407407

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

‎drivers/nvme/host/pci.c‎

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1602,22 +1602,15 @@ static const struct blk_mq_ops nvme_mq_admin_ops = {
16021602
.timeout = nvme_timeout,
16031603
};
16041604

1605-
#define NVME_SHARED_MQ_OPS \
1606-
.queue_rq = nvme_queue_rq, \
1607-
.commit_rqs = nvme_commit_rqs, \
1608-
.complete = nvme_pci_complete_rq, \
1609-
.init_hctx = nvme_init_hctx, \
1610-
.init_request = nvme_init_request, \
1611-
.map_queues = nvme_pci_map_queues, \
1612-
.timeout = nvme_timeout \
1613-
16141605
static const struct blk_mq_ops nvme_mq_ops = {
1615-
NVME_SHARED_MQ_OPS,
1616-
};
1617-
1618-
static const struct blk_mq_ops nvme_mq_poll_ops = {
1619-
NVME_SHARED_MQ_OPS,
1620-
.poll = nvme_poll,
1606+
.queue_rq = nvme_queue_rq,
1607+
.complete = nvme_pci_complete_rq,
1608+
.commit_rqs = nvme_commit_rqs,
1609+
.init_hctx = nvme_init_hctx,
1610+
.init_request = nvme_init_request,
1611+
.map_queues = nvme_pci_map_queues,
1612+
.timeout = nvme_timeout,
1613+
.poll = nvme_poll,
16211614
};
16221615

16231616
static void nvme_dev_remove_admin(struct nvme_dev *dev)
@@ -2304,11 +2297,7 @@ static int nvme_dev_add(struct nvme_dev *dev)
23042297
int ret;
23052298

23062299
if (!dev->ctrl.tagset) {
2307-
if (dev->io_queues[HCTX_TYPE_POLL])
2308-
dev->tagset.ops = &nvme_mq_poll_ops;
2309-
else
2310-
dev->tagset.ops = &nvme_mq_ops;
2311-
2300+
dev->tagset.ops = &nvme_mq_ops;
23122301
dev->tagset.nr_hw_queues = dev->online_queues - 1;
23132302
dev->tagset.nr_maps = HCTX_MAX_TYPES;
23142303
dev->tagset.timeout = NVME_IO_TIMEOUT;

0 commit comments

Comments
 (0)