All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.de>
To: Sagi Grimberg <sagi@grimberg.me>, Keith Busch <kbusch@kernel.org>
Cc: Christoph Hellwig <hch@lst.de>, Keith Busch <keith.busch@wdc.com>,
	linux-nvme@lists.infradead.org
Subject: Re: [PATCH] nvme: allow to re-attach namespaces after all paths are down
Date: Wed, 12 May 2021 08:05:38 +0200	[thread overview]
Message-ID: <01ce227a-2f1f-f4dd-d3fc-c179a1940464@suse.de> (raw)
In-Reply-To: <0d604ca8-ddf0-574a-2226-025d54e52344@grimberg.me>

On 5/11/21 7:02 PM, Sagi Grimberg wrote:
> 
>>>>> @@ -3605,16 +3608,26 @@ static int nvme_init_ns_head(struct nvme_ns 
>>>>> *ns, unsigned nsid,
>>>>>           head->shared = is_shared;
>>>>>       } else {
>>>>>           ret = -EINVAL;
>>>>> -        if (!is_shared || !head->shared) {
>>>>> -            dev_err(ctrl->device,
>>>>> -                "Duplicate unshared namespace %d\n", nsid);
>>>>> -            goto out_put_ns_head;
>>>>> -        }
>>>>> -        if (!nvme_ns_ids_equal(&head->ids, ids)) {
>>>>> -            dev_err(ctrl->device,
>>>>> -                "IDs don't match for shared namespace %d\n",
>>>>> +        /*
>>>>> +         * If multipath is enabled we might hit an ns head with no
>>>>> +         * paths, but that doesn't indicate it's a shared namespace.
>>>>> +         */
>>>>> +        if (!nvme_ns_head_multipath(head) ||
>>>>> +            !list_empty(&head->list)) {
>>>>> +            if (!is_shared || !head->shared) {
>>>>> +                dev_err(ctrl->device,
>>>>> +                    "Duplicate unshared namespace %d\n", nsid);
>>>>> +                goto out_put_ns_head;
>>>>> +            }
>>>>
>>>> If not multipath, then it is not shared. The above will fail attaching
>>>> single-path namespaces to a known head.
>>>>
>>>> The rest is similar to something I was working on too, though, so I
>>>> think it's the right direction.
>>>>
>>>>
>>>>> +            if (!nvme_ns_ids_equal(&head->ids, ids)) {
>>>>> +                dev_err(ctrl->device,
>>>>> +                    "IDs don't match for shared namespace %d\n",
>>>>>                       nsid);
>>>>> -            goto out_put_ns_head;
>>>>> +                goto out_put_ns_head;
>>>>> +            }
>>>>> +        } else {
>>>>> +            /* But the ids might have changed, so reset them */
>>>>> +            head->ids = *ids;
>>>>>           }
>>>>>       }
>>>>> @@ -3764,8 +3777,6 @@ static void nvme_ns_remove(struct nvme_ns *ns)
>>>>>       mutex_lock(&ns->ctrl->subsys->lock);
>>>>>       list_del_rcu(&ns->siblings);
>>>>> -    if (list_empty(&ns->head->list))
>>>>> -        list_del_init(&ns->head->entry);
>>>
>>> Hannes, you sent a patch like this before, my comment was that a nshead
>>> should be removed before the final reference (which who knows when it
>>> will ever arrive) as if a nsid were to be reused by the controller for
>>> a different namespace then we'd reject it so I'm not sure how this 
>>> helps?
>>>
>>
>> But we _need_ to have the nshead available in the linked list if we 
>> ever want to re-attach a namespace after reconnecting the controller.
> 
> Again, this is a queue_if_no_path functionality, this sequence is 
> correct for that.
> 

We so need to have a face-to-face meeting for this will all concerned 
parties ...

Why do we need queue_if_no_path for this?

We do _not_ queue I/O in any shape or form; in fact, MD will register 
I/O errors on the failed nshead just fine. And my understanding for 
'queue_if_no_path' is that I/O will be held until the underlying paths 
gets reattached. But this is _not_ what this patch does.

This patch merely deals with the situation when a controller is 
reattached after an all-paths-removed scenario.
And as the nshead still _is_ present we should use it, precisely to 
avoid the situation where the NSID changes underneath us.

>> And we should be able to catch the 'reuse namespace' issue by checking 
>> the contents of the nsids field, which we keep attached to the nshead.
> 
> Well, you may be right, what I'm concerned about is that a new namespace
> may be falsely identified as the same namespace because it is 
> re-attaching to a lingering mounted mpath device.

Please check v3. Your concern should be addressed there.

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: Felix Imendörffer

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

  reply	other threads:[~2021-05-12  6:06 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-10 14:49 [PATCH] nvme: allow to re-attach namespaces after all paths are down Hannes Reinecke
2021-05-10 15:53 ` Keith Busch
2021-05-10 22:25   ` Sagi Grimberg
2021-05-11  5:57     ` Hannes Reinecke
2021-05-11 17:02       ` Sagi Grimberg
2021-05-12  6:05         ` Hannes Reinecke [this message]
2021-05-11 21:37     ` Keith Busch
2021-05-12 13:18       ` Hannes Reinecke
2021-05-12 20:51         ` Sagi Grimberg
2021-05-11  5:29   ` Hannes Reinecke

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=01ce227a-2f1f-f4dd-d3fc-c179a1940464@suse.de \
    --to=hare@suse.de \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=keith.busch@wdc.com \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.