linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] nvme/target: Change max_nsid in subsystem due to ns_disable if needed
@ 2017-10-10 15:59 roys
  2017-10-11 11:40 ` Sagi Grimberg
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: roys @ 2017-10-10 15:59 UTC (permalink / raw)


From: Roy Shterman <roys@lightbitslabs.com>

In case we disable namespaces which has the nsid like
subsystem max_nsid we need to search for the next largest nsid
in this subsystem. If the subsystem don't has more namespaces
we set it to 0, else we take nsid from the last namespace in
namespaces list because the list is sorted while inserting.

Signed-off-by: Roy Shterman <roys at lightbitslabs.com>
---
 drivers/nvme/target/core.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
index eb9399a..e996972 100644
--- a/drivers/nvme/target/core.c
+++ b/drivers/nvme/target/core.c
@@ -334,6 +334,17 @@ void nvmet_ns_disable(struct nvmet_ns *ns)
 
 	ns->enabled = false;
 	list_del_rcu(&ns->dev_link);
+
+	if (ns->nsid == subsys->max_nsid) {
+		if (list_empty(&subsys->namespaces)) {
+			subsys->max_nsid = 0;
+		} else {
+			struct nvmet_ns *ns = list_last_entry(&subsys->namespaces, struct nvmet_ns, entry);
+
+			subsys->max_nsid = ns->nsid;
+		}
+	}
+
 	mutex_unlock(&subsys->lock);
 
 	/*
-- 
2.7.4

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

* [PATCH] nvme/target: Change max_nsid in subsystem due to ns_disable if needed
  2017-10-10 15:59 [PATCH] nvme/target: Change max_nsid in subsystem due to ns_disable if needed roys
@ 2017-10-11 11:40 ` Sagi Grimberg
  2017-10-14 18:41 ` Max Gurtovoy
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Sagi Grimberg @ 2017-10-11 11:40 UTC (permalink / raw)


Looks good,

Reviewed-by: Sagi Grimberg <sagi at rimberg.me>

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

* [PATCH] nvme/target: Change max_nsid in subsystem due to ns_disable if needed
  2017-10-10 15:59 [PATCH] nvme/target: Change max_nsid in subsystem due to ns_disable if needed roys
  2017-10-11 11:40 ` Sagi Grimberg
@ 2017-10-14 18:41 ` Max Gurtovoy
  2017-10-16 12:48 ` Christoph Hellwig
  2017-10-16 13:00 ` Christoph Hellwig
  3 siblings, 0 replies; 5+ messages in thread
From: Max Gurtovoy @ 2017-10-14 18:41 UTC (permalink / raw)




On 10/10/2017 6:59 PM, roys@lightbitslabs.com wrote:
> From: Roy Shterman <roys at lightbitslabs.com>
> 
> In case we disable namespaces which has the nsid like
> subsystem max_nsid we need to search for the next largest nsid
> in this subsystem. If the subsystem don't has more namespaces
> we set it to 0, else we take nsid from the last namespace in
> namespaces list because the list is sorted while inserting.
> 
> Signed-off-by: Roy Shterman <roys at lightbitslabs.com>
> ---

Looks good,

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

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

* [PATCH] nvme/target: Change max_nsid in subsystem due to ns_disable if needed
  2017-10-10 15:59 [PATCH] nvme/target: Change max_nsid in subsystem due to ns_disable if needed roys
  2017-10-11 11:40 ` Sagi Grimberg
  2017-10-14 18:41 ` Max Gurtovoy
@ 2017-10-16 12:48 ` Christoph Hellwig
  2017-10-16 13:00 ` Christoph Hellwig
  3 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2017-10-16 12:48 UTC (permalink / raw)


Looks good and a reasonable 4.14. candidate.

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

* [PATCH] nvme/target: Change max_nsid in subsystem due to ns_disable if needed
  2017-10-10 15:59 [PATCH] nvme/target: Change max_nsid in subsystem due to ns_disable if needed roys
                   ` (2 preceding siblings ...)
  2017-10-16 12:48 ` Christoph Hellwig
@ 2017-10-16 13:00 ` Christoph Hellwig
  3 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2017-10-16 13:00 UTC (permalink / raw)


Actually, this doesn't even compile..  the entry in ->namespaces
is dev_link, not entry.

If you resend please also fix the line > 80 chars, preferably
by adding a new helper that returns the new max_nsid value.

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

end of thread, other threads:[~2017-10-16 13:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-10 15:59 [PATCH] nvme/target: Change max_nsid in subsystem due to ns_disable if needed roys
2017-10-11 11:40 ` Sagi Grimberg
2017-10-14 18:41 ` Max Gurtovoy
2017-10-16 12:48 ` Christoph Hellwig
2017-10-16 13:00 ` Christoph Hellwig

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).