Re: [PATCH v1 1/1] nvme: add admin controller support. prohibit ioq creation for admin & disco ctrlrs

From: Niklas Cassel
Date: Tue Apr 01 2025 - 04:05:02 EST


On Mon, Mar 31, 2025 at 09:03:11AM -0600, Keith Busch wrote:
> On Fri, Mar 28, 2025 at 02:36:40PM -0700, Kamaljit Singh wrote:
> > -static inline bool nvme_discovery_ctrl(struct nvme_ctrl *ctrl)
> > -{
> > - return ctrl->opts && ctrl->opts->discovery_nqn;
> > -}
> > -
>
> I suppose it's fine to rename this function with an nvmf_ prefix, but
> it's not really related to the rest of the patch and makes the diff
> larger than necessary.
>
> > + /* An admin or discovery controller has one admin queue, but no I/O queues */
> > + if (nvme_admin_ctrl(&ctrl->ctrl) || nvmf_discovery_ctrl(&ctrl->ctrl)) {
> > + ctrl->ctrl.queue_count = 1;
> > + } else if (ctrl->ctrl.queue_count < 2) {
> > + /* I/O controller with no I/O queues is not allowed */
> > + ret = -EOPNOTSUPP;
> > + dev_err(ctrl->ctrl.device,
> > + "I/O controller doesn't allow zero I/O queues!\n");
> > + goto destroy_admin;
> > + }
>
> The queue_count comes from the user. If the user provides a bad value
> for an IO controller, you're erroring. If they provide a bad value for a
> discovery or admin controller, you override the value. Why the different
> behavior?
>

Good question.

My initial proposal was simply to override the user provided value
to 1 (admin queue only) in case of admin (or discovery) controller.

The check for queue_count < 2 should be in a separate patch, if we
want that check at all. But to be honest, the code did previously
allow an I/O controller with just the admin queue and no I/O queues.
Thus, without a commit message explaining clearly why we should start
to disallow an I/O controller with just the admin queue, I think that
additional check is wrong.


Kind regards,
Niklas