mirror of
https://github.com/torvalds/linux
synced 2024-10-10 13:24:04 +00:00
nvme-fabrics: move controller options matching to fabrics
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@grimberg.me> Signed-off-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
parent
bb59b8e574
commit
b7c7be6f6b
|
@ -868,6 +868,36 @@ static int nvmf_check_required_opts(struct nvmf_ctrl_options *opts,
|
||||||
return 0;
|
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, none is 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,
|
static int nvmf_check_allowed_opts(struct nvmf_ctrl_options *opts,
|
||||||
unsigned int allowed_opts)
|
unsigned int allowed_opts)
|
||||||
{
|
{
|
||||||
|
|
|
@ -166,6 +166,8 @@ blk_status_t nvmf_fail_nonready_command(struct nvme_ctrl *ctrl,
|
||||||
struct request *rq);
|
struct request *rq);
|
||||||
bool __nvmf_check_ready(struct nvme_ctrl *ctrl, struct request *rq,
|
bool __nvmf_check_ready(struct nvme_ctrl *ctrl, struct request *rq,
|
||||||
bool queue_live);
|
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,
|
static inline bool nvmf_check_ready(struct nvme_ctrl *ctrl, struct request *rq,
|
||||||
bool queue_live)
|
bool queue_live)
|
||||||
|
|
|
@ -1856,39 +1856,6 @@ static const struct nvme_ctrl_ops nvme_rdma_ctrl_ops = {
|
||||||
.stop_ctrl = nvme_rdma_stop_ctrl,
|
.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
|
* Fails a connection request if it matches an existing controller
|
||||||
* (association) with the same tuple:
|
* (association) with the same tuple:
|
||||||
|
@ -1909,7 +1876,7 @@ nvme_rdma_existing_controller(struct nvmf_ctrl_options *opts)
|
||||||
|
|
||||||
mutex_lock(&nvme_rdma_ctrl_mutex);
|
mutex_lock(&nvme_rdma_ctrl_mutex);
|
||||||
list_for_each_entry(ctrl, &nvme_rdma_ctrl_list, list) {
|
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)
|
if (found)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue