Skip to contentSkip to conversation

nvme/target: Change max_nsid in subsystem due to ns_disable if needed

PATCH New [email protected] 4 participants 5 messages Oct 10, 2017 – Oct 16, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvme/target: Change max_nsid in subsystem due to ns_disable if needed

From: Roy Shterman <[email protected]>

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(+)
drivers/nvme/target/core.c +11 -0
index eb9399a..e996972 100644
@@ -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);
 
 	/*
Signature · 1 line
2.7.4
maintainer
#1 lore raw

PATCH 1/1 nvme/target: Change max_nsid in subsystem due to ns_disable if needed

Looks good,

Reviewed-by Sagi Grimberg <sagi at rimberg.me>
#2 lore raw

PATCH 1/1 nvme/target: Change max_nsid in subsystem due to ns_disable if needed

In reply to [email protected]
Quoted 10 lines · On 10/10/2017 6:59 PM, [email protected] 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>
#4 lore raw

PATCH 1/1 nvme/target: Change max_nsid in subsystem due to ns_disable if needed

In reply to [email protected]

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.