Skip to contentSkip to conversation

nvme: Treat discovery subsystems as unique subsystems

PATCH Superseded James Smart 4 participants 5 messages Aug 30, 2019 – Sep 2, 2019 NVMe

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvme: Treat discovery subsystems as unique subsystems

Current code matches subnqn and collapses all controllers to the same subnqn to a single subsystem structure. This is good for recognizing multiple controllers for the same subsystem. But with the well-known discovery subnqn, the subsystems aren't truly the same subsystem. As such, subsystem specific rules, such as no overlap of controller id, do not apply. With today's behavior, the check for overlap of controller id can fail, preventing the new discovery controller from being created.

When searching for like subsystem nqn, exclude the discovery nqn from matching. This will result in each discovery controller being attached to a unique subsystem structure.

---
 drivers/nvme/host/core.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/nvme/host/core.c +3 -0
index 4660505eded9..3edafe57c7f7 100644
@@ -2358,6 +2358,9 @@ static struct nvme_subsystem *__nvme_find_get_subsystem(const char *subsysnqn)
 
 	lockdep_assert_held(&nvme_subsystems_lock);
 
+	if (!strcmp(subsysnqn, NVME_DISC_SUBSYS_NAME))
+		return NULL;
+
 	list_for_each_entry(subsys, &nvme_subsystems, entry) {
 		if (strcmp(subsys->subnqn, subsysnqn))
 			continue;
Signature · 7 lines
2.13.7


_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
#2 lore raw
In reply to James Smart
Quoted 8 lines · James Smart

Current code matches subnqn and collapses all controllers to the same subnqn to a single subsystem structure. This is good for recognizing multiple controllers for the same subsystem. But with the well-known discovery subnqn, the subsystems aren't truly the same subsystem. As such, subsystem specific rules, such as no overlap of controller id, do not apply. With today's behavior, the check for overlap of controller id can fail, preventing the new discovery controller from being created.

so this fixes a scenario of multiple discovery in parallel ?

Quoted 14 lines

When searching for like subsystem nqn, exclude the discovery nqn from matching. This will result in each discovery controller being attached to a unique subsystem structure.

---
  drivers/nvme/host/core.c | 3 +++
  1 file changed, 3 insertions(+)
drivers/nvme/host/core.c +0 -0
index 4660505eded9..3edafe57c7f7 100644

drivers/nvme/host/core.c static struct nvme_subsystem *__nvme_find_get_subsystem(const char *subsysnqn) · line 2366

Quoted 9 lines
drivers/nvme/host/core.c +3 -0
@@ -2358,6 +2358,9 @@ static struct nvme_subsystem *__nvme_find_get_subsystem(const char *subsysnqn)
 
  	lockdep_assert_held(&nvme_subsystems_lock);
 
+	if (!strcmp(subsysnqn, NVME_DISC_SUBSYS_NAME))
+		return NULL;
+
  	list_for_each_entry(subsys, &nvme_subsystems, entry) {
  		if (strcmp(subsys->subnqn, subsysnqn))
  			continue;

_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme

#3 lore raw
Quoted 15 lines · Max Gurtovoy
Quoted 8 lines · James Smart

Current code matches subnqn and collapses all controllers to the same subnqn to a single subsystem structure. This is good for recognizing multiple controllers for the same subsystem. But with the well-known discovery subnqn, the subsystems aren't truly the same subsystem. As such, subsystem specific rules, such as no overlap of controller id, do not apply. With today's behavior, the check for overlap of controller id can fail, preventing the new discovery controller from being created.

Quoted 2 lines

so this fixes a scenario of multiple discovery in parallel ?

It’s not to say that multiple discoveries in parallel doesn’t work, but I did see a scenario where it mapped into this. In most cases, the time taken for an ioctl or two to get the log, then delete the controller happens so fast it’s avoided. But I fully expect long-lived controllers to make this problematic.

— james

_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme

Reviewed-by on v1 1/1
#4 lore raw
In reply to James Smart

drivers/nvme/host/core.c static struct nvme_subsystem *__nvme_find_get_subsystem(const char *subsysnqn) · line 2363

Quoted 7 lines · James Smart
drivers/nvme/host/core.c +3 -0
@@ -2358,6 +2358,9 @@ static struct nvme_subsystem *__nvme_find_get_subsystem(const char *subsysnqn)
 
 	lockdep_assert_held(&nvme_subsystems_lock);
 
+	if (!strcmp(subsysnqn, NVME_DISC_SUBSYS_NAME))
+		return NULL;
+

Can you throw in a comment here?

Otherwise this looks good:

_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme