From: Hannes Reinecke <hare@suse.de>
To: Daniel Wagner <dwagner@suse.de>,
Dan Carpenter <dan.carpenter@linaro.org>
Cc: linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org,
linux-block@vger.kernel.org, Chaitanya Kulkarni <kch@nvidia.com>,
Shin'ichiro Kawasaki <shinichiro@fastmail.com>,
Sagi Grimberg <sagi@grimberg.me>,
James Smart <jsmart2021@gmail.com>
Subject: Re: [PATCH v2 4/5] nvme-fc: Make initial connect attempt synchronous
Date: Tue, 27 Jun 2023 08:51:49 +0200 [thread overview]
Message-ID: <9b01b4b3-0beb-4159-1ce9-4ed4b531d7a6@suse.de> (raw)
In-Reply-To: <17321e5d-3744-dd7c-5ed9-cecf055ada39@suse.de>
On 6/27/23 08:39, Hannes Reinecke wrote:
> On 6/27/23 08:18, Daniel Wagner wrote:
>> On Mon, Jun 26, 2023 at 02:33:18PM +0300, Dan Carpenter wrote:
>>>> @@ -2943,6 +2943,8 @@ nvme_fc_create_io_queues(struct nvme_fc_ctrl
>>>> *ctrl)
>>>> /* force put free routine to ignore io queues */
>>>> ctrl->ctrl.tagset = NULL;
>>>> + if (ret > 0)
>>>> + ret = -EIO;
>>>
>>> All these checks for ret > 0 make me unhappy. I don't understand how
>>> they are a part of the commit.
>>
>> We have two types of error message types in the nvme subsystem. The
>> negative
>> values are the usual ones and positive ones are nvme protocol errors.
>>
>> For example if the authentication fails because of invalid credentials
>> when
>> doing the authentication nvmf_connect_admin_queue() will return a
>> value of
>> NVME_SC_AUTH_REQUIRED. This is also the value which gets propagated to
>> this
>> point here. The problem is any positive error code is interpreted as a
>> valid
>> pointer later in the code, which results in a crash.
>>
>>> I have tried to look at the context and I think maybe you are working
>>> around the fact that qla_nvme_ls_req() returns QLA_FUNCTION_FAILED on
>>> error.
>>
>> The auth blktests are exercising the error path here and that's why I
>> added
>> this check. BTW, we already use in other places, this is not
>> completely new in
>> this subsystem.
>>
>>> Also the qla_nvme_ls_req() function EINVAL on error. I just wrote a
>>> commit message saying that none of the callers cared but I missed that
>>> apparently gets returned to nvme_fc_init_ctrl(). :/
>>> https://lore.kernel.org/all/49866d28-4cfe-47b0-842b-78f110e61aab@moroto.mountain/
>>
>> Thank!
>>
>>> Let's just fix qla_nvme_ls_req() instead of working around it here.
>>>
>>> And let's add a WARN_ON_ONCE() somewhere to prevent future bugs.
>>
>> This makes sense for the driver APIs. Though for the core nvme
>> subsystem this
>> needs to be discusses/redesigned how to handle the protocol errors first.
>>
> I would stick with the 'normal' nvme syntax of having negative errors as
> internal errors (ie errnos), '0' for no error, and positive numbers as
> NVMe protocol errors.
> As such I would also advocate to not map NVMe protocol errors onto error
> numbers but rather fix the callers to not do a pointer conversion.
>
Aw. Now I see it.
It's the ->create_ctrl() callback which will always return a controller
pointer or an error value.
If we were to return a protocol error we would need to stick it into the
controller structure itself. But if we doing that then we'll be ending
up with a non-existing controller, ie we'd be returning a structure for
a dead controller. Not exactly pretty, but it would allow us to improve
the userland API to return the NVMe protocol error by reading from the
fabrics device; the controller structure itself would be cleaned up when
closing that device.
Hmm.
Cheers,
Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
hare@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
next prev parent reply other threads:[~2023-06-27 6:51 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-20 13:37 [PATCH v2 0/5] nvme-fc: Fix blktests hangers Daniel Wagner
2023-06-20 13:37 ` [PATCH v2 1/5] nvme-fc: Do not wait in vain when unloading module Daniel Wagner
2023-06-20 13:37 ` [PATCH v2 2/5] nvme-fcloop: queue work items correctly Daniel Wagner
2023-06-20 13:37 ` [PATCH v2 3/5] nvmet-fcloop: Remove remote port from list when unlinking Daniel Wagner
2023-06-20 13:37 ` [PATCH v2 4/5] nvme-fc: Make initial connect attempt synchronous Daniel Wagner
2023-06-26 10:59 ` Dan Carpenter
2023-06-26 11:33 ` Dan Carpenter
2023-06-27 6:18 ` Daniel Wagner
2023-06-27 6:39 ` Hannes Reinecke
2023-06-27 6:51 ` Hannes Reinecke [this message]
2023-07-01 12:11 ` James Smart
2023-07-06 12:07 ` Daniel Wagner
2023-07-11 22:47 ` James Smart
2023-07-12 6:50 ` Hannes Reinecke
2023-07-13 20:35 ` Ewan Milne
2023-06-20 13:37 ` [PATCH v2 5/5] nvme-fc: do no free ctrl opts Daniel Wagner
2023-06-30 13:33 ` [PATCH v2 0/5] nvme-fc: Fix blktests hangers Ewan Milne
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9b01b4b3-0beb-4159-1ce9-4ed4b531d7a6@suse.de \
--to=hare@suse.de \
--cc=dan.carpenter@linaro.org \
--cc=dwagner@suse.de \
--cc=jsmart2021@gmail.com \
--cc=kch@nvidia.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
--cc=shinichiro@fastmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).