Skip to contentSkip to conversation

nvmet: fixup nvmetcli save/restore

PATCH Applied Hannes Reinecke 3 participants 8 messages Jun 17, 2024 – Jun 21, 2024

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

cover nvmet: fixup nvmetcli save/restore

Hi all,

I noticed that there are some small issues during nvmetcli save and restore. This patchset fixes them up.

Hannes Reinecke (3):
nvmet: do not return 'reserved' for empty TSAS values
nvme: fixup comment for nvme RDMA Provider Type
nvmet: make 'tsas' attribute idempotent for RDMA

 drivers/nvme/target/configfs.c | 41 +++++++++++++++++++++++++---------
 include/linux/nvme.h           |  6 +++--
 2 files changed, 35 insertions(+), 12 deletions(-)
Signature · 1 line
2.35.3
#1 lore raw

PATCH 1/3 nvmet: do not return 'reserved' for empty TSAS values

The 'TSAS' value is only defined for TCP and RDMA, but returning 'reserved' for undefined values tricked nvmetcli to try to write 'reserved' when restoring from a config file. This caused an error and the configuration would not be applied.

Fixes 3f123494db72 ("nvmet: make TCP sectype settable via configfs")
---
 drivers/nvme/target/configfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/target/configfs.c +1 -1
index bd87dfd173a4..e60224356048 100644
@@ -410,7 +410,7 @@ static ssize_t nvmet_addr_tsas_show(struct config_item *item,
 				return sprintf(page, "%s\n", nvmet_addr_tsas_rdma[i].name);
 		}
 	}
-	return sprintf(page, "reserved\n");
+	return sprintf(page, "\n");
 }
 
 static ssize_t nvmet_addr_tsas_store(struct config_item *item,
Signature · 1 line
2.35.3
maintainer Applied
#2 lore raw

Re: [PATCH 1/3] nvmet: do not return 'reserved' for empty TSAS values

Quoted 4 lines · Hannes Reinecke

The 'TSAS' value is only defined for TCP and RDMA, but returning 'reserved' for undefined values tricked nvmetcli to try to write 'reserved' when restoring from a config file. This caused an error and the configuration would not be applied.

Thanks, applied to nvme-6.10.

#3 lore raw

PATCH 2/3 nvme: fixup comment for nvme RDMA Provider Type

In reply to Hannes Reinecke

From: Hannes Reinecke <[email protected]>

PRTYPE is the provider type, not the QP service type.

Fixes eb793e2c9286 ("nvme.h: add NVMe over Fabrics definitions")
---
 include/linux/nvme.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/nvme.h +2 -2
index 27faae34245d..0993703f6617 100644
@@ -87,8 +87,8 @@ enum {
 	NVMF_RDMA_QPTYPE_DATAGRAM	= 2, /* Reliable Datagram */
 };
 
-/* RDMA QP Service Type codes for Discovery Log Page entry TSAS
- * RDMA_QPTYPE field
+/* RDMA Provider Type codes for Discovery Log Page entry TSAS
+ * RDMA_PRTYPE field
  */
 enum {
 	NVMF_RDMA_PRTYPE_NOT_SPECIFIED	= 1, /* No Provider Specified */
Signature · 1 line
2.35.3
#5 lore raw

PATCH 3/3 nvmet: make 'tsas' attribute idempotent for RDMA

In reply to Hannes Reinecke

The RDMA transport defines values for TSAS, but it cannot be changed as we only support the 'connected' mode.
So to avoid errors during reconfiguration we should allow to write the current value.

Fixes 3f123494db72 ("nvmet: make TCP sectype settable via configfs")
---
 drivers/nvme/target/configfs.c | 39 ++++++++++++++++++++++++++--------
 include/linux/nvme.h           |  2 ++
 2 files changed, 32 insertions(+), 9 deletions(-)
drivers/nvme/target/configfs.c +30 -9
index e60224356048..685e89b35d33 100644
@@ -413,25 +413,46 @@ static ssize_t nvmet_addr_tsas_show(struct config_item *item,
 	return sprintf(page, "\n");
 }
 
+static u8 nvmet_addr_tsas_rdma_store(const char *page)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(nvmet_addr_tsas_rdma); i++) {
+		if (sysfs_streq(page, nvmet_addr_tsas_rdma[i].name))
+			return nvmet_addr_tsas_rdma[i].type;
+	}
+	return NVMF_RDMA_QPTYPE_INVALID;
+}
+
+static u8 nvmet_addr_tsas_tcp_store(const char *page)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(nvmet_addr_tsas_tcp); i++) {
+		if (sysfs_streq(page, nvmet_addr_tsas_tcp[i].name))
+			return nvmet_addr_tsas_tcp[i].type;
+	}
+	return NVMF_TCP_SECTYPE_INVALID;
+}
+
 static ssize_t nvmet_addr_tsas_store(struct config_item *item,
 		const char *page, size_t count)
 {
 	struct nvmet_port *port = to_nvmet_port(item);
 	u8 treq = nvmet_port_disc_addr_treq_mask(port);
-	u8 sectype;
-	int i;
+	u8 sectype, qptype;
 
 	if (nvmet_is_port_enabled(port, __func__))
 		return -EACCES;
 
-	if (port->disc_addr.trtype != NVMF_TRTYPE_TCP)
-		return -EINVAL;
-
-	for (i = 0; i < ARRAY_SIZE(nvmet_addr_tsas_tcp); i++) {
-		if (sysfs_streq(page, nvmet_addr_tsas_tcp[i].name)) {
-			sectype = nvmet_addr_tsas_tcp[i].type;
+	if (port->disc_addr.trtype == NVMF_TRTYPE_RDMA) {
+		qptype = nvmet_addr_tsas_rdma_store(page);
+		if (qptype == port->disc_addr.tsas.rdma.qptype)
+			return count;
+	} else if (port->disc_addr.trtype == NVMF_TRTYPE_TCP) {
+		sectype = nvmet_addr_tsas_tcp_store(page);
+		if (sectype != NVMF_TCP_SECTYPE_INVALID)
 			goto found;
-		}
 	}
 
 	pr_err("Invalid value '%s' for tsas\n", page);
include/linux/nvme.h +2 -0
index 0993703f6617..efda407622c1 100644
@@ -85,6 +85,7 @@ enum {
 enum {
 	NVMF_RDMA_QPTYPE_CONNECTED	= 1, /* Reliable Connected */
 	NVMF_RDMA_QPTYPE_DATAGRAM	= 2, /* Reliable Datagram */
+	NVMF_RDMA_QPTYPE_INVALID	= 0xff,
 };
 
 /* RDMA Provider Type codes for Discovery Log Page entry TSAS
@@ -110,6 +111,7 @@ enum {
 	NVMF_TCP_SECTYPE_NONE = 0, /* No Security */
 	NVMF_TCP_SECTYPE_TLS12 = 1, /* TLSv1.2, NVMe-oF 1.1 and NVMe-TCP 3.6.1.1 */
 	NVMF_TCP_SECTYPE_TLS13 = 2, /* TLSv1.3, NVMe-oF 1.1 and NVMe-TCP 3.6.1.1 */
+	NVMF_TCP_SECTYPE_INVALID = 0xff,
 };
 
 #define NVME_AQ_DEPTH		32
Signature · 1 line
2.35.3
maintainer Applied
#7 lore raw
In reply to Hannes Reinecke
Quoted 4 lines · Hannes Reinecke

Hi all,

I noticed that there are some small issues during nvmetcli save and restore. This patchset fixes them up.

Thanks, applied to nvme-6.10. The web ui appears to not show the branch anymore, but git says it's there.