[PATCH 2/6] nvme-auth: do not queue authentication if the queue is not live

Sagi Grimberg sagi at grimberg.me
Thu Nov 3 14:19:31 PDT 2022


> If the queue is not connecting or live there's no point in trying
> to start authentication as we won't be able to send commands.
> So terminate the work functions directly if the controller is
> in a wrong state.
> 
> Signed-off-by: Hannes Reinecke <hare at suse.de>
> ---
>   drivers/nvme/host/auth.c | 10 ++++++++++
>   1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/nvme/host/auth.c b/drivers/nvme/host/auth.c
> index b68fb2c764f6..719c514363ee 100644
> --- a/drivers/nvme/host/auth.c
> +++ b/drivers/nvme/host/auth.c
> @@ -696,6 +696,12 @@ static void __nvme_auth_work(struct work_struct *work)
>   	size_t tl;
>   	int ret = 0;
>   
> +	if (ctrl->state != NVME_CTRL_CONNECTING &&
> +	    ctrl->state != NVME_CTRL_LIVE) {
> +		chap->error = -ENOTCONN;
> +		return;
> +	}

Why do you want this to run in CONNECTING at all? The connect itself
will authenticate...

> +
>   	chap->transaction = ctrl->transaction++;
>   	chap->status = 0;
>   	chap->error = 0;
> @@ -937,6 +943,10 @@ static void nvme_dhchap_auth_work(struct work_struct *work)
>   		container_of(work, struct nvme_ctrl, dhchap_auth_work);
>   	int ret, q;
>   
> +	if (ctrl->state != NVME_CTRL_CONNECTING &&
> +	    ctrl->state != NVME_CTRL_LIVE)
> +		return;

Same here.

> +
>   	/* Authenticate admin queue first */
>   	ret = nvme_auth_negotiate(ctrl, 0);
>   	if (ret) {



More information about the Linux-nvme mailing list