Skip to content

Commit e715b87

Browse files
Kamaljit SinghChristoph Hellwig
authored andcommitted
nvme: add capability to connect to an administrative controller
Add capability to connect to an administrative controller by preventing ioq creation for admin-controllers. Add a nvme_admin_ctrl() to check if a controller's CNTRLTYPE indicates that it is an administrative controller and override ctrl->queue_count to 1 for admin controllers, so that only the admin queue and no I/O queues are created for an administrative controller. This override is done in nvme_init_ctrl_finish() after ctrl->cntrltype has been initialized in nvme_init_identify() so nvme_admin_ctrl() will work correctly. Doing this override in generic code (nvme_init_ctrl_finish) makes it transport agnostic and will work properly for nvme/tcp as well as for nvme/rdma. Suggested-by: Niklas Cassel <[email protected]> Reviewed-by: Damien Le Moal <[email protected]> Reviewed-by: Niklas Cassel <[email protected]> Signed-off-by: Kamaljit Singh <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]>
1 parent c71fc0f commit e715b87

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

drivers/nvme/host/core.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3158,6 +3158,11 @@ static inline bool nvme_discovery_ctrl(struct nvme_ctrl *ctrl)
31583158
return ctrl->opts && ctrl->opts->discovery_nqn;
31593159
}
31603160

3161+
static inline bool nvme_admin_ctrl(struct nvme_ctrl *ctrl)
3162+
{
3163+
return ctrl->cntrltype == NVME_CTRL_ADMIN;
3164+
}
3165+
31613166
static bool nvme_validate_cntlid(struct nvme_subsystem *subsys,
31623167
struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)
31633168
{
@@ -3670,6 +3675,17 @@ int nvme_init_ctrl_finish(struct nvme_ctrl *ctrl, bool was_suspended)
36703675
if (ret)
36713676
return ret;
36723677

3678+
if (nvme_admin_ctrl(ctrl)) {
3679+
/*
3680+
* An admin controller has one admin queue, but no I/O queues.
3681+
* Override queue_count so it only creates an admin queue.
3682+
*/
3683+
dev_dbg(ctrl->device,
3684+
"Subsystem %s is an administrative controller",
3685+
ctrl->subsys->subnqn);
3686+
ctrl->queue_count = 1;
3687+
}
3688+
36733689
ret = nvme_configure_apst(ctrl);
36743690
if (ret < 0)
36753691
return ret;

0 commit comments

Comments
 (0)