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

Hannes Reinecke hare at suse.de
Thu Nov 3 23:54:44 PDT 2022


On 11/3/22 22:19, Sagi Grimberg wrote:
> 
>> 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...
> 
Precisely. It will authenticate _using this function_ ...

>> +
>>       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.
> 
Here, however, things are different, as this function is only called 
during re-authentication (ie if someone wrote into the sysfs attributes).
This really makes sense only when the controller is live.
Will be fixing it.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke                Kernel Storage Architect
hare at suse.de                              +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Ivo Totev, Andrew
Myers, Andrew McDonald, Martje Boudien Moerman




More information about the Linux-nvme mailing list