From: roys@lightbitslabs.com (roys@lightbitslabs.com)
Subject: [PATCH] nvme/target: Change max_nsid in subsystem due to ns_disable if needed
Date: Tue, 10 Oct 2017 18:59:27 +0300 [thread overview]
Message-ID: <1507651167-4839-1-git-send-email-roys@lightbitslabs.com> (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
next reply other threads:[~2017-10-10 15:59 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-10 15:59 roys [this message]
2017-10-11 11:40 ` [PATCH] nvme/target: Change max_nsid in subsystem due to ns_disable if needed Sagi Grimberg
2017-10-14 18:41 ` Max Gurtovoy
2017-10-16 12:48 ` Christoph Hellwig
2017-10-16 13:00 ` Christoph Hellwig
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=1507651167-4839-1-git-send-email-roys@lightbitslabs.com \
--to=roys@lightbitslabs.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).