nvmet: discovery controller discovery support
Subsystems (2)
v2 cover nvmet: discovery controller discovery support
TPAR 8014 (discovery controller discovery) adds a new discovery log page entry type '3' to describe the current discovery controller. This patchset adds support for this to the nvme target.
As usual, comments and reviews are welcome.
Changes to v1:
- Rebased to nvme-5.16
Hannes Reinecke (3):
nvmet: switch check for subsystem type
nvme: add new discovery log page entry definitions
nvmet: register discovery subsystem as 'current'
drivers/nvme/target/core.c | 2 ++ drivers/nvme/target/discovery.c | 13 ++++++++----- drivers/nvme/target/nvmet.h | 2 +- include/linux/nvme.h | 12 ++++++++++-- 4 files changed, 21 insertions(+), 8 deletions(-)
Signature · 1 line
2.29.2
PATCH v2 1/3 nvmet: switch check for subsystem type
Invert the check for discovery subsystem type to allow for additional discovery subsystem types.
--- drivers/nvme/target/nvmet.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/target/nvmet.h +1 -1
@@ -579,7 +579,7 @@ static inline struct nvmet_subsys *nvmet_req_subsys(struct nvmet_req *req)static inline bool nvmet_is_disc_subsys (struct nvmet_subsys *subsys) { -return subsys->type ==NVME_NQN_DISC ; +return subsys->type !=NVME_NQN_NVME ; }#ifdef CONFIG_NVME_TARGET_PASSTHRU
Signature · 1 line
2.29.2
Re: [PATCH 1/3] nvmet: switch check for subsystem type
Quoted 13 lines · Hannes Reinecke
Invert the check for discovery subsystem type to allow for additional discovery subsystem types.
Signed-off-by Hannes Reinecke <[email protected]>--- drivers/nvme/target/nvmet.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/nvme/target/nvmet.h +0
-0
drivers/nvme/target/nvmet.h static inline struct nvmet_subsys *nvmet_req_subsys(struct nvmet_req *req) · line 582
Quoted 5 lines
drivers/nvme/target/nvmet.h +1
-1@@ -579,7 +579,7 @@ static inline struct nvmet_subsys *nvmet_req_subsys(struct nvmet_req *req)static inline bool nvmet_is_disc_subsys (struct nvmet_subsys *subsys) { -return subsys->type ==NVME_NQN_DISC ; +return subsys->type !=NVME_NQN_NVME ;
shouldn't we use switch and make code more readable for allowed subsys->type values ? unless there is a reason ..
Quoted 4 lines
drivers/nvme/target/nvmet.h +0
-0}#ifdef CONFIG_NVME_TARGET_PASSTHRU
Re: [PATCH 1/3] nvmet: switch check for subsystem type
Quoted 15 lines · Chaitanya Kulkarni
Quoted 14 lines · Hannes Reinecke
Invert the check for discovery subsystem type to allow for additional discovery subsystem types.
Signed-off-by Hannes Reinecke <[email protected]>--- drivers/nvme/target/nvmet.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/nvme/target/nvmet.h +0
-0@@ -579,7 +579,7 @@ static inline struct nvmet_subsys *nvmet_req_subsys(struct nvmet_req *req)
Quoted 8 lines
drivers/nvme/target/nvmet.h static inline struct nvmet_subsys *nvmet_req_subsys(struct nvmet_req *req) · line 582
Quoted 4 lines
drivers/nvme/target/nvmet.h +1
-1static inline bool nvmet_is_disc_subsys (struct nvmet_subsys *subsys) { -return subsys->type ==NVME_NQN_DISC ; +return subsys->type !=NVME_NQN_NVME ;shouldn't we use switch and make code more readable for allowed
subsys->typevalues ? unless there is a reason ..
Well, with this patch we still have only two values; introducing a switch for this feels a bit silly.
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
PATCH v2 2/3 nvme: add new discovery log page entry definitions
In reply to Hannes ReineckeTP8014 adds a new SUBTYPE value and a new field EFLAGS for the discovery log page entry.
--- include/linux/nvme.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
include/linux/nvme.h +10 -2
@@ -27,8 +27,9 @@#define NVME_NSID_ALL 0xffffffffenum nvme_subsys_type { -NVME_NQN_DISC =1 ,/* Discovery type target subsystem */ +NVME_NQN_DISC =1 ,/* Referral to another discovery type target subsystem */ NVME_NQN_NVME =2 ,/* NVME type target subsystem */ +NVME_NQN_CURR =3 ,/* Current discovery type target subsystem */ };enum nvme_ctrl_type {
@@ -1312,6 +1313,12 @@ struct nvmf_common_command {#define MAX_DISC_LOGS 255 +/* Discovery log page entry flags (EFLAGS): */ +enum { +NVME_DISC_EFLAGS_EPCSD = (1 <<1 ), +NVME_DISC_EFLAGS_DUPRETINFO = (1 <<0 ), +}; +/* Discovery log page entry */ struct nvmf_disc_rsp_page_entry {__u8 trtype;
@@ -1321,7 +1328,8 @@ struct nvmf_disc_rsp_page_entry {__le16 portid;__le16 cntlid;__le16 asqsz; -__u8 resv8[22 ]; +__le16 eflags; +__u8 resv10[20 ];char trsvcid[NVMF_TRSVCID_SIZE ];__u8 resv64[192 ];char subnqn[NVMF_NQN_FIELD_LEN ];
Signature · 1 line
2.29.2
PATCH v2 3/3 nvmet: register discovery subsystem as 'current'
In reply to Hannes ReineckeRegister the discovery subsystem as the 'current' discovery subsystem, and add a new discovery log page entry for it.
--- drivers/nvme/target/core.c | 2 ++ drivers/nvme/target/discovery.c | 13 ++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-)
drivers/nvme/target/core.c +2 -0
@@ -1541,6 +1541,8 @@ struct nvmet_subsys *nvmet_subsys_alloc(const char *subsysnqn, subsys->max_qid =NVMET_NR_QUEUES ;break ;case NVME_NQN_DISC : + fallthrough; +case NVME_NQN_CURR : subsys->max_qid =0 ;break ;default :
drivers/nvme/target/discovery.c +8 -5
@@ -146,7 +146,7 @@ static size_t discovery_log_entries(struct nvmet_req *req)struct nvmet_ctrl *ctrl = req->sq->ctrl;struct nvmet_subsys_link *p;struct nvmet_port *r; -size_t entries =0 ; +size_t entries =1 ;list_for_each_entry (p, &req->port->subsystems, entry) {if (!nvmet_host_allowed (p->subsys, ctrl->hostnqn))
@@ -171,6 +171,7 @@ static void nvmet_execute_disc_get_log_page(struct nvmet_req *req)u32 numrec =0 ;u16 status =0 ;void *buffer; +char traddr[NVMF_TRADDR_SIZE ];if (!nvmet_check_transfer_len (req, data_len))return ;
@@ -204,14 +205,16 @@ static void nvmet_execute_disc_get_log_page(struct nvmet_req *req) goto out; } +nvmet_set_disc_traddr (req, req->port, traddr); hdr = buffer; +nvmet_format_discovery_entry (hdr, req->port, + nvmet_disc_subsys->subsysnqn, + traddr,NVME_NQN_CURR , numrec); + numrec++;list_for_each_entry (p, &req->port->subsystems, entry) { -char traddr[NVMF_TRADDR_SIZE ]; -if (!nvmet_host_allowed (p->subsys, ctrl->hostnqn))continue ; -nvmet_set_disc_traddr (req, req->port, traddr);nvmet_format_discovery_entry (hdr, req->port, p->subsys->subsysnqn, traddr,NVME_NQN_NVME , numrec);
@@ -389,7 +392,7 @@ u16 nvmet_parse_discovery_cmd(struct nvmet_req *req)int __init nvmet_init_discovery (void ) { nvmet_disc_subsys = -nvmet_subsys_alloc (NVME_DISC_SUBSYS_NAME ,NVME_NQN_DISC ); +nvmet_subsys_alloc (NVME_DISC_SUBSYS_NAME ,NVME_NQN_CURR );return PTR_ERR_OR_ZERO (nvmet_disc_subsys); }
Signature · 1 line
2.29.2
Thanks,
applied to nvme-5.16 with a few cosmetic tweaks.