Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nvme: Skip checking heads without namespaces
@ 2018-03-19 16:53 Keith Busch
  2018-03-20  8:48 ` Christoph Hellwig
  2018-03-20 12:56 ` Max Gurtovoy
  0 siblings, 2 replies; 4+ messages in thread
From: Keith Busch @ 2018-03-19 16:53 UTC (permalink / raw)


If a task is holding a reference to a namespace on a removed controller,
the head will not be released. If the same controller is added again
later, its namespaces may not be successfully added. Instead, the user
will see kernel message "Duplicate IDs for nsid <X>".

This patch fixes that by skipping heads that don't have namespaces when
considering if a new namespace is safe to add.

Reported-by: Alex Gagniuc <Alex_Gagniuc at Dellteam.com>
Cc: stable at vger.kernel.org
Signed-off-by: Keith Busch <keith.busch at intel.com>
---
 drivers/nvme/host/core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 7aeca5db7916..0b9e60861e53 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2793,6 +2793,7 @@ static int __nvme_check_ids(struct nvme_subsystem *subsys,
 
 	list_for_each_entry(h, &subsys->nsheads, entry) {
 		if (nvme_ns_ids_valid(&new->ids) &&
+		    !list_empty(&h->list) &&
 		    nvme_ns_ids_equal(&new->ids, &h->ids))
 			return -EINVAL;
 	}
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] nvme: Skip checking heads without namespaces
  2018-03-19 16:53 [PATCH] nvme: Skip checking heads without namespaces Keith Busch
@ 2018-03-20  8:48 ` Christoph Hellwig
  2018-03-20 12:56 ` Max Gurtovoy
  1 sibling, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2018-03-20  8:48 UTC (permalink / raw)


On Mon, Mar 19, 2018@10:53:50AM -0600, Keith Busch wrote:
> If a task is holding a reference to a namespace on a removed controller,
> the head will not be released. If the same controller is added again
> later, its namespaces may not be successfully added. Instead, the user
> will see kernel message "Duplicate IDs for nsid <X>".
> 
> This patch fixes that by skipping heads that don't have namespaces when
> considering if a new namespace is safe to add.

Delayed reference strike once again, sigh.

Looks fine:

Reviewed-by: Christoph Hellwig <hch at lst.de>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] nvme: Skip checking heads without namespaces
  2018-03-19 16:53 [PATCH] nvme: Skip checking heads without namespaces Keith Busch
  2018-03-20  8:48 ` Christoph Hellwig
@ 2018-03-20 12:56 ` Max Gurtovoy
  2018-03-20 17:50   ` Keith Busch
  1 sibling, 1 reply; 4+ messages in thread
From: Max Gurtovoy @ 2018-03-20 12:56 UTC (permalink / raw)




On 3/19/2018 6:53 PM, Keith Busch wrote:
> If a task is holding a reference to a namespace on a removed controller,
> the head will not be released. If the same controller is added again
> later, its namespaces may not be successfully added. Instead, the user
> will see kernel message "Duplicate IDs for nsid <X>".
> 
> This patch fixes that by skipping heads that don't have namespaces when
> considering if a new namespace is safe to add.
> 
> Reported-by: Alex Gagniuc <Alex_Gagniuc at Dellteam.com>
> Cc: stable at vger.kernel.org
> Signed-off-by: Keith Busch <keith.busch at intel.com>
> ---
>   drivers/nvme/host/core.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index 7aeca5db7916..0b9e60861e53 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -2793,6 +2793,7 @@ static int __nvme_check_ids(struct nvme_subsystem *subsys,
>   
>   	list_for_each_entry(h, &subsys->nsheads, entry) {
>   		if (nvme_ns_ids_valid(&new->ids) &&
> +		    !list_empty(&h->list) &&
>   		    nvme_ns_ids_equal(&new->ids, &h->ids))
>   			return -EINVAL;
>   	}
> 

Looks good,

Reviewed-by: Max Gurtovoy <maxg at mellanox.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] nvme: Skip checking heads without namespaces
  2018-03-20 12:56 ` Max Gurtovoy
@ 2018-03-20 17:50   ` Keith Busch
  0 siblings, 0 replies; 4+ messages in thread
From: Keith Busch @ 2018-03-20 17:50 UTC (permalink / raw)


Thannks for the reviews. Applied for 4.17.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-03-20 17:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-19 16:53 [PATCH] nvme: Skip checking heads without namespaces Keith Busch
2018-03-20  8:48 ` Christoph Hellwig
2018-03-20 12:56 ` Max Gurtovoy
2018-03-20 17:50   ` Keith Busch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox