* [PATCH 1/2] nvme-rdma: always have a valid trsvcid
@ 2018-10-04 17:43 Sagi Grimberg
2018-10-04 17:43 ` [PATCH 2/2] nvme-fabrics: move controller options matching to fabrics Sagi Grimberg
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Sagi Grimberg @ 2018-10-04 17:43 UTC (permalink / raw)
If not passed, we set the default trsvcid. We can rely
on having trsvcid and can simplify the controller matching
logic.
Signed-off-by: Sagi Grimberg <sagi at grimberg.me>
---
drivers/nvme/host/rdma.c | 34 ++++++++++------------------------
1 file changed, 10 insertions(+), 24 deletions(-)
diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c
index dc042017c293..cd4269c2fb10 100644
--- a/drivers/nvme/host/rdma.c
+++ b/drivers/nvme/host/rdma.c
@@ -1853,26 +1853,11 @@ static inline bool
__nvme_rdma_options_match(struct nvme_rdma_ctrl *ctrl,
struct nvmf_ctrl_options *opts)
{
- char *stdport = __stringify(NVME_RDMA_IP_PORT);
-
-
if (!nvmf_ctlr_matches_baseopts(&ctrl->ctrl, opts) ||
- strcmp(opts->traddr, ctrl->ctrl.opts->traddr))
+ strcmp(opts->traddr, ctrl->ctrl.opts->traddr) ||
+ strcmp(opts->trsvcid, ctrl->ctrl.opts->trsvcid))
return false;
- if (opts->mask & NVMF_OPT_TRSVCID &&
- ctrl->ctrl.opts->mask & NVMF_OPT_TRSVCID) {
- if (strcmp(opts->trsvcid, ctrl->ctrl.opts->trsvcid))
- return false;
- } else if (opts->mask & NVMF_OPT_TRSVCID) {
- if (strcmp(opts->trsvcid, stdport))
- return false;
- } else if (ctrl->ctrl.opts->mask & NVMF_OPT_TRSVCID) {
- if (strcmp(stdport, ctrl->ctrl.opts->trsvcid))
- return false;
- }
- /* else, it's a match as both have stdport. Fall to next checks */
-
/*
* checking the local address is rough. In most cases, one
* is not specified and the host port is selected by the stack.
@@ -1932,7 +1917,6 @@ static struct nvme_ctrl *nvme_rdma_create_ctrl(struct device *dev,
struct nvme_rdma_ctrl *ctrl;
int ret;
bool changed;
- char *port;
ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL);
if (!ctrl)
@@ -1940,15 +1924,17 @@ static struct nvme_ctrl *nvme_rdma_create_ctrl(struct device *dev,
ctrl->ctrl.opts = opts;
INIT_LIST_HEAD(&ctrl->list);
- if (opts->mask & NVMF_OPT_TRSVCID)
- port = opts->trsvcid;
- else
- port = __stringify(NVME_RDMA_IP_PORT);
+ if (!(opts->mask & NVMF_OPT_TRSVCID)) {
+ opts->trsvcid =
+ kstrdup(__stringify(NVME_RDMA_IP_PORT), GFP_KERNEL);
+ opts->mask |= NVMF_OPT_TRSVCID;
+ }
ret = inet_pton_with_scope(&init_net, AF_UNSPEC,
- opts->traddr, port, &ctrl->addr);
+ opts->traddr, opts->trsvcid, &ctrl->addr);
if (ret) {
- pr_err("malformed address passed: %s:%s\n", opts->traddr, port);
+ pr_err("malformed address passed: %s:%s\n",
+ opts->traddr, opts->trsvcid);
goto out_free_ctrl;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] nvme-fabrics: move controller options matching to fabrics
2018-10-04 17:43 [PATCH 1/2] nvme-rdma: always have a valid trsvcid Sagi Grimberg
@ 2018-10-04 17:43 ` Sagi Grimberg
2018-10-17 7:09 ` Christoph Hellwig
2018-10-16 1:04 ` [PATCH 1/2] nvme-rdma: always have a valid trsvcid Sagi Grimberg
2018-10-17 7:08 ` Christoph Hellwig
2 siblings, 1 reply; 5+ messages in thread
From: Sagi Grimberg @ 2018-10-04 17:43 UTC (permalink / raw)
IP transports will most likely use the same controller options
matching when detecting a duplicate connect. Move it to
fabrics.
Signed-off-by: Sagi Grimberg <sagi at grimberg.me>
---
drivers/nvme/host/fabrics.c | 29 +++++++++++++++++++++++++++++
drivers/nvme/host/fabrics.h | 2 ++
drivers/nvme/host/rdma.c | 35 +----------------------------------
3 files changed, 32 insertions(+), 34 deletions(-)
diff --git a/drivers/nvme/host/fabrics.c b/drivers/nvme/host/fabrics.c
index bcd09d3a44da..a43924e50733 100644
--- a/drivers/nvme/host/fabrics.c
+++ b/drivers/nvme/host/fabrics.c
@@ -868,6 +868,35 @@ static int nvmf_check_required_opts(struct nvmf_ctrl_options *opts,
return 0;
}
+bool nvmf_ip_options_match(struct nvme_ctrl *ctrl,
+ struct nvmf_ctrl_options *opts)
+{
+ if (!nvmf_ctlr_matches_baseopts(ctrl, opts) ||
+ strcmp(opts->traddr, ctrl->opts->traddr) ||
+ strcmp(opts->trsvcid, ctrl->opts->trsvcid))
+ return false;
+
+ /*
+ * checking the local address is rough. In most cases, one
+ * is not specified and the host port is selected by the stack.
+ *
+ * Assume no match if:
+ * local address is specified and address is not the same
+ * local address is not specified but remote is, or vice versa
+ * (admin using specific host_traddr when it matters).
+ */
+ if (opts->mask & NVMF_OPT_HOST_TRADDR &&
+ ctrl->opts->mask & NVMF_OPT_HOST_TRADDR) {
+ if (strcmp(opts->host_traddr, ctrl->opts->host_traddr))
+ return false;
+ } else if (opts->mask & NVMF_OPT_HOST_TRADDR ||
+ ctrl->opts->mask & NVMF_OPT_HOST_TRADDR)
+ return false;
+
+ return true;
+}
+EXPORT_SYMBOL_GPL(nvmf_ip_options_match);
+
static int nvmf_check_allowed_opts(struct nvmf_ctrl_options *opts,
unsigned int allowed_opts)
{
diff --git a/drivers/nvme/host/fabrics.h b/drivers/nvme/host/fabrics.h
index aa2fdb2a2e8f..6ea6275f332a 100644
--- a/drivers/nvme/host/fabrics.h
+++ b/drivers/nvme/host/fabrics.h
@@ -166,6 +166,8 @@ blk_status_t nvmf_fail_nonready_command(struct nvme_ctrl *ctrl,
struct request *rq);
bool __nvmf_check_ready(struct nvme_ctrl *ctrl, struct request *rq,
bool queue_live);
+bool nvmf_ip_options_match(struct nvme_ctrl *ctrl,
+ struct nvmf_ctrl_options *opts);
static inline bool nvmf_check_ready(struct nvme_ctrl *ctrl, struct request *rq,
bool queue_live)
diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c
index cd4269c2fb10..c637c7b38949 100644
--- a/drivers/nvme/host/rdma.c
+++ b/drivers/nvme/host/rdma.c
@@ -1849,39 +1849,6 @@ static const struct nvme_ctrl_ops nvme_rdma_ctrl_ops = {
.stop_ctrl = nvme_rdma_stop_ctrl,
};
-static inline bool
-__nvme_rdma_options_match(struct nvme_rdma_ctrl *ctrl,
- struct nvmf_ctrl_options *opts)
-{
- if (!nvmf_ctlr_matches_baseopts(&ctrl->ctrl, opts) ||
- strcmp(opts->traddr, ctrl->ctrl.opts->traddr) ||
- strcmp(opts->trsvcid, ctrl->ctrl.opts->trsvcid))
- return false;
-
- /*
- * checking the local address is rough. In most cases, one
- * is not specified and the host port is selected by the stack.
- *
- * Assume no match if:
- * local address is specified and address is not the same
- * local address is not specified but remote is, or vice versa
- * (admin using specific host_traddr when it matters).
- */
- if (opts->mask & NVMF_OPT_HOST_TRADDR &&
- ctrl->ctrl.opts->mask & NVMF_OPT_HOST_TRADDR) {
- if (strcmp(opts->host_traddr, ctrl->ctrl.opts->host_traddr))
- return false;
- } else if (opts->mask & NVMF_OPT_HOST_TRADDR ||
- ctrl->ctrl.opts->mask & NVMF_OPT_HOST_TRADDR)
- return false;
- /*
- * if neither controller had an host port specified, assume it's
- * a match as everything else matched.
- */
-
- return true;
-}
-
/*
* Fails a connection request if it matches an existing controller
* (association) with the same tuple:
@@ -1902,7 +1869,7 @@ nvme_rdma_existing_controller(struct nvmf_ctrl_options *opts)
mutex_lock(&nvme_rdma_ctrl_mutex);
list_for_each_entry(ctrl, &nvme_rdma_ctrl_list, list) {
- found = __nvme_rdma_options_match(ctrl, opts);
+ found = nvmf_ip_options_match(&ctrl->ctrl, opts);
if (found)
break;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 1/2] nvme-rdma: always have a valid trsvcid
2018-10-04 17:43 [PATCH 1/2] nvme-rdma: always have a valid trsvcid Sagi Grimberg
2018-10-04 17:43 ` [PATCH 2/2] nvme-fabrics: move controller options matching to fabrics Sagi Grimberg
@ 2018-10-16 1:04 ` Sagi Grimberg
2018-10-17 7:08 ` Christoph Hellwig
2 siblings, 0 replies; 5+ messages in thread
From: Sagi Grimberg @ 2018-10-16 1:04 UTC (permalink / raw)
Ping?
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] nvme-rdma: always have a valid trsvcid
2018-10-04 17:43 [PATCH 1/2] nvme-rdma: always have a valid trsvcid Sagi Grimberg
2018-10-04 17:43 ` [PATCH 2/2] nvme-fabrics: move controller options matching to fabrics Sagi Grimberg
2018-10-16 1:04 ` [PATCH 1/2] nvme-rdma: always have a valid trsvcid Sagi Grimberg
@ 2018-10-17 7:08 ` Christoph Hellwig
2 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2018-10-17 7:08 UTC (permalink / raw)
On Thu, Oct 04, 2018@10:43:57AM -0700, Sagi Grimberg wrote:
> If not passed, we set the default trsvcid. We can rely
> on having trsvcid and can simplify the controller matching
> logic.
Use your 73 lines for the changelog, please.
> + if (!(opts->mask & NVMF_OPT_TRSVCID)) {
> + opts->trsvcid =
> + kstrdup(__stringify(NVME_RDMA_IP_PORT), GFP_KERNEL);
This needs error handling.
Otherwise the patch looks fine to me.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/2] nvme-fabrics: move controller options matching to fabrics
2018-10-04 17:43 ` [PATCH 2/2] nvme-fabrics: move controller options matching to fabrics Sagi Grimberg
@ 2018-10-17 7:09 ` Christoph Hellwig
0 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2018-10-17 7:09 UTC (permalink / raw)
> +bool nvmf_ip_options_match(struct nvme_ctrl *ctrl,
> + struct nvmf_ctrl_options *opts)
This needs a two-tab indent.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-10-17 7:09 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-04 17:43 [PATCH 1/2] nvme-rdma: always have a valid trsvcid Sagi Grimberg
2018-10-04 17:43 ` [PATCH 2/2] nvme-fabrics: move controller options matching to fabrics Sagi Grimberg
2018-10-17 7:09 ` Christoph Hellwig
2018-10-16 1:04 ` [PATCH 1/2] nvme-rdma: always have a valid trsvcid Sagi Grimberg
2018-10-17 7:08 ` Christoph Hellwig
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.