* [PATCH 1/7] nvmet: make discovery NQN configurable
2021-09-22 6:35 [PATCHv3 0/7] nvme: support unique discovery controller NQN Hannes Reinecke
@ 2021-09-22 6:35 ` Hannes Reinecke
2021-09-22 7:07 ` Chaitanya Kulkarni
2021-09-22 13:36 ` Himanshu Madhani
2021-09-22 6:35 ` [PATCH 2/7] nvme: add CNTRLTYPE definitions for 'identify controller' Hannes Reinecke
` (6 subsequent siblings)
7 siblings, 2 replies; 21+ messages in thread
From: Hannes Reinecke @ 2021-09-22 6:35 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Sagi Grimberg, Keith Busch, Chaitanya Kulkarni, linux-nvme,
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 <hare@suse.de>
---
drivers/nvme/target/configfs.c | 39 ++++++++++++++++++++++++++++++++++
drivers/nvme/target/core.c | 3 ++-
2 files changed, 41 insertions(+), 1 deletion(-)
diff --git a/drivers/nvme/target/configfs.c b/drivers/nvme/target/configfs.c
index be5d82421e3a..4873564384a3 100644
--- a/drivers/nvme/target/configfs.c
+++ b/drivers/nvme/target/configfs.c
@@ -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
diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
index b8425fa34300..88ed746c675f 100644
--- a/drivers/nvme/target/core.c
+++ b/drivers/nvme/target/core.c
@@ -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;
--
2.29.2
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH 1/7] nvmet: make discovery NQN configurable
2021-09-22 6:35 ` [PATCH 1/7] nvmet: make discovery NQN configurable Hannes Reinecke
@ 2021-09-22 7:07 ` Chaitanya Kulkarni
2021-09-22 13:36 ` Himanshu Madhani
1 sibling, 0 replies; 21+ messages in thread
From: Chaitanya Kulkarni @ 2021-09-22 7:07 UTC (permalink / raw)
To: Hannes Reinecke, Christoph Hellwig; +Cc: Sagi Grimberg, Keith Busch, linux-nvme
On 9/21/21 23:35, Hannes Reinecke wrote:
> 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 <hare@suse.de>
> ---
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 1/7] nvmet: make discovery NQN configurable
2021-09-22 6:35 ` [PATCH 1/7] nvmet: make discovery NQN configurable Hannes Reinecke
2021-09-22 7:07 ` Chaitanya Kulkarni
@ 2021-09-22 13:36 ` Himanshu Madhani
1 sibling, 0 replies; 21+ messages in thread
From: Himanshu Madhani @ 2021-09-22 13:36 UTC (permalink / raw)
To: Hannes Reinecke
Cc: Christoph Hellwig, Sagi Grimberg, Keith Busch,
Chaitanya Kulkarni, linux-nvme
> On Sep 22, 2021, at 1:35 AM, Hannes Reinecke <hare@suse.de> wrote:
>
> 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 <hare@suse.de>
> ---
> drivers/nvme/target/configfs.c | 39 ++++++++++++++++++++++++++++++++++
> drivers/nvme/target/core.c | 3 ++-
> 2 files changed, 41 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/nvme/target/configfs.c b/drivers/nvme/target/configfs.c
> index be5d82421e3a..4873564384a3 100644
> --- a/drivers/nvme/target/configfs.c
> +++ b/drivers/nvme/target/configfs.c
> @@ -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
> diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
> index b8425fa34300..88ed746c675f 100644
> --- a/drivers/nvme/target/core.c
> +++ b/drivers/nvme/target/core.c
> @@ -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;
> --
> 2.29.2
>
>
> _______________________________________________
> Linux-nvme mailing list
> Linux-nvme@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-nvme
Aah .. .did not see this updated version in my inbox while reviewing …
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
--
Himanshu Madhani Oracle Linux Engineering
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 2/7] nvme: add CNTRLTYPE definitions for 'identify controller'
2021-09-22 6:35 [PATCHv3 0/7] nvme: support unique discovery controller NQN Hannes Reinecke
2021-09-22 6:35 ` [PATCH 1/7] nvmet: make discovery NQN configurable Hannes Reinecke
@ 2021-09-22 6:35 ` Hannes Reinecke
2021-09-22 13:37 ` Himanshu Madhani
2021-09-22 6:35 ` [PATCH 3/7] nvmet: add nvmet_is_disc_subsys() helper Hannes Reinecke
` (5 subsequent siblings)
7 siblings, 1 reply; 21+ messages in thread
From: Hannes Reinecke @ 2021-09-22 6:35 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Sagi Grimberg, Keith Busch, Chaitanya Kulkarni, linux-nvme,
Hannes Reinecke, Chaitanya Kulkarni
Update the 'identify controller' structure to define the missing
CNTRLTYPE field.
Signed-off-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
---
include/linux/nvme.h | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/include/linux/nvme.h b/include/linux/nvme.h
index b7c4c4130b65..ed2428918bca 100644
--- a/include/linux/nvme.h
+++ b/include/linux/nvme.h
@@ -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;
--
2.29.2
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH 2/7] nvme: add CNTRLTYPE definitions for 'identify controller'
2021-09-22 6:35 ` [PATCH 2/7] nvme: add CNTRLTYPE definitions for 'identify controller' Hannes Reinecke
@ 2021-09-22 13:37 ` Himanshu Madhani
0 siblings, 0 replies; 21+ messages in thread
From: Himanshu Madhani @ 2021-09-22 13:37 UTC (permalink / raw)
To: Hannes Reinecke
Cc: Christoph Hellwig, Sagi Grimberg, Keith Busch,
Chaitanya Kulkarni, linux-nvme, Chaitanya Kulkarni
> On Sep 22, 2021, at 1:35 AM, Hannes Reinecke <hare@suse.de> wrote:
>
> Update the 'identify controller' structure to define the missing
> CNTRLTYPE field.
>
> Signed-off-by: Hannes Reinecke <hare@suse.de>
> Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
> ---
> include/linux/nvme.h | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/nvme.h b/include/linux/nvme.h
> index b7c4c4130b65..ed2428918bca 100644
> --- a/include/linux/nvme.h
> +++ b/include/linux/nvme.h
> @@ -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;
> --
> 2.29.2
>
>
> _______________________________________________
> Linux-nvme mailing list
> Linux-nvme@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-nvme
Looks Good.
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
--
Himanshu Madhani Oracle Linux Engineering
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 3/7] nvmet: add nvmet_is_disc_subsys() helper
2021-09-22 6:35 [PATCHv3 0/7] nvme: support unique discovery controller NQN Hannes Reinecke
2021-09-22 6:35 ` [PATCH 1/7] nvmet: make discovery NQN configurable Hannes Reinecke
2021-09-22 6:35 ` [PATCH 2/7] nvme: add CNTRLTYPE definitions for 'identify controller' Hannes Reinecke
@ 2021-09-22 6:35 ` Hannes Reinecke
2021-09-22 7:06 ` Chaitanya Kulkarni
2021-09-22 13:36 ` Himanshu Madhani
2021-09-22 6:35 ` [PATCH 4/7] nvmet: set 'CNTRLTYPE' in the identify controller data Hannes Reinecke
` (4 subsequent siblings)
7 siblings, 2 replies; 21+ messages in thread
From: Hannes Reinecke @ 2021-09-22 6:35 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Sagi Grimberg, Keith Busch, Chaitanya Kulkarni, linux-nvme,
Hannes Reinecke
Add a helper function to determine if a given subsystem is a discovery
subsystem.
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
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(-)
diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index aa6d84d8848e..b653ea4244fe 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -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);
diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
index 88ed746c675f..61ceb42717f1 100644
--- a/drivers/nvme/target/core.c
+++ b/drivers/nvme/target/core.c
@@ -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 */
diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h
index 7143c7fa7464..93a86d6053ef 100644
--- a/drivers/nvme/target/nvmet.h
+++ b/drivers/nvme/target/nvmet.h
@@ -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);
--
2.29.2
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH 3/7] nvmet: add nvmet_is_disc_subsys() helper
2021-09-22 6:35 ` [PATCH 3/7] nvmet: add nvmet_is_disc_subsys() helper Hannes Reinecke
@ 2021-09-22 7:06 ` Chaitanya Kulkarni
2021-09-22 13:36 ` Himanshu Madhani
1 sibling, 0 replies; 21+ messages in thread
From: Chaitanya Kulkarni @ 2021-09-22 7:06 UTC (permalink / raw)
To: Hannes Reinecke; +Cc: Sagi Grimberg, Keith Busch, linux-nvme, Christoph Hellwig
On 9/21/21 23:35, Hannes Reinecke wrote:
>
>
> Add a helper function to determine if a given subsystem is a discovery
> subsystem.
>
> Signed-off-by: Hannes Reinecke <hare@suse.de>
Looks good.
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 3/7] nvmet: add nvmet_is_disc_subsys() helper
2021-09-22 6:35 ` [PATCH 3/7] nvmet: add nvmet_is_disc_subsys() helper Hannes Reinecke
2021-09-22 7:06 ` Chaitanya Kulkarni
@ 2021-09-22 13:36 ` Himanshu Madhani
1 sibling, 0 replies; 21+ messages in thread
From: Himanshu Madhani @ 2021-09-22 13:36 UTC (permalink / raw)
To: Hannes Reinecke
Cc: Christoph Hellwig, Sagi Grimberg, Keith Busch,
Chaitanya Kulkarni, linux-nvme
> On Sep 22, 2021, at 1:35 AM, Hannes Reinecke <hare@suse.de> wrote:
>
> Add a helper function to determine if a given subsystem is a discovery
> subsystem.
>
> Signed-off-by: Hannes Reinecke <hare@suse.de>
> ---
> 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(-)
>
> diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
> index aa6d84d8848e..b653ea4244fe 100644
> --- a/drivers/nvme/target/admin-cmd.c
> +++ b/drivers/nvme/target/admin-cmd.c
> @@ -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);
> diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
> index 88ed746c675f..61ceb42717f1 100644
> --- a/drivers/nvme/target/core.c
> +++ b/drivers/nvme/target/core.c
> @@ -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 */
> diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h
> index 7143c7fa7464..93a86d6053ef 100644
> --- a/drivers/nvme/target/nvmet.h
> +++ b/drivers/nvme/target/nvmet.h
> @@ -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);
> --
> 2.29.2
>
>
> _______________________________________________
> Linux-nvme mailing list
> Linux-nvme@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-nvme
Looks Good.
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
--
Himanshu Madhani Oracle Linux Engineering
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 4/7] nvmet: set 'CNTRLTYPE' in the identify controller data
2021-09-22 6:35 [PATCHv3 0/7] nvme: support unique discovery controller NQN Hannes Reinecke
` (2 preceding siblings ...)
2021-09-22 6:35 ` [PATCH 3/7] nvmet: add nvmet_is_disc_subsys() helper Hannes Reinecke
@ 2021-09-22 6:35 ` Hannes Reinecke
2021-09-22 7:08 ` Chaitanya Kulkarni
2021-09-22 6:35 ` [PATCH 5/7] nvme: expose subsystem type in sysfs attribute 'subtype' Hannes Reinecke
` (3 subsequent siblings)
7 siblings, 1 reply; 21+ messages in thread
From: Hannes Reinecke @ 2021-09-22 6:35 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Sagi Grimberg, Keith Busch, Chaitanya Kulkarni, linux-nvme,
Hannes Reinecke
Set the correct 'CNTRLTYPE' field in the identify controller data.
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
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(-)
diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index b653ea4244fe..0428bf203fa5 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -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.
diff --git a/drivers/nvme/target/discovery.c b/drivers/nvme/target/discovery.c
index 7aa62bc6ae84..7b360f8d07e9 100644
--- a/drivers/nvme/target/discovery.c
+++ b/drivers/nvme/target/discovery.c
@@ -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);
diff --git a/drivers/nvme/target/fabrics-cmd.c b/drivers/nvme/target/fabrics-cmd.c
index 7d0454cee920..70fb587e9413 100644
--- a/drivers/nvme/target/fabrics-cmd.c
+++ b/drivers/nvme/target/fabrics-cmd.c
@@ -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);
--
2.29.2
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 5/7] nvme: expose subsystem type in sysfs attribute 'subtype'
2021-09-22 6:35 [PATCHv3 0/7] nvme: support unique discovery controller NQN Hannes Reinecke
` (3 preceding siblings ...)
2021-09-22 6:35 ` [PATCH 4/7] nvmet: set 'CNTRLTYPE' in the identify controller data Hannes Reinecke
@ 2021-09-22 6:35 ` Hannes Reinecke
2021-09-22 8:02 ` Daniel Wagner
2021-09-22 6:35 ` [PATCH 6/7] nvme: Add connect option 'discovery' Hannes Reinecke
` (2 subsequent siblings)
7 siblings, 1 reply; 21+ messages in thread
From: Hannes Reinecke @ 2021-09-22 6:35 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Sagi Grimberg, Keith Busch, Chaitanya Kulkarni, linux-nvme,
Hannes Reinecke, Chaitanya Kulkarni
With 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'.
Signed-off-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
---
drivers/nvme/host/core.c | 27 +++++++++++++++++++++++++++
drivers/nvme/host/nvme.h | 1 +
2 files changed, 28 insertions(+)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index e486845d2c7e..1ed1b7be2812 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -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;
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index 9871c0c9374c..2c7a77f600f8 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -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;
--
2.29.2
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH 5/7] nvme: expose subsystem type in sysfs attribute 'subtype'
2021-09-22 6:35 ` [PATCH 5/7] nvme: expose subsystem type in sysfs attribute 'subtype' Hannes Reinecke
@ 2021-09-22 8:02 ` Daniel Wagner
2021-10-12 13:10 ` Christoph Hellwig
0 siblings, 1 reply; 21+ messages in thread
From: Daniel Wagner @ 2021-09-22 8:02 UTC (permalink / raw)
To: Hannes Reinecke
Cc: Christoph Hellwig, Sagi Grimberg, Keith Busch,
Chaitanya Kulkarni, linux-nvme, Chaitanya Kulkarni
On Wed, Sep 22, 2021 at 08:35:23AM +0200, Hannes Reinecke wrote:
> +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
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 5/7] nvme: expose subsystem type in sysfs attribute 'subtype'
2021-09-22 8:02 ` Daniel Wagner
@ 2021-10-12 13:10 ` Christoph Hellwig
2021-10-12 13:43 ` Hannes Reinecke
0 siblings, 1 reply; 21+ messages in thread
From: Christoph Hellwig @ 2021-10-12 13:10 UTC (permalink / raw)
To: Daniel Wagner
Cc: Hannes Reinecke, Christoph Hellwig, Sagi Grimberg, Keith Busch,
Chaitanya Kulkarni, linux-nvme, Chaitanya Kulkarni
On Wed, Sep 22, 2021 at 10:02:56AM +0200, Daniel Wagner wrote:
> On Wed, Sep 22, 2021 at 08:35:23AM +0200, Hannes Reinecke wrote:
> > +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
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 5/7] nvme: expose subsystem type in sysfs attribute 'subtype'
2021-10-12 13:10 ` Christoph Hellwig
@ 2021-10-12 13:43 ` Hannes Reinecke
2021-10-12 13:44 ` Christoph Hellwig
0 siblings, 1 reply; 21+ messages in thread
From: Hannes Reinecke @ 2021-10-12 13:43 UTC (permalink / raw)
To: Christoph Hellwig, Daniel Wagner
Cc: Sagi Grimberg, Keith Busch, Chaitanya Kulkarni, linux-nvme,
Chaitanya Kulkarni
On 10/12/21 3:10 PM, Christoph Hellwig wrote:
> On Wed, Sep 22, 2021 at 10:02:56AM +0200, Daniel Wagner wrote:
>> On Wed, Sep 22, 2021 at 08:35:23AM +0200, Hannes Reinecke wrote:
>>> +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.
>
I don't really care. Should I send you a patch to update it?
Cheers,
Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
hare@suse.de +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
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 5/7] nvme: expose subsystem type in sysfs attribute 'subtype'
2021-10-12 13:43 ` Hannes Reinecke
@ 2021-10-12 13:44 ` Christoph Hellwig
0 siblings, 0 replies; 21+ messages in thread
From: Christoph Hellwig @ 2021-10-12 13:44 UTC (permalink / raw)
To: Hannes Reinecke
Cc: Christoph Hellwig, Daniel Wagner, Sagi Grimberg, Keith Busch,
Chaitanya Kulkarni, linux-nvme, Chaitanya Kulkarni
On Tue, Oct 12, 2021 at 03:43:22PM +0200, Hannes Reinecke wrote:
> >>> &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
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 6/7] nvme: Add connect option 'discovery'
2021-09-22 6:35 [PATCHv3 0/7] nvme: support unique discovery controller NQN Hannes Reinecke
` (4 preceding siblings ...)
2021-09-22 6:35 ` [PATCH 5/7] nvme: expose subsystem type in sysfs attribute 'subtype' Hannes Reinecke
@ 2021-09-22 6:35 ` Hannes Reinecke
2021-09-22 16:59 ` James Smart
2021-09-22 6:35 ` [PATCH 7/7] nvme: display correct subsystem NQN Hannes Reinecke
2021-10-12 13:10 ` [PATCHv3 0/7] nvme: support unique discovery controller NQN Christoph Hellwig
7 siblings, 1 reply; 21+ messages in thread
From: Hannes Reinecke @ 2021-09-22 6:35 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Sagi Grimberg, Keith Busch, Chaitanya Kulkarni, linux-nvme,
Hannes Reinecke, Chaitanya Kulkarni
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 <hare@suse.de>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
---
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(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 1ed1b7be2812..ad01e2778cb6 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -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;
diff --git a/drivers/nvme/host/fabrics.c b/drivers/nvme/host/fabrics.c
index 668c6bb7a567..c5a2b71c5268 100644
--- a/drivers/nvme/host/fabrics.c
+++ b/drivers/nvme/host/fabrics.c
@@ -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 *
diff --git a/drivers/nvme/host/fabrics.h b/drivers/nvme/host/fabrics.h
index a146cb903869..b61b666e10ec 100644
--- a/drivers/nvme/host/fabrics.h
+++ b/drivers/nvme/host/fabrics.h
@@ -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,
};
/**
--
2.29.2
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH 6/7] nvme: Add connect option 'discovery'
2021-09-22 6:35 ` [PATCH 6/7] nvme: Add connect option 'discovery' Hannes Reinecke
@ 2021-09-22 16:59 ` James Smart
2021-09-23 6:11 ` Hannes Reinecke
0 siblings, 1 reply; 21+ messages in thread
From: James Smart @ 2021-09-22 16:59 UTC (permalink / raw)
To: Hannes Reinecke, Christoph Hellwig
Cc: Sagi Grimberg, Keith Busch, Chaitanya Kulkarni, linux-nvme,
Chaitanya Kulkarni
On 9/21/2021 11:35 PM, Hannes Reinecke wrote:
> 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 <hare@suse.de>
> Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
> ---
> 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(-)
>
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index 1ed1b7be2812..ad01e2778cb6 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -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;
> diff --git a/drivers/nvme/host/fabrics.c b/drivers/nvme/host/fabrics.c
> index 668c6bb7a567..c5a2b71c5268 100644
> --- a/drivers/nvme/host/fabrics.c
> +++ b/drivers/nvme/host/fabrics.c
> @@ -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 *
> diff --git a/drivers/nvme/host/fabrics.h b/drivers/nvme/host/fabrics.h
> index a146cb903869..b61b666e10ec 100644
> --- a/drivers/nvme/host/fabrics.h
> +++ b/drivers/nvme/host/fabrics.h
> @@ -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
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 6/7] nvme: Add connect option 'discovery'
2021-09-22 16:59 ` James Smart
@ 2021-09-23 6:11 ` Hannes Reinecke
0 siblings, 0 replies; 21+ messages in thread
From: Hannes Reinecke @ 2021-09-23 6:11 UTC (permalink / raw)
To: James Smart, Christoph Hellwig
Cc: Sagi Grimberg, Keith Busch, Chaitanya Kulkarni, linux-nvme,
Chaitanya Kulkarni
On 9/22/21 6:59 PM, James Smart wrote:
> On 9/21/2021 11:35 PM, Hannes Reinecke wrote:
>> 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 <hare@suse.de>
>> Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
>> ---
>> 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(-)
>>
>> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
>> index 1ed1b7be2812..ad01e2778cb6 100644
>> --- a/drivers/nvme/host/core.c
>> +++ b/drivers/nvme/host/core.c
>> @@ -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;
>> diff --git a/drivers/nvme/host/fabrics.c b/drivers/nvme/host/fabrics.c
>> index 668c6bb7a567..c5a2b71c5268 100644
>> --- a/drivers/nvme/host/fabrics.c
>> +++ b/drivers/nvme/host/fabrics.c
>> @@ -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 *
>> diff --git a/drivers/nvme/host/fabrics.h b/drivers/nvme/host/fabrics.h
>> index a146cb903869..b61b666e10ec 100644
>> --- a/drivers/nvme/host/fabrics.h
>> +++ b/drivers/nvme/host/fabrics.h
>> @@ -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
>
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
--
Dr. Hannes Reinecke Kernel Storage Architect
hare@suse.de +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
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 7/7] nvme: display correct subsystem NQN
2021-09-22 6:35 [PATCHv3 0/7] nvme: support unique discovery controller NQN Hannes Reinecke
` (5 preceding siblings ...)
2021-09-22 6:35 ` [PATCH 6/7] nvme: Add connect option 'discovery' Hannes Reinecke
@ 2021-09-22 6:35 ` Hannes Reinecke
2021-10-12 13:10 ` [PATCHv3 0/7] nvme: support unique discovery controller NQN Christoph Hellwig
7 siblings, 0 replies; 21+ messages in thread
From: Hannes Reinecke @ 2021-09-22 6:35 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Sagi Grimberg, Keith Busch, Chaitanya Kulkarni, linux-nvme,
Hannes Reinecke, Chaitanya Kulkarni
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.
Signed-off-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
---
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(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index ad01e2778cb6..084a2df2a58e 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -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);
diff --git a/drivers/nvme/host/fabrics.h b/drivers/nvme/host/fabrics.h
index b61b666e10ec..56253a060258 100644
--- a/drivers/nvme/host/fabrics.h
+++ b/drivers/nvme/host/fabrics.h
@@ -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);
diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c
index aa14ad963d91..fa8bd6c21073 100644
--- a/drivers/nvme/host/fc.c
+++ b/drivers/nvme/host/fc.c
@@ -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;
diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c
index 042c594bc57e..d795a9868674 100644
--- a/drivers/nvme/host/rdma.c
+++ b/drivers/nvme/host/rdma.c
@@ -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);
diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
index 3c1c29dd3020..78966b8ddb1e 100644
--- a/drivers/nvme/host/tcp.c
+++ b/drivers/nvme/host/tcp.c
@@ -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);
--
2.29.2
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCHv3 0/7] nvme: support unique discovery controller NQN
2021-09-22 6:35 [PATCHv3 0/7] nvme: support unique discovery controller NQN Hannes Reinecke
` (6 preceding siblings ...)
2021-09-22 6:35 ` [PATCH 7/7] nvme: display correct subsystem NQN Hannes Reinecke
@ 2021-10-12 13:10 ` Christoph Hellwig
7 siblings, 0 replies; 21+ messages in thread
From: Christoph Hellwig @ 2021-10-12 13:10 UTC (permalink / raw)
To: Hannes Reinecke
Cc: Christoph Hellwig, Sagi Grimberg, Keith Busch,
Chaitanya Kulkarni, linux-nvme
Thanks,
applied to nvme-5.15.
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply [flat|nested] 21+ messages in thread