Skip to content

Commit 0f1f580

Browse files
Hannes Reineckekeithbusch
authored andcommitted
nvmet: make 'tsas' attribute idempotent for RDMA
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: 3f12349 ("nvmet: make TCP sectype settable via configfs") Signed-off-by: Hannes Reinecke <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Keith Busch <[email protected]>
1 parent f80a55f commit 0f1f580

File tree

2 files changed

+32
-9
lines changed

2 files changed

+32
-9
lines changed

drivers/nvme/target/configfs.c

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -413,25 +413,46 @@ static ssize_t nvmet_addr_tsas_show(struct config_item *item,
413413
return sprintf(page, "\n");
414414
}
415415

416+
static u8 nvmet_addr_tsas_rdma_store(const char *page)
417+
{
418+
int i;
419+
420+
for (i = 0; i < ARRAY_SIZE(nvmet_addr_tsas_rdma); i++) {
421+
if (sysfs_streq(page, nvmet_addr_tsas_rdma[i].name))
422+
return nvmet_addr_tsas_rdma[i].type;
423+
}
424+
return NVMF_RDMA_QPTYPE_INVALID;
425+
}
426+
427+
static u8 nvmet_addr_tsas_tcp_store(const char *page)
428+
{
429+
int i;
430+
431+
for (i = 0; i < ARRAY_SIZE(nvmet_addr_tsas_tcp); i++) {
432+
if (sysfs_streq(page, nvmet_addr_tsas_tcp[i].name))
433+
return nvmet_addr_tsas_tcp[i].type;
434+
}
435+
return NVMF_TCP_SECTYPE_INVALID;
436+
}
437+
416438
static ssize_t nvmet_addr_tsas_store(struct config_item *item,
417439
const char *page, size_t count)
418440
{
419441
struct nvmet_port *port = to_nvmet_port(item);
420442
u8 treq = nvmet_port_disc_addr_treq_mask(port);
421-
u8 sectype;
422-
int i;
443+
u8 sectype, qptype;
423444

424445
if (nvmet_is_port_enabled(port, __func__))
425446
return -EACCES;
426447

427-
if (port->disc_addr.trtype != NVMF_TRTYPE_TCP)
428-
return -EINVAL;
429-
430-
for (i = 0; i < ARRAY_SIZE(nvmet_addr_tsas_tcp); i++) {
431-
if (sysfs_streq(page, nvmet_addr_tsas_tcp[i].name)) {
432-
sectype = nvmet_addr_tsas_tcp[i].type;
448+
if (port->disc_addr.trtype == NVMF_TRTYPE_RDMA) {
449+
qptype = nvmet_addr_tsas_rdma_store(page);
450+
if (qptype == port->disc_addr.tsas.rdma.qptype)
451+
return count;
452+
} else if (port->disc_addr.trtype == NVMF_TRTYPE_TCP) {
453+
sectype = nvmet_addr_tsas_tcp_store(page);
454+
if (sectype != NVMF_TCP_SECTYPE_INVALID)
433455
goto found;
434-
}
435456
}
436457

437458
pr_err("Invalid value '%s' for tsas\n", page);

include/linux/nvme.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ enum {
8585
enum {
8686
NVMF_RDMA_QPTYPE_CONNECTED = 1, /* Reliable Connected */
8787
NVMF_RDMA_QPTYPE_DATAGRAM = 2, /* Reliable Datagram */
88+
NVMF_RDMA_QPTYPE_INVALID = 0xff,
8889
};
8990

9091
/* RDMA Provider Type codes for Discovery Log Page entry TSAS
@@ -110,6 +111,7 @@ enum {
110111
NVMF_TCP_SECTYPE_NONE = 0, /* No Security */
111112
NVMF_TCP_SECTYPE_TLS12 = 1, /* TLSv1.2, NVMe-oF 1.1 and NVMe-TCP 3.6.1.1 */
112113
NVMF_TCP_SECTYPE_TLS13 = 2, /* TLSv1.3, NVMe-oF 1.1 and NVMe-TCP 3.6.1.1 */
114+
NVMF_TCP_SECTYPE_INVALID = 0xff,
113115
};
114116

115117
#define NVME_AQ_DEPTH 32

0 commit comments

Comments
 (0)