nvme: support unique discovery controller NQN
Subsystems (3)
PATCH v3 4/7 nvmet: set 'CNTRLTYPE' in the identify controller data
In reply to Hannes ReineckeSet the correct 'CNTRLTYPE' field in the identify controller data.
--- drivers/nvme/target/admin-cmd.c | 3 +++ drivers/nvme/target/discovery.c | 2 ++ drivers/nvme/target/fabrics-cmd.c | 3 ++- 3 files changed, 7 insertions(+), 1 deletion(-)
drivers/nvme/target/admin-cmd.c +3 -0
@@ -374,6 +374,9 @@ static void nvmet_execute_identify_ctrl(struct nvmet_req *req) id->rab =6 ; + id->cntrltype =nvmet_is_disc_subsys (ctrl->subsys) ? +NVME_CTRL_DISC :NVME_CTRL_IO ; +/* * XXX: figure out how we can assign a IEEE OUI, but until then * the safest is to leave it as zeroes.
drivers/nvme/target/discovery.c +2 -0
@@ -268,6 +268,8 @@ static void nvmet_execute_disc_identify(struct nvmet_req *req)memcpy_and_pad (id->fr,sizeof (id->fr),UTS_RELEASE ,strlen (UTS_RELEASE ),' ' ); + id->cntrltype =NVME_CTRL_DISC ; +/* no limit on data transfer sizes for now */ id->mdts =0 ; id->cntlid =cpu_to_le16 (ctrl->cntlid);
drivers/nvme/target/fabrics-cmd.c +2 -1
@@ -221,7 +221,8 @@ static void nvmet_execute_admin_connect(struct nvmet_req *req) goto out; } -pr_info ("creating controller %d for subsystem %s for NQN %s%s.\n" , +pr_info ("creating %s controller %d for subsystem %s for NQN %s%s.\n" , +nvmet_is_disc_subsys (ctrl->subsys) ?"discovery" :"nvm" , ctrl->cntlid, ctrl->subsys->subsysnqn, ctrl->hostnqn, ctrl->pi_support ?" T10-PI is enabled" :"" ); req->cqe->result.u16 =cpu_to_le16 (ctrl->cntlid);
Signature · 7 lines
2.29.2 _______________________________________________ Linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
v3 cover nvme: support unique discovery controller NQN
Hi all,
with TPAR8013 a discovery controller can support a unique subsystem NQN. This patchset adds support for this for both target and host. For host support a new connect option 'discovery' is added, as we can't infer from the NQN whether it should be a discovery connection or not.
As usual, comments and reviews are welcome.
Changes to v1:
- Rebase to nvme-5.15
Changes to v2:
- Add nvmet_is_disc_subsys() helper
- Include reviews from Chaitanya
Hannes Reinecke (7):
nvmet: make discovery NQN configurable
nvme: add CNTRLTYPE definitions for 'identify controller'
nvmet: add nvmet_is_disc_subsys() helper
nvmet: set 'CNTRLTYPE' in the identify controller data
nvme: expose subsystem type in sysfs attribute 'subtype'
nvme: Add connect option 'discovery'
nvme: display correct subsystem NQN
drivers/nvme/host/core.c | 36 +++++++++++++++++++++++++++- drivers/nvme/host/fabrics.c | 6 ++++- drivers/nvme/host/fabrics.h | 6 +++++ drivers/nvme/host/fc.c | 2 +- drivers/nvme/host/nvme.h | 1 + drivers/nvme/host/rdma.c | 2 +- drivers/nvme/host/tcp.c | 2 +- drivers/nvme/target/admin-cmd.c | 5 +++- drivers/nvme/target/configfs.c | 39 +++++++++++++++++++++++++++++++ drivers/nvme/target/core.c | 9 +++---- drivers/nvme/target/discovery.c | 2 ++ drivers/nvme/target/fabrics-cmd.c | 3 ++- drivers/nvme/target/nvmet.h | 5 ++++ include/linux/nvme.h | 10 +++++++- 14 files changed, 116 insertions(+), 12 deletions(-)
Signature · 7 lines
2.29.2 _______________________________________________ Linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
PATCH v3 7/7 nvme: display correct subsystem NQN
With discovery controllers supporting unique subsystem NQNs the actual subsystem NQN might be different from that one passed in via the connect args. So add a helper to display the resulting subsystem NQN.
--- drivers/nvme/host/core.c | 2 +- drivers/nvme/host/fabrics.h | 5 +++++ drivers/nvme/host/fc.c | 2 +- drivers/nvme/host/rdma.c | 2 +- drivers/nvme/host/tcp.c | 2 +- 5 files changed, 9 insertions(+), 4 deletions(-)
drivers/nvme/host/core.c +1 -1
@@ -221,7 +221,7 @@ int nvme_reset_ctrl_sync(struct nvme_ctrl *ctrl)static void nvme_do_delete_ctrl (struct nvme_ctrl *ctrl) {dev_info (ctrl->device, -"Removing ctrl: NQN \"%s\"\n" , ctrl->opts->subsysnqn); +"Removing ctrl: NQN \"%s\"\n" ,nvmf_ctrl_subsysnqn (ctrl));flush_work (&ctrl->reset_work);nvme_stop_ctrl (ctrl);
drivers/nvme/host/fabrics.h +5 -0
@@ -179,6 +179,11 @@ nvmf_ctlr_matches_baseopts(struct nvme_ctrl *ctrl,return true; } +static inline char *nvmf_ctrl_subsysnqn (struct nvme_ctrl *ctrl) +{ +return ctrl->subsys ? ctrl->subsys->subnqn : ctrl->opts->subsysnqn; +} +int nvmf_reg_read32 (struct nvme_ctrl *ctrl,u32 off,u32 *val);int nvmf_reg_read64 (struct nvme_ctrl *ctrl,u32 off,u64 *val);int nvmf_reg_write32 (struct nvme_ctrl *ctrl,u32 off,u32 val);
drivers/nvme/host/fc.c +1 -1
@@ -3572,7 +3572,7 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts,dev_info (ctrl->ctrl.device,"NVME-FC{%d}: new ctrl: NQN \"%s\"\n" , - ctrl->cnum, ctrl->ctrl.opts->subsysnqn); + ctrl->cnum,nvmf_ctrl_subsysnqn (&ctrl->ctrl));return &ctrl->ctrl;
drivers/nvme/host/rdma.c +1 -1
@@ -2385,7 +2385,7 @@ static struct nvme_ctrl *nvme_rdma_create_ctrl(struct device *dev, goto out_uninit_ctrl;dev_info (ctrl->ctrl.device,"new ctrl: NQN \"%s\", addr %pISpcs\n" , - ctrl->ctrl.opts->subsysnqn, &ctrl->addr); +nvmf_ctrl_subsysnqn (&ctrl->ctrl), &ctrl->addr);mutex_lock (&nvme_rdma_ctrl_mutex);list_add_tail (&ctrl->list, &nvme_rdma_ctrl_list);
drivers/nvme/host/tcp.c +1 -1
@@ -2582,7 +2582,7 @@ static struct nvme_ctrl *nvme_tcp_create_ctrl(struct device *dev, goto out_uninit_ctrl;dev_info (ctrl->ctrl.device,"new ctrl: NQN \"%s\", addr %pISp\n" , - ctrl->ctrl.opts->subsysnqn, &ctrl->addr); +nvmf_ctrl_subsysnqn (&ctrl->ctrl), &ctrl->addr);mutex_lock (&nvme_tcp_ctrl_mutex);list_add_tail (&ctrl->list, &nvme_tcp_ctrl_list);
Signature · 7 lines
2.29.2 _______________________________________________ Linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
PATCH v3 5/7 nvme: expose subsystem type in sysfs attribute 'subtype'
In reply to Hannes ReineckeWith unique discovery controller NQNs we cannot distinguish the subsystem type by the NQN alone, but need to check the subsystem type, too.
So expose the subsystem type in a new sysfs attribute 'subtype'.
--- drivers/nvme/host/core.c | 27 +++++++++++++++++++++++++++ drivers/nvme/host/nvme.h | 1 + 2 files changed, 28 insertions(+)
drivers/nvme/host/core.c +27 -0
@@ -2598,6 +2598,24 @@ static ssize_t nvme_subsys_show_nqn(struct device *dev, } static SUBSYS_ATTR_RO(subsysnqn, S_IRUGO, nvme_subsys_show_nqn); +static ssize_t nvme_subsys_show_subtype (struct device *dev, +struct device_attribute *attr, +char *buf) +{ +struct nvme_subsystem *subsys = + container_of(dev, struct nvme_subsystem, dev); + +switch (subsys->subtype) { +case NVME_NQN_DISC : +return sysfs_emit (buf,"discovery\n" ); +case NVME_NQN_NVME : +return sysfs_emit (buf,"nvm\n" ); +default : +return sysfs_emit (buf,"reserved\n" ); + } +} +static SUBSYS_ATTR_RO(subtype, S_IRUGO, nvme_subsys_show_subtype); +#define nvme_subsys_show_str_function (field) \ static ssize_t subsys_##field##_show(struct device *dev, \ struct device_attribute *attr, char *buf) \
@@ -2618,6 +2636,7 @@ static struct attribute *nvme_subsys_attrs[] = { &subsys_attr_serial.attr, &subsys_attr_firmware_rev.attr, &subsys_attr_subsysnqn.attr, + &subsys_attr_subtype.attr, #ifdef CONFIG_NVME_MULTIPATH &subsys_attr_iopolicy.attr, #endif
@@ -2688,6 +2707,14 @@ static int nvme_init_subsystem(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)memcpy (subsys->firmware_rev, id->fr,sizeof (subsys->firmware_rev)); subsys->vendor_id =le16_to_cpu (id->vid); subsys->cmic = id->cmic; + +/* Versions prior to 1.4 don't necessarily report a valid type */ +if (id->cntrltype ==NVME_CTRL_DISC || + !strcmp (subsys->subnqn,NVME_DISC_SUBSYS_NAME )) + subsys->subtype =NVME_NQN_DISC ; +else + subsys->subtype =NVME_NQN_NVME ; + subsys->awupf =le16_to_cpu (id->awupf);#ifdef CONFIG_NVME_MULTIPATH subsys->iopolicy =NVME_IOPOLICY_NUMA ;
drivers/nvme/host/nvme.h +1 -0
@@ -366,6 +366,7 @@ struct nvme_subsystem {char model[40 ];char firmware_rev[8 ];u8 cmic; +enum nvme_subsys_type subtype;u16 vendor_id;u16 awupf;/* 0's based awupf value. */ struct ida ns_ida;
Signature · 7 lines
2.29.2 _______________________________________________ Linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
PATCH v3 3/7 nvmet: add nvmet_is_disc_subsys() helper
In reply to Hannes ReineckeAdd a helper function to determine if a given subsystem is a discovery subsystem.
--- drivers/nvme/target/admin-cmd.c | 2 +- drivers/nvme/target/core.c | 6 +++--- drivers/nvme/target/nvmet.h | 5 +++++ 3 files changed, 9 insertions(+), 4 deletions(-)
drivers/nvme/target/admin-cmd.c +1 -1
@@ -1008,7 +1008,7 @@ u16 nvmet_parse_admin_cmd(struct nvmet_req *req)if (nvme_is_fabrics (cmd))return nvmet_parse_fabrics_cmd (req); -if (nvmet_req_subsys (req)->type ==NVME_NQN_DISC ) +if (nvmet_is_disc_subsys (nvmet_req_subsys (req)))return nvmet_parse_discovery_cmd (req); ret =nvmet_check_ctrl_status (req);
drivers/nvme/target/core.c +3 -3
@@ -1140,7 +1140,7 @@ static void nvmet_start_ctrl(struct nvmet_ctrl *ctrl)* should verify iosqes,iocqes are zeroed, however that * would break backwards compatibility, so don't enforce it. */ -if (ctrl->subsys->type !=NVME_NQN_DISC && +if (!nvmet_is_disc_subsys (ctrl->subsys) && (nvmet_cc_iosqes (ctrl->cc) !=NVME_NVM_IOSQES ||nvmet_cc_iocqes (ctrl->cc) !=NVME_NVM_IOCQES )) { ctrl->csts =NVME_CSTS_CFS ;
@@ -1278,7 +1278,7 @@ bool nvmet_host_allowed(struct nvmet_subsys *subsys, const char *hostnqn)if (subsys->allow_any_host)return true; -if (subsys->type ==NVME_NQN_DISC )/* allow all access to disc subsys */ +if (nvmet_is_disc_subsys (subsys))/* allow all access to disc subsys */ return true;list_for_each_entry (p, &subsys->hosts, entry) {
@@ -1411,7 +1411,7 @@ u16 nvmet_alloc_ctrl(const char *subsysnqn, const char *hostnqn,* Discovery controllers may use some arbitrary high value * in order to cleanup stale discovery sessions */ -if ((ctrl->subsys->type ==NVME_NQN_DISC ) && !kato) +if (nvmet_is_disc_subsys (ctrl->subsys) && !kato) kato =NVMET_DISC_KATO_MS ;/* keep-alive timeout in seconds */
drivers/nvme/target/nvmet.h +5 -0
@@ -576,6 +576,11 @@ static inline struct nvmet_subsys *nvmet_req_subsys(struct nvmet_req *req)return req->sq->ctrl->subsys; } +static inline bool nvmet_is_disc_subsys (struct nvmet_subsys *subsys) +{ +return subsys->type ==NVME_NQN_DISC ; +} +#ifdef CONFIG_NVME_TARGET_PASSTHRU void nvmet_passthru_subsys_free (struct nvmet_subsys *subsys);int nvmet_passthru_ctrl_enable (struct nvmet_subsys *subsys);
Signature · 7 lines
2.29.2 _______________________________________________ Linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
PATCH v3 2/7 nvme: add CNTRLTYPE definitions for 'identify controller'
In reply to Hannes ReineckeUpdate the 'identify controller' structure to define the missing CNTRLTYPE field.
--- include/linux/nvme.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
include/linux/nvme.h +9 -1
@@ -31,6 +31,12 @@ enum nvme_subsys_type { NVME_NQN_NVME = 2, /* NVME type target subsystem */ }; +enum nvme_ctrl_type { +NVME_CTRL_IO =1 ,/* I/O controller */ +NVME_CTRL_DISC =2 ,/* Discovery controller */ +NVME_CTRL_ADMIN =3 ,/* Administrative controller */ +}; +/* Address Family codes for Discovery Log Page entry ADRFAM field */ enum {NVMF_ADDR_FAMILY_PCI =0 ,/* PCIe */
@@ -244,7 +250,9 @@ struct nvme_id_ctrl {__le32 rtd3e;__le32 oaes;__le32 ctratt; -__u8 rsvd100[28 ]; +__u8 rsvd100[11 ]; +__u8 cntrltype; +__u8 fguid[16 ];__le16 crdt1;__le16 crdt2;__le16 crdt3;
Signature · 7 lines
2.29.2 _______________________________________________ Linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
PATCH v3 6/7 nvme: Add connect option 'discovery'
In reply to Hannes ReineckeAdd a connect option 'discovery' to specify that the connection should be made to a discovery controller, not a normal I/O controller. With discovery controllers supporting unique subsystem NQNs we cannot easily distinguish by the subsystem NQN if this should be a discovery connection, but we need this information to blank out options not supported by discovery controllers.
--- drivers/nvme/host/core.c | 7 +++++++ drivers/nvme/host/fabrics.c | 6 +++++- drivers/nvme/host/fabrics.h | 1 + 3 files changed, 13 insertions(+), 1 deletion(-)
drivers/nvme/host/core.c +7 -0
@@ -2715,6 +2715,13 @@ static int nvme_init_subsystem(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)else subsys->subtype =NVME_NQN_NVME ; +if (nvme_discovery_ctrl (ctrl) && subsys->subtype !=NVME_NQN_DISC ) { +dev_err (ctrl->device, +"Subsystem %s is not a discovery controller" , + subsys->subnqn); +kfree (subsys); +return -EINVAL ; + } subsys->awupf =le16_to_cpu (id->awupf);#ifdef CONFIG_NVME_MULTIPATH subsys->iopolicy =NVME_IOPOLICY_NUMA ;
drivers/nvme/host/fabrics.c +5 -1
@@ -548,6 +548,7 @@ static const match_table_t opt_tokens = { { NVMF_OPT_NR_POLL_QUEUES, "nr_poll_queues=%d" }, { NVMF_OPT_TOS, "tos=%d" }, { NVMF_OPT_FAIL_FAST_TMO, "fast_io_fail_tmo=%d" }, + { NVMF_OPT_DISCOVERY, "discovery" }, { NVMF_OPT_ERR, NULL } };
@@ -823,6 +824,9 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts, } opts->tos = token;break ; +case NVMF_OPT_DISCOVERY : + opts->discovery_nqn = true; +break ;default :pr_warn ("unknown parameter or missing value '%s' in ctrl creation request\n" , p);
@@ -949,7 +953,7 @@ EXPORT_SYMBOL_GPL(nvmf_free_options);#define NVMF_ALLOWED_OPTS (NVMF_OPT_QUEUE_SIZE | NVMF_OPT_NR_IO_QUEUES | \ NVMF_OPT_KATO | NVMF_OPT_HOSTNQN | \ NVMF_OPT_HOST_ID | NVMF_OPT_DUP_CONNECT |\ - NVMF_OPT_DISABLE_SQFLOW |\ + NVMF_OPT_DISABLE_SQFLOW | NVMF_OPT_DISCOVERY |\ NVMF_OPT_FAIL_FAST_TMO) static struct nvme_ctrl *
drivers/nvme/host/fabrics.h +1 -0
@@ -67,6 +67,7 @@ enum {NVMF_OPT_TOS =1 <<19 ,NVMF_OPT_FAIL_FAST_TMO =1 <<20 ,NVMF_OPT_HOST_IFACE =1 <<21 , + NVMF_OPT_DISCOVERY = 1 << 22, };/**
Signature · 7 lines
2.29.2 _______________________________________________ Linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
PATCH v3 1/7 nvmet: make discovery NQN configurable
In reply to Hannes ReineckeTPAR8013 allows for unique discovery NQNs, so make the discovery controller NQN configurable by exposing a subsys attribute 'discovery_nqn'.
--- drivers/nvme/target/configfs.c | 39 ++++++++++++++++++++++++++++++++++ drivers/nvme/target/core.c | 3 ++- 2 files changed, 41 insertions(+), 1 deletion(-)
drivers/nvme/target/configfs.c +39 -0
@@ -1233,6 +1233,44 @@ static ssize_t nvmet_subsys_attr_model_store(struct config_item *item, }CONFIGFS_ATTR (nvmet_subsys_, attr_model); +static ssize_t nvmet_subsys_attr_discovery_nqn_show (struct config_item *item, +char *page) +{ +return snprintf (page,PAGE_SIZE ,"%s\n" , + nvmet_disc_subsys->subsysnqn); +} + +static ssize_t nvmet_subsys_attr_discovery_nqn_store (struct config_item *item, +const char *page,size_t count) +{ +struct nvmet_subsys *subsys =to_subsys (item); +char *subsysnqn; +int len; + + len =strcspn (page,"\n" ); +if (!len) +return -EINVAL ; + + subsysnqn =kmemdup_nul (page, len,GFP_KERNEL ); +if (!subsysnqn) +return -ENOMEM ; + +/* +* The discovery NQN must be different from subsystem NQN. +*/ +if (!strcmp (subsysnqn, subsys->subsysnqn)) { +kfree (subsysnqn); +return -EBUSY ; + } +down_write (&nvmet_config_sem); +kfree (nvmet_disc_subsys->subsysnqn); + nvmet_disc_subsys->subsysnqn = subsysnqn; +up_write (&nvmet_config_sem); + +return count; +} +CONFIGFS_ATTR (nvmet_subsys_, attr_discovery_nqn); +#ifdef CONFIG_BLK_DEV_INTEGRITY static ssize_t nvmet_subsys_attr_pi_enable_show (struct config_item *item,char *page)
@@ -1262,6 +1300,7 @@ static struct configfs_attribute *nvmet_subsys_attrs[] = { &nvmet_subsys_attr_attr_cntlid_min, &nvmet_subsys_attr_attr_cntlid_max, &nvmet_subsys_attr_attr_model, + &nvmet_subsys_attr_attr_discovery_nqn, #ifdef CONFIG_BLK_DEV_INTEGRITY &nvmet_subsys_attr_attr_pi_enable, #endif
drivers/nvme/target/core.c +2 -1
@@ -1491,7 +1491,8 @@ static struct nvmet_subsys *nvmet_find_get_subsys(struct nvmet_port *port,if (!port)return NULL ; -if (!strcmp (NVME_DISC_SUBSYS_NAME , subsysnqn)) { +if (!strcmp (NVME_DISC_SUBSYS_NAME , subsysnqn) || + !strcmp (nvmet_disc_subsys->subsysnqn, subsysnqn)) {if (!kref_get_unless_zero (&nvmet_disc_subsys->ref))return NULL ;return nvmet_disc_subsys;
Signature · 7 lines
2.29.2 _______________________________________________ Linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Re: [PATCH 3/7] nvmet: add nvmet_is_disc_subsys() helper
In reply to Hannes ReineckeQuoted 6 lines · Hannes Reinecke
Add a helper function to determine if a given subsystem is a discovery subsystem.
Signed-off-by Hannes Reinecke <[email protected]>
Looks good.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Re: [PATCH 1/7] nvmet: make discovery NQN configurable
In reply to Hannes ReineckeQuoted 9 lines · Hannes Reinecke
External email: Use caution opening links or attachments
TPAR8013 allows for unique discovery NQNs, so make the discovery controller NQN configurable by exposing a subsys attribute '
discovery_nqn'.Signed-off-by Hannes Reinecke <[email protected]>---
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Re: [PATCH 4/7] nvmet: set 'CNTRLTYPE' in the identify controller data
In reply to Hannes ReineckeQuoted 7 lines · Hannes Reinecke
External email: Use caution opening links or attachments
Set the correct 'CNTRLTYPE' field in the identify controller data.
Signed-off-by Hannes Reinecke <[email protected]>---
Looks good.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Re: [PATCH 5/7] nvme: expose subsystem type in sysfs attribute 'subtype'
In reply to Hannes Reineckedrivers/nvme/host/core.c static struct attribute *nvme_subsys_attrs[] = { · line 2639
Quoted 10 lines · Hannes Reinecke
drivers/nvme/host/core.c +3
-0+static SUBSYS_ATTR_RO(subtype, S_IRUGO, nvme_subsys_show_subtype); +#define nvme_subsys_show_str_function (field) \ static ssize_t subsys_##field##_show(struct device *dev, \ struct device_attribute *attr, char *buf) \@@ -2618,6 +2636,7 @@ static struct attribute *nvme_subsys_attrs[] = { &subsys_attr_serial.attr, &subsys_attr_firmware_rev.attr, &subsys_attr_subsysnqn.attr, + &subsys_attr_subtype.attr,
Shouldn't this be subsystype to stay consistent with subsysnqn?
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Re: [PATCH 1/7] nvmet: make discovery NQN configurable
In reply to Hannes ReineckeQuoted 93 lines · Hannes Reinecke
TPAR8013 allows for unique discovery NQNs, so make the discovery controller NQN configurable by exposing a subsys attribute '
discovery_nqn'.Signed-off-by Hannes Reinecke <[email protected]>---
drivers/nvme/target/configfs.c| 39 ++++++++++++++++++++++++++++++++++drivers/nvme/target/core.c| 3 ++-2 files changed, 41 insertions(+), 1 deletion(-)drivers/nvme/target/configfs.c +39
-0@@ -1233,6 +1233,44 @@ static ssize_t nvmet_subsys_attr_model_store(struct config_item *item, }CONFIGFS_ATTR (nvmet_subsys_, attr_model); +static ssize_t nvmet_subsys_attr_discovery_nqn_show (struct config_item *item, +char *page) +{ +return snprintf (page,PAGE_SIZE ,"%s\n" , + nvmet_disc_subsys->subsysnqn); +} + +static ssize_t nvmet_subsys_attr_discovery_nqn_store (struct config_item *item, +const char *page,size_t count) +{ +struct nvmet_subsys *subsys =to_subsys (item); +char *subsysnqn; +int len; + + len =strcspn (page,"\n" ); +if (!len) +return -EINVAL ; + + subsysnqn =kmemdup_nul (page, len,GFP_KERNEL ); +if (!subsysnqn) +return -ENOMEM ; + +/* +* The discovery NQN must be different from subsystem NQN. +*/ +if (!strcmp (subsysnqn, subsys->subsysnqn)) { +kfree (subsysnqn); +return -EBUSY ; + } +down_write (&nvmet_config_sem); +kfree (nvmet_disc_subsys->subsysnqn); + nvmet_disc_subsys->subsysnqn = subsysnqn; +up_write (&nvmet_config_sem); + +return count; +} +CONFIGFS_ATTR (nvmet_subsys_, attr_discovery_nqn); +#ifdef CONFIG_BLK_DEV_INTEGRITY static ssize_t nvmet_subsys_attr_pi_enable_show (struct config_item *item,char *page)@@ -1262,6 +1300,7 @@ static struct configfs_attribute *nvmet_subsys_attrs[] = { &nvmet_subsys_attr_attr_cntlid_min, &nvmet_subsys_attr_attr_cntlid_max, &nvmet_subsys_attr_attr_model, + &nvmet_subsys_attr_attr_discovery_nqn, #ifdef CONFIG_BLK_DEV_INTEGRITY &nvmet_subsys_attr_attr_pi_enable, #endifdrivers/nvme/target/core.c +2
-1@@ -1491,7 +1491,8 @@ static struct nvmet_subsys *nvmet_find_get_subsys(struct nvmet_port *port,if (!port)return NULL ; -if (!strcmp (NVME_DISC_SUBSYS_NAME , subsysnqn)) { +if (!strcmp (NVME_DISC_SUBSYS_NAME , subsysnqn) || + !strcmp (nvmet_disc_subsys->subsysnqn, subsysnqn)) {if (!kref_get_unless_zero (&nvmet_disc_subsys->ref))return NULL ;return nvmet_disc_subsys;Signature · 7 lines
2.29.2 _______________________________________________ Linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Aah .. .did not see this updated version in my inbox while reviewing …
--
Himanshu Madhani Oracle Linux Engineering
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Re: [PATCH 3/7] nvmet: add nvmet_is_disc_subsys() helper
In reply to Hannes ReineckeQuoted 82 lines · Hannes Reinecke
Add a helper function to determine if a given subsystem is a discovery subsystem.
Signed-off-by Hannes Reinecke <[email protected]>---
drivers/nvme/target/admin-cmd.c | 2 +- drivers/nvme/target/core.c | 6 +++--- drivers/nvme/target/nvmet.h | 5 +++++ 3 files changed, 9 insertions(+), 4 deletions(-)drivers/nvme/target/admin-cmd.c +1
-1@@ -1008,7 +1008,7 @@ u16 nvmet_parse_admin_cmd(struct nvmet_req *req)if (nvme_is_fabrics (cmd))return nvmet_parse_fabrics_cmd (req); -if (nvmet_req_subsys (req)->type ==NVME_NQN_DISC ) +if (nvmet_is_disc_subsys (nvmet_req_subsys (req)))return nvmet_parse_discovery_cmd (req); ret =nvmet_check_ctrl_status (req);drivers/nvme/target/core.c +3
-3@@ -1140,7 +1140,7 @@ static void nvmet_start_ctrl(struct nvmet_ctrl *ctrl)* should verify iosqes,iocqes are zeroed, however that * would break backwards compatibility, so don't enforce it. */ -if (ctrl->subsys->type !=NVME_NQN_DISC && +if (!nvmet_is_disc_subsys (ctrl->subsys) && (nvmet_cc_iosqes (ctrl->cc) !=NVME_NVM_IOSQES ||nvmet_cc_iocqes (ctrl->cc) !=NVME_NVM_IOCQES )) { ctrl->csts =NVME_CSTS_CFS ;@@ -1278,7 +1278,7 @@ bool nvmet_host_allowed(struct nvmet_subsys *subsys, const char *hostnqn)if (subsys->allow_any_host)return true; -if (subsys->type ==NVME_NQN_DISC )/* allow all access to disc subsys */ +if (nvmet_is_disc_subsys (subsys))/* allow all access to disc subsys */ return true;list_for_each_entry (p, &subsys->hosts, entry) {@@ -1411,7 +1411,7 @@ u16 nvmet_alloc_ctrl(const char *subsysnqn, const char *hostnqn,* Discovery controllers may use some arbitrary high value * in order to cleanup stale discovery sessions */ -if ((ctrl->subsys->type ==NVME_NQN_DISC ) && !kato) +if (nvmet_is_disc_subsys (ctrl->subsys) && !kato) kato =NVMET_DISC_KATO_MS ;/* keep-alive timeout in seconds */ drivers/nvme/target/nvmet.h +5
-0@@ -576,6 +576,11 @@ static inline struct nvmet_subsys *nvmet_req_subsys(struct nvmet_req *req)return req->sq->ctrl->subsys; } +static inline bool nvmet_is_disc_subsys (struct nvmet_subsys *subsys) +{ +return subsys->type ==NVME_NQN_DISC ; +} +#ifdef CONFIG_NVME_TARGET_PASSTHRU void nvmet_passthru_subsys_free (struct nvmet_subsys *subsys);int nvmet_passthru_ctrl_enable (struct nvmet_subsys *subsys);Signature · 7 lines
2.29.2 _______________________________________________ Linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Looks Good.
--
Himanshu Madhani Oracle Linux Engineering
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Re: [PATCH 2/7] nvme: add CNTRLTYPE definitions for 'identify controller'
In reply to Hannes ReineckeQuoted 49 lines · Hannes Reinecke
Update the 'identify controller' structure to define the missing CNTRLTYPE field.
Signed-off-by Hannes Reinecke <[email protected]>Reviewed-by Chaitanya Kulkarni <[email protected]>---
include/linux/nvme.h| 10 +++++++++-1 file changed, 9 insertions(+), 1 deletion(-)include/linux/nvme.h +9
-1@@ -31,6 +31,12 @@ enum nvme_subsys_type { NVME_NQN_NVME = 2, /* NVME type target subsystem */ }; +enum nvme_ctrl_type { +NVME_CTRL_IO =1 ,/* I/O controller */ +NVME_CTRL_DISC =2 ,/* Discovery controller */ +NVME_CTRL_ADMIN =3 ,/* Administrative controller */ +}; +/* Address Family codes for Discovery Log Page entry ADRFAM field */ enum {NVMF_ADDR_FAMILY_PCI =0 ,/* PCIe */ @@ -244,7 +250,9 @@ struct nvme_id_ctrl {__le32 rtd3e;__le32 oaes;__le32 ctratt; -__u8 rsvd100[28 ]; +__u8 rsvd100[11 ]; +__u8 cntrltype; +__u8 fguid[16 ];__le16 crdt1;__le16 crdt2;__le16 crdt3;Signature · 7 lines
2.29.2 _______________________________________________ Linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Looks Good.
--
Himanshu Madhani Oracle Linux Engineering
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Re: [PATCH 6/7] nvme: Add connect option 'discovery'
In reply to Hannes ReineckeQuoted 70 lines · Hannes Reinecke
Add a connect option 'discovery' to specify that the connection should be made to a discovery controller, not a normal I/O controller. With discovery controllers supporting unique subsystem NQNs we cannot easily distinguish by the subsystem NQN if this should be a discovery connection, but we need this information to blank out options not supported by discovery controllers.
Signed-off-by Hannes Reinecke <[email protected]>Reviewed-by Chaitanya Kulkarni <[email protected]>--- drivers/nvme/host/core.c | 7 +++++++ drivers/nvme/host/fabrics.c | 6 +++++- drivers/nvme/host/fabrics.h | 1 + 3 files changed, 13 insertions(+), 1 deletion(-)drivers/nvme/host/core.c +7
-0@@ -2715,6 +2715,13 @@ static int nvme_init_subsystem(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)else subsys->subtype =NVME_NQN_NVME ; +if (nvme_discovery_ctrl (ctrl) && subsys->subtype !=NVME_NQN_DISC ) { +dev_err (ctrl->device, +"Subsystem %s is not a discovery controller" , + subsys->subnqn); +kfree (subsys); +return -EINVAL ; + } subsys->awupf =le16_to_cpu (id->awupf);#ifdef CONFIG_NVME_MULTIPATH subsys->iopolicy =NVME_IOPOLICY_NUMA ;drivers/nvme/host/fabrics.c +5
-1@@ -548,6 +548,7 @@ static const match_table_t opt_tokens = { { NVMF_OPT_NR_POLL_QUEUES, "nr_poll_queues=%d" }, { NVMF_OPT_TOS, "tos=%d" }, { NVMF_OPT_FAIL_FAST_TMO, "fast_io_fail_tmo=%d" }, + { NVMF_OPT_DISCOVERY, "discovery" }, { NVMF_OPT_ERR, NULL } };@@ -823,6 +824,9 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts, } opts->tos = token;break ; +case NVMF_OPT_DISCOVERY : + opts->discovery_nqn = true; +break ;default :pr_warn ("unknown parameter or missing value '%s' in ctrl creation request\n" , p);@@ -949,7 +953,7 @@ EXPORT_SYMBOL_GPL(nvmf_free_options);#define NVMF_ALLOWED_OPTS (NVMF_OPT_QUEUE_SIZE | NVMF_OPT_NR_IO_QUEUES | \ NVMF_OPT_KATO | NVMF_OPT_HOSTNQN | \ NVMF_OPT_HOST_ID | NVMF_OPT_DUP_CONNECT |\ - NVMF_OPT_DISABLE_SQFLOW |\ + NVMF_OPT_DISABLE_SQFLOW | NVMF_OPT_DISCOVERY |\ NVMF_OPT_FAIL_FAST_TMO) static struct nvme_ctrl *drivers/nvme/host/fabrics.h +0
-0
drivers/nvme/host/fabrics.h enum { · line 73
Quoted 7 lines
drivers/nvme/host/fabrics.h +1
-0@@ -67,6 +67,7 @@ enum {NVMF_OPT_TOS =1 <<19 ,NVMF_OPT_FAIL_FAST_TMO =1 <<20 ,NVMF_OPT_HOST_IFACE =1 <<21 , + NVMF_OPT_DISCOVERY = 1 << 22, };/**
I think you need to be patching __nvme_find_get_subsystem(), which looks for subsystem name and opts out (allowing multiple connects to discovery subsystems) if discovery controller nqn.
e.g. the loop matching subsys name (assuming discovery ctlr now has a unique name) continues if subsys->subtype is NVME_NQN_DISC
-- james
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Re: [PATCH 6/7] nvme: Add connect option 'discovery'
Quoted 80 lines · James Smart
Quoted 68 lines · Hannes Reinecke
Add a connect option 'discovery' to specify that the connection should be made to a discovery controller, not a normal I/O controller. With discovery controllers supporting unique subsystem NQNs we cannot easily distinguish by the subsystem NQN if this should be a discovery connection, but we need this information to blank out options not supported by discovery controllers.
Signed-off-by Hannes Reinecke <[email protected]>Reviewed-by Chaitanya Kulkarni <[email protected]>---
drivers/nvme/host/core.c | 7 +++++++
drivers/nvme/host/fabrics.c| 6 +++++-
drivers/nvme/host/fabrics.h| 1 +3 files changed, 13 insertions(+), 1 deletion(-)drivers/nvme/host/core.c +0
-0@@ -2715,6 +2715,13 @@ static int nvme_init_subsystem(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)else
subsys->subtype=NVME_NQN_NVME;
+ if (nvme_discovery_ctrl(ctrl)&&subsys->subtype!=NVME_NQN_DISC) { + dev_err(ctrl->device,
+ "Subsystem %s is not a discovery controller",
+subsys->subnqn);
+ kfree(subsys);
+ return-EINVAL;
+ }
subsys->awupf=le16_to_cpu(id->awupf);
#ifdefCONFIG_NVME_MULTIPATH
subsys->iopolicy=NVME_IOPOLICY_NUMA;drivers/nvme/host/fabrics.c +4
-0@@ -548,6 +548,7 @@ static const match_table_t opt_tokens = { { NVMF_OPT_NR_POLL_QUEUES, "nr_poll_queues=%d" }, { NVMF_OPT_TOS, "tos=%d" }, { NVMF_OPT_FAIL_FAST_TMO, "fast_io_fail_tmo=%d" }, + { NVMF_OPT_DISCOVERY, "discovery" }, { NVMF_OPT_ERR, NULL } };@@ -823,6 +824,9 @@ static int nvmf_parse_options(structnvmf_ctrl_options *opts, } opts->tos = token; break; + case NVMF_OPT_DISCOVERY: + opts->discovery_nqn = true; + break;default:
pr_warn("unknown parameter or missing value '%s' in ctrl creation request\n", p);drivers/nvme/host/fabrics.c +1
-1@@ -949,7 +953,7 @@ EXPORT_SYMBOL_GPL(nvmf_free_options); #define NVMF_ALLOWED_OPTS (NVMF_OPT_QUEUE_SIZE | NVMF_OPT_NR_IO_QUEUES | \ NVMF_OPT_KATO | NVMF_OPT_HOSTNQN | \ NVMF_OPT_HOST_ID | NVMF_OPT_DUP_CONNECT |\ - NVMF_OPT_DISABLE_SQFLOW |\ + NVMF_OPT_DISABLE_SQFLOW | NVMF_OPT_DISCOVERY |\ NVMF_OPT_FAIL_FAST_TMO)static struct
nvme_ctrl*drivers/nvme/host/fabrics.h +0
-0drivers/nvme/host/fabrics.h enum { · line 73
Quoted 7 lines
drivers/nvme/host/fabrics.h +1
-0@@ -67,6 +67,7 @@ enum { NVMF_OPT_TOS = 1 << 19, NVMF_OPT_FAIL_FAST_TMO = 1 << 20, NVMF_OPT_HOST_IFACE = 1 << 21, + NVMF_OPT_DISCOVERY = 1 << 22, }; /**I think you need to be patching
__nvme_find_get_subsystem(), which looks for subsystem name and opts out (allowing multiple connects to discovery subsystems) if discovery controller nqn.
Quoted 2 lines
e.g. the loop matching subsys name (assuming discovery ctlr now has a unique name) continues if
subsys->subtypeisNVME_NQN_DISC
Ah. You spotted it.
That is actually by design.
The sole reason (from my perspective) for this condition is precisely because we cannot currently identify discovery subsystems. So we need to create individual discovery subsystems for each controller. But with this patch we can, so we _can_ figure out if two controllers are attached to the same discovery subsystem.
Cheers,
Hannes
Signature · 9 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 _______________________________________________ Linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Thanks,
applied to nvme-5.15.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Christoph Hellwig
maintainerRe: [PATCH 5/7] nvme: expose subsystem type in sysfs attribute 'subtype'
In reply to Daniel WagnerQuoted 14 lines · Daniel Wagner
drivers/nvme/host/core.c static struct attribute *nvme_subsys_attrs[] = { · line 2639
Quoted 10 lines · Hannes Reinecke
drivers/nvme/host/core.c +3
-0+static SUBSYS_ATTR_RO(subtype, S_IRUGO, nvme_subsys_show_subtype); +#define nvme_subsys_show_str_function (field) \ static ssize_t subsys_##field##_show(struct device *dev, \ struct device_attribute *attr, char *buf) \@@ -2618,6 +2636,7 @@ static struct attribute *nvme_subsys_attrs[] = { &subsys_attr_serial.attr, &subsys_attr_firmware_rev.attr, &subsys_attr_subsysnqn.attr, + &subsys_attr_subtype.attr,Shouldn't this be subsystype to stay consistent with subsysnqn?
Hannes? I've aplied the patch for now, but the above seems like a useful fixup to fold in.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Re: [PATCH 5/7] nvme: expose subsystem type in sysfs attribute 'subtype'
Quoted 16 lines · Christoph Hellwig
Quoted 14 lines · Daniel Wagner
drivers/nvme/host/core.c static struct attribute *nvme_subsys_attrs[] = { · line 2639
Quoted 10 lines · Hannes Reinecke
drivers/nvme/host/core.c +3
-0+static SUBSYS_ATTR_RO(subtype, S_IRUGO, nvme_subsys_show_subtype); +#define nvme_subsys_show_str_function (field) \ static ssize_t subsys_##field##_show(struct device *dev, \ struct device_attribute *attr, char *buf) \@@ -2618,6 +2636,7 @@ static struct attribute *nvme_subsys_attrs[] = { &subsys_attr_serial.attr, &subsys_attr_firmware_rev.attr, &subsys_attr_subsysnqn.attr, + &subsys_attr_subtype.attr,Shouldn't this be subsystype to stay consistent with subsysnqn?
Quoted 3 lines
Hannes? I've aplied the patch for now, but the above seems like a useful fixup to fold in.
I don't really care. Should I send you a patch to update it?
Cheers,
Hannes
Signature · 9 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), GF: Felix Imendörffer _______________________________________________ Linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Christoph Hellwig
maintainerRe: [PATCH 5/7] nvme: expose subsystem type in sysfs attribute 'subtype'
Quoted 11 lines · Hannes Reinecke
Quoted 10 lines
Quoted 6 lines
drivers/nvme/host/core.c static struct attribute *nvme_subsys_attrs[] = { · line 2639
Quoted 3 lines
drivers/nvme/host/core.c +1
-0&subsys_attr_firmware_rev.attr, &subsys_attr_subsysnqn.attr, + &subsys_attr_subtype.attr,Shouldn't this be subsystype to stay consistent with subsysnqn?
Hannes? I've aplied the patch for now, but the above seems like a useful fixup to fold in.
I don't really care. Should I send you a patch to update it?
That would be nice.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme