linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Israel Rukshin <israelr@mellanox.com>
To: Sagi Grimberg <sagi@grimberg.me>,
	Linux-nvme <linux-nvme@lists.infradead.org>,
	Christoph Hellwig <hch@lst.de>
Cc: Max Gurtovoy <maxg@mellanox.com>, Shlomi Nimrodi <shlomin@mellanox.com>
Subject: Re: [PATCH 6/7] nvme-rdma: Add warning on state change failure at nvme_rdma_setup_ctrl
Date: Wed, 25 Mar 2020 12:07:40 +0200	[thread overview]
Message-ID: <660765ef-6394-28b6-279c-78656cdc2771@mellanox.com> (raw)
In-Reply-To: <b49bee23-3041-9e35-5359-efbc861be595@grimberg.me>

On 3/25/2020 2:19 AM, Sagi Grimberg wrote:
>
>> The transition to LIVE state should not fail in case of a new 
>> controller.
>> Moving to DELETING state before nvme_tcp_create_ctrl() allocates all the
>> resources may leads to NULL dereference at teardown flow (e.g., IO 
>> tagset,
>> admin_q, connect_q).
>>
>> Signed-off-by: Israel Rukshin <israelr@mellanox.com>
>> Reviewed-by: Max Gurtovoy <maxg@mellanox.com>
>> Reviewed-by: Christoph Hellwig <hch@lst.de>
>> ---
>>   drivers/nvme/host/rdma.c | 7 ++++++-
>>   1 file changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c
>> index c99a882..3ae3011 100644
>> --- a/drivers/nvme/host/rdma.c
>> +++ b/drivers/nvme/host/rdma.c
>> @@ -1022,8 +1022,13 @@ static int nvme_rdma_setup_ctrl(struct 
>> nvme_rdma_ctrl *ctrl, bool new)
>>         changed = nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_LIVE);
>>       if (!changed) {
>> -        /* state change failure is ok if we're in DELETING state */
>> +        /*
>> +         * state change failure is ok if we're in DELETING state,
>> +         * unless we're during creation of a new controller to
>> +         * avoid races with teardown flow.
>> +         */
>>           WARN_ON_ONCE(ctrl->ctrl.state != NVME_CTRL_DELETING);
>> +        WARN_ON_ONCE(new);
>>           ret = -EINVAL;
>
> I still don't understand this. Why are we warning on new controller?
>
> Are you saying that a the state change must succeed in case its
> a new controller? because if its expected to not succeed in case
> of a failure then there is no point of the warning.
>
> I am missing something here..
Yes, the state change must succeed in case of a new controller.

Moving to DELETING state on new controller is forbidden, to avoid races 
with delete flow.

The state machine allows us to move to DELETING state from CONNECTING state,

but the io tagest for example may not be allocated yet which may cause a 
crash at the delete function.


_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

  reply	other threads:[~2020-03-25 10:07 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-24 15:29 [PATCH 0/7 V3] nvme: Fixes for deleting a ctrl before it was created Israel Rukshin
2020-03-24 15:29 ` [PATCH 1/7] nvme: Remove unused return code from nvme_delete_ctrl_sync Israel Rukshin
2020-03-24 15:29 ` [PATCH 2/7] nvme-pci: Re-order nvme_pci_free_ctrl Israel Rukshin
2020-03-24 15:42   ` Christoph Hellwig
2020-03-24 15:29 ` [PATCH 3/7] nvme: Fix ctrl use-after-free during sysfs deletion Israel Rukshin
2020-03-24 15:42   ` Christoph Hellwig
2020-03-24 15:29 ` [PATCH 4/7] nvme: Make nvme_uninit_ctrl symmetric to nvme_init_ctrl Israel Rukshin
2020-03-24 15:42   ` Christoph Hellwig
2020-03-24 15:29 ` [PATCH 5/7] nvme: Fix controller creation races with teardown flow Israel Rukshin
2020-08-19 23:16   ` James Smart
2020-08-21  0:28     ` Sagi Grimberg
2020-03-24 15:29 ` [PATCH 6/7] nvme-rdma: Add warning on state change failure at nvme_rdma_setup_ctrl Israel Rukshin
2020-03-25  0:19   ` Sagi Grimberg
2020-03-25 10:07     ` Israel Rukshin [this message]
2020-03-24 15:29 ` [PATCH 7/7] nvme-tcp: Add warning on state change failure at nvme_tcp_setup_ctrl Israel Rukshin
2020-03-24 16:17 ` [PATCH 0/7 V3] nvme: Fixes for deleting a ctrl before it was created Keith Busch

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=660765ef-6394-28b6-279c-78656cdc2771@mellanox.com \
    --to=israelr@mellanox.com \
    --cc=hch@lst.de \
    --cc=linux-nvme@lists.infradead.org \
    --cc=maxg@mellanox.com \
    --cc=sagi@grimberg.me \
    --cc=shlomin@mellanox.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).