* [PATCH v2 1/2] nvme-rdma: always have a valid trsvcid
@ 2018-10-19 0:40 Sagi Grimberg
2018-10-19 0:40 ` [PATCH v2 2/2] nvme-fabrics: move controller options matching to fabrics Sagi Grimberg
2018-10-19 6:32 ` [PATCH v2 1/2] nvme-rdma: always have a valid trsvcid Christoph Hellwig
0 siblings, 2 replies; 5+ messages in thread
From: Sagi Grimberg @ 2018-10-19 0:40 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>
---
Changes from v1:
- fixed change log
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 e7be903041a8..ca18fe67f856 100644
--- a/drivers/nvme/host/rdma.c
+++ b/drivers/nvme/host/rdma.c
@@ -1860,26 +1860,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.
@@ -1939,7 +1924,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)
@@ -1947,15 +1931,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 v2 2/2] nvme-fabrics: move controller options matching to fabrics
2018-10-19 0:40 [PATCH v2 1/2] nvme-rdma: always have a valid trsvcid Sagi Grimberg
@ 2018-10-19 0:40 ` Sagi Grimberg
2018-10-19 12:22 ` Christoph Hellwig
2018-10-19 6:32 ` [PATCH v2 1/2] nvme-rdma: always have a valid trsvcid Christoph Hellwig
1 sibling, 1 reply; 5+ messages in thread
From: Sagi Grimberg @ 2018-10-19 0:40 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>
---
Changes from v1:
- double tab function signature
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..5b3912f43e5e 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 ca18fe67f856..ab4e2a0cea87 100644
--- a/drivers/nvme/host/rdma.c
+++ b/drivers/nvme/host/rdma.c
@@ -1856,39 +1856,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:
@@ -1909,7 +1876,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 v2 1/2] nvme-rdma: always have a valid trsvcid
2018-10-19 0:40 [PATCH v2 1/2] nvme-rdma: always have a valid trsvcid Sagi Grimberg
2018-10-19 0:40 ` [PATCH v2 2/2] nvme-fabrics: move controller options matching to fabrics Sagi Grimberg
@ 2018-10-19 6:32 ` Christoph Hellwig
2018-10-19 7:50 ` Sagi Grimberg
1 sibling, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2018-10-19 6:32 UTC (permalink / raw)
> + if (!(opts->mask & NVMF_OPT_TRSVCID)) {
> + opts->trsvcid =
> + kstrdup(__stringify(NVME_RDMA_IP_PORT), GFP_KERNEL);
This still locks error handling.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 1/2] nvme-rdma: always have a valid trsvcid
2018-10-19 6:32 ` [PATCH v2 1/2] nvme-rdma: always have a valid trsvcid Christoph Hellwig
@ 2018-10-19 7:50 ` Sagi Grimberg
0 siblings, 0 replies; 5+ messages in thread
From: Sagi Grimberg @ 2018-10-19 7:50 UTC (permalink / raw)
>> + if (!(opts->mask & NVMF_OPT_TRSVCID)) {
>> + opts->trsvcid =
>> + kstrdup(__stringify(NVME_RDMA_IP_PORT), GFP_KERNEL);
>
> This still locks error handling.
Not sure how I managed to miss this comment... Sorry..
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 2/2] nvme-fabrics: move controller options matching to fabrics
2018-10-19 0:40 ` [PATCH v2 2/2] nvme-fabrics: move controller options matching to fabrics Sagi Grimberg
@ 2018-10-19 12:22 ` Christoph Hellwig
0 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2018-10-19 12:22 UTC (permalink / raw)
Thanks,
applied to nvme-4.20.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-10-19 12:22 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-19 0:40 [PATCH v2 1/2] nvme-rdma: always have a valid trsvcid Sagi Grimberg
2018-10-19 0:40 ` [PATCH v2 2/2] nvme-fabrics: move controller options matching to fabrics Sagi Grimberg
2018-10-19 12:22 ` Christoph Hellwig
2018-10-19 6:32 ` [PATCH v2 1/2] nvme-rdma: always have a valid trsvcid Christoph Hellwig
2018-10-19 7:50 ` Sagi Grimberg
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.