/* * We have defined a host as how it is perceived by the target. * Therefore, we don't allow different Host NQNs with the same Host ID. * Similarly, we do not allow the usage of the same Host NQN with * different Host IDs. This'll maintain unambiguous host identification.
*/
list_for_each_entry(host, &nvmf_hosts, list) { bool same_hostnqn = !strcmp(host->nqn, hostnqn); bool same_hostid = uuid_equal(&host->id, id);
if (same_hostnqn && same_hostid) {
kref_get(&host->ref); goto out_unlock;
} if (same_hostnqn) {
pr_err("found same hostnqn %s but different hostid %pUb\n",
hostnqn, id);
host = ERR_PTR(-EINVAL); goto out_unlock;
} if (same_hostid) {
pr_err("found same hostid %pUb but different hostnqn %s\n",
id, hostnqn);
host = ERR_PTR(-EINVAL); goto out_unlock;
}
}
staticvoid nvmf_host_put(struct nvmf_host *host)
{ if (host)
kref_put(&host->ref, nvmf_host_destroy);
}
/** * nvmf_get_address() - Get address/port * @ctrl: Host NVMe controller instance which we got the address * @buf: OUTPUT parameter that will contain the address/port * @size: buffer size
*/ int nvmf_get_address(struct nvme_ctrl *ctrl, char *buf, int size)
{ int len = 0;
if (ctrl->opts->mask & NVMF_OPT_TRADDR)
len += scnprintf(buf, size, "traddr=%s", ctrl->opts->traddr); if (ctrl->opts->mask & NVMF_OPT_TRSVCID)
len += scnprintf(buf + len, size - len, "%strsvcid=%s",
(len) ? "," : "", ctrl->opts->trsvcid); if (ctrl->opts->mask & NVMF_OPT_HOST_TRADDR)
len += scnprintf(buf + len, size - len, "%shost_traddr=%s",
(len) ? "," : "", ctrl->opts->host_traddr); if (ctrl->opts->mask & NVMF_OPT_HOST_IFACE)
len += scnprintf(buf + len, size - len, "%shost_iface=%s",
(len) ? "," : "", ctrl->opts->host_iface);
len += scnprintf(buf + len, size - len, "\n");
/** * nvmf_reg_read32() - NVMe Fabrics "Property Get" API function. * @ctrl: Host NVMe controller instance maintaining the admin * queue used to submit the property read command to * the allocated NVMe controller resource on the target system. * @off: Starting offset value of the targeted property * register (see the fabrics section of the NVMe standard). * @val: OUTPUT parameter that will contain the value of * the property after a successful read. * * Used by the host system to retrieve a 32-bit capsule property value * from an NVMe controller on the target system. * * ("Capsule property" is an "PCIe register concept" applied to the * NVMe fabrics space.) * * Return: * 0: successful read * > 0: NVMe error status code * < 0: Linux errno error code
*/ int nvmf_reg_read32(struct nvme_ctrl *ctrl, u32 off, u32 *val)
{ struct nvme_command cmd = { }; union nvme_result res; int ret;
ret = __nvme_submit_sync_cmd(ctrl->fabrics_q, &cmd, &res, NULL, 0,
NVME_QID_ANY, NVME_SUBMIT_RESERVED);
if (ret >= 0)
*val = le64_to_cpu(res.u64); if (unlikely(ret != 0))
dev_err(ctrl->device, "Property Get error: %d, offset %#x\n",
ret > 0 ? ret & ~NVME_STATUS_DNR : ret, off);
return ret;
}
EXPORT_SYMBOL_GPL(nvmf_reg_read32);
/** * nvmf_reg_read64() - NVMe Fabrics "Property Get" API function. * @ctrl: Host NVMe controller instance maintaining the admin * queue used to submit the property read command to * the allocated controller resource on the target system. * @off: Starting offset value of the targeted property * register (see the fabrics section of the NVMe standard). * @val: OUTPUT parameter that will contain the value of * the property after a successful read. * * Used by the host system to retrieve a 64-bit capsule property value * from an NVMe controller on the target system. * * ("Capsule property" is an "PCIe register concept" applied to the * NVMe fabrics space.) * * Return: * 0: successful read * > 0: NVMe error status code * < 0: Linux errno error code
*/ int nvmf_reg_read64(struct nvme_ctrl *ctrl, u32 off, u64 *val)
{ struct nvme_command cmd = { }; union nvme_result res; int ret;
ret = __nvme_submit_sync_cmd(ctrl->fabrics_q, &cmd, &res, NULL, 0,
NVME_QID_ANY, NVME_SUBMIT_RESERVED);
if (ret >= 0)
*val = le64_to_cpu(res.u64); if (unlikely(ret != 0))
dev_err(ctrl->device, "Property Get error: %d, offset %#x\n",
ret > 0 ? ret & ~NVME_STATUS_DNR : ret, off); return ret;
}
EXPORT_SYMBOL_GPL(nvmf_reg_read64);
/** * nvmf_reg_write32() - NVMe Fabrics "Property Write" API function. * @ctrl: Host NVMe controller instance maintaining the admin * queue used to submit the property read command to * the allocated NVMe controller resource on the target system. * @off: Starting offset value of the targeted property * register (see the fabrics section of the NVMe standard). * @val: Input parameter that contains the value to be * written to the property. * * Used by the NVMe host system to write a 32-bit capsule property value * to an NVMe controller on the target system. * * ("Capsule property" is an "PCIe register concept" applied to the * NVMe fabrics space.) * * Return: * 0: successful write * > 0: NVMe error status code * < 0: Linux errno error code
*/ int nvmf_reg_write32(struct nvme_ctrl *ctrl, u32 off, u32 val)
{ struct nvme_command cmd = { }; int ret;
/** * nvmf_log_connect_error() - Error-parsing-diagnostic print out function for * connect() errors. * @ctrl: The specific /dev/nvmeX device that had the error. * @errval: Error code to be decoded in a more human-friendly * printout. * @offset: For use with the NVMe error code * NVME_SC_CONNECT_INVALID_PARAM. * @cmd: This is the SQE portion of a submission capsule. * @data: This is the "Data" portion of a submission capsule.
*/ staticvoid nvmf_log_connect_error(struct nvme_ctrl *ctrl, int errval, int offset, struct nvme_command *cmd, struct nvmf_connect_data *data)
{ int err_sctype = errval & ~NVME_STATUS_DNR;
/* * set keep-alive timeout in seconds granularity (ms * 1000)
*/
cmd->connect.kato = cpu_to_le32(ctrl->kato * 1000);
}
if (ctrl->opts->disable_sqflow)
cmd->connect.cattr |= NVME_CONNECT_DISABLE_SQFLOW;
}
/** * nvmf_connect_admin_queue() - NVMe Fabrics Admin Queue "Connect" * API function. * @ctrl: Host nvme controller instance used to request * a new NVMe controller allocation on the target * system and establish an NVMe Admin connection to * that controller. * * This function enables an NVMe host device to request a new allocation of * an NVMe controller resource on a target system as well establish a * fabrics-protocol connection of the NVMe Admin queue between the * host system device and the allocated NVMe controller on the * target system via a NVMe Fabrics "Connect" command.
*/ int nvmf_connect_admin_queue(struct nvme_ctrl *ctrl)
{ struct nvme_command cmd = { }; union nvme_result res; struct nvmf_connect_data *data; int ret;
u32 result;
nvmf_connect_cmd_prep(ctrl, 0, &cmd);
data = nvmf_connect_data_prep(ctrl, 0xffff); if (!data) return -ENOMEM;
result = le32_to_cpu(res.u32);
ctrl->cntlid = result & 0xFFFF; if (result & (NVME_CONNECT_AUTHREQ_ATR | NVME_CONNECT_AUTHREQ_ASCR)) { /* Check for secure concatenation */ if ((result & NVME_CONNECT_AUTHREQ_ASCR) &&
!ctrl->opts->concat) {
dev_warn(ctrl->device, "qid 0: secure concatenation is not supported\n");
ret = -EOPNOTSUPP; goto out_free_data;
} /* Authentication required */
ret = nvme_auth_negotiate(ctrl, 0); if (ret) {
dev_warn(ctrl->device, "qid 0: authentication setup failed\n"); goto out_free_data;
}
ret = nvme_auth_wait(ctrl, 0); if (ret) {
dev_warn(ctrl->device, "qid 0: authentication failed, error %d\n",
ret);
} else
dev_info(ctrl->device, "qid 0: authenticated\n");
}
out_free_data:
kfree(data); return ret;
}
EXPORT_SYMBOL_GPL(nvmf_connect_admin_queue);
/** * nvmf_connect_io_queue() - NVMe Fabrics I/O Queue "Connect" * API function. * @ctrl: Host nvme controller instance used to establish an * NVMe I/O queue connection to the already allocated NVMe * controller on the target system. * @qid: NVMe I/O queue number for the new I/O connection between * host and target (note qid == 0 is illegal as this is * the Admin queue, per NVMe standard). * * This function issues a fabrics-protocol connection * of a NVMe I/O queue (via NVMe Fabrics "Connect" command) * between the host system device and the allocated NVMe controller * on the target system. * * Return: * 0: success * > 0: NVMe error status code * < 0: Linux errno error code
*/ int nvmf_connect_io_queue(struct nvme_ctrl *ctrl, u16 qid)
{ struct nvme_command cmd = { }; struct nvmf_connect_data *data; union nvme_result res; int ret;
u32 result;
nvmf_connect_cmd_prep(ctrl, qid, &cmd);
data = nvmf_connect_data_prep(ctrl, ctrl->cntlid); if (!data) return -ENOMEM;
ret = __nvme_submit_sync_cmd(ctrl->connect_q, &cmd, &res,
data, sizeof(*data), qid,
NVME_SUBMIT_AT_HEAD |
NVME_SUBMIT_RESERVED |
NVME_SUBMIT_NOWAIT); if (ret) {
nvmf_log_connect_error(ctrl, ret, le32_to_cpu(res.u32),
&cmd, data); goto out_free_data;
}
result = le32_to_cpu(res.u32); if (result & (NVME_CONNECT_AUTHREQ_ATR | NVME_CONNECT_AUTHREQ_ASCR)) { /* Secure concatenation is not implemented */ if (result & NVME_CONNECT_AUTHREQ_ASCR) {
dev_warn(ctrl->device, "qid %d: secure concatenation is not supported\n", qid);
ret = -EOPNOTSUPP; goto out_free_data;
} /* Authentication required */
ret = nvme_auth_negotiate(ctrl, qid); if (ret) {
dev_warn(ctrl->device, "qid %d: authentication setup failed\n", qid); goto out_free_data;
}
ret = nvme_auth_wait(ctrl, qid); if (ret) {
dev_warn(ctrl->device, "qid %u: authentication failed, error %d\n",
qid, ret);
}
}
out_free_data:
kfree(data); return ret;
}
EXPORT_SYMBOL_GPL(nvmf_connect_io_queue);
/* * Evaluate the status information returned by the transport in order to decided * if a reconnect attempt should be scheduled. * * Do not retry when: * * - the DNR bit is set and the specification states no further connect * attempts with the same set of parameters should be attempted. * * - when the authentication attempt fails, because the key was invalid. * This error code is set on the host side.
*/ bool nvmf_should_reconnect(struct nvme_ctrl *ctrl, int status)
{ if (status > 0 && (status & NVME_STATUS_DNR)) returnfalse;
if (status == -EKEYREJECTED) returnfalse;
if (ctrl->opts->max_reconnects == -1 ||
ctrl->nr_reconnects < ctrl->opts->max_reconnects) returntrue;
/** * nvmf_register_transport() - NVMe Fabrics Library registration function. * @ops: Transport ops instance to be registered to the * common fabrics library. * * API function that registers the type of specific transport fabric * being implemented to the common NVMe fabrics library. Part of * the overall init sequence of starting up a fabrics driver.
*/ int nvmf_register_transport(struct nvmf_transport_ops *ops)
{ if (!ops->create_ctrl) return -EINVAL;
/** * nvmf_unregister_transport() - NVMe Fabrics Library unregistration function. * @ops: Transport ops instance to be unregistered from the * common fabrics library. * * Fabrics API function that unregisters the type of specific transport * fabric being implemented from the common NVMe fabrics library. * Part of the overall exit sequence of unloading the implemented driver.
*/ void nvmf_unregister_transport(struct nvmf_transport_ops *ops)
{
down_write(&nvmf_transports_rwsem);
list_del(&ops->entry);
up_write(&nvmf_transports_rwsem);
}
EXPORT_SYMBOL_GPL(nvmf_unregister_transport);
if (!IS_ENABLED(CONFIG_NVME_TCP_TLS)) {
pr_err("TLS is not supported\n"); return ERR_PTR(-EINVAL);
}
key = nvme_tls_key_lookup(key_id); if (IS_ERR(key))
pr_err("key id %08x not found\n", key_id); else
pr_debug("Using key id %08x\n", key_id); return key;
}
options = o = kstrdup(buf, GFP_KERNEL); if (!options) return -ENOMEM;
/* use default host if not given by user space */
uuid_copy(&hostid, &nvmf_default_host->id);
strscpy(hostnqn, nvmf_default_host->nqn, NVMF_NQN_SIZE);
while ((p = strsep(&o, ",\n")) != NULL) { if (!*p) continue;
token = match_token(p, opt_tokens, args);
opts->mask |= token; switch (token) { case NVMF_OPT_TRANSPORT:
p = match_strdup(args); if (!p) {
ret = -ENOMEM; goto out;
}
kfree(opts->transport);
opts->transport = p; break; case NVMF_OPT_NQN:
p = match_strdup(args); if (!p) {
ret = -ENOMEM; goto out;
}
kfree(opts->subsysnqn);
opts->subsysnqn = p;
nqnlen = strlen(opts->subsysnqn); if (nqnlen >= NVMF_NQN_SIZE) {
pr_err("%s needs to be < %d bytes\n",
opts->subsysnqn, NVMF_NQN_SIZE);
ret = -EINVAL; goto out;
}
opts->discovery_nqn =
!(strcmp(opts->subsysnqn,
NVME_DISC_SUBSYS_NAME)); break; case NVMF_OPT_TRADDR:
p = match_strdup(args); if (!p) {
ret = -ENOMEM; goto out;
}
kfree(opts->traddr);
opts->traddr = p; break; case NVMF_OPT_TRSVCID:
p = match_strdup(args); if (!p) {
ret = -ENOMEM; goto out;
}
kfree(opts->trsvcid);
opts->trsvcid = p; break; case NVMF_OPT_QUEUE_SIZE: if (match_int(args, &token)) {
ret = -EINVAL; goto out;
} if (token < NVMF_MIN_QUEUE_SIZE ||
token > NVMF_MAX_QUEUE_SIZE) {
pr_err("Invalid queue_size %d\n", token);
ret = -EINVAL; goto out;
}
opts->queue_size = token; break; case NVMF_OPT_NR_IO_QUEUES: if (match_int(args, &token)) {
ret = -EINVAL; goto out;
} if (token <= 0) {
pr_err("Invalid number of IOQs %d\n", token);
ret = -EINVAL; goto out;
} if (opts->discovery_nqn) {
pr_debug("Ignoring nr_io_queues value for discovery controller\n"); break;
}
opts->nr_io_queues = min_t(unsignedint,
num_online_cpus(), token); break; case NVMF_OPT_KATO: if (match_int(args, &token)) {
ret = -EINVAL; goto out;
}
if (token < 0) {
pr_err("Invalid keep_alive_tmo %d\n", token);
ret = -EINVAL; goto out;
} elseif (token == 0 && !opts->discovery_nqn) { /* Allowed for debug */
pr_warn("keep_alive_tmo 0 won't execute keep alives!!!\n");
}
opts->kato = token; break; case NVMF_OPT_CTRL_LOSS_TMO: if (match_int(args, &token)) {
ret = -EINVAL; goto out;
}
if (token < 0)
pr_warn("ctrl_loss_tmo < 0 will reconnect forever\n");
ctrl_loss_tmo = token; break; case NVMF_OPT_FAIL_FAST_TMO: if (match_int(args, &token)) {
ret = -EINVAL; goto out;
}
if (token >= 0)
pr_warn("I/O fail on reconnect controller after %d sec\n",
token); else
token = -1;
opts->fast_io_fail_tmo = token; break; case NVMF_OPT_HOSTNQN: if (opts->host) {
pr_err("hostnqn already user-assigned: %s\n",
opts->host->nqn);
ret = -EADDRINUSE; goto out;
}
p = match_strdup(args); if (!p) {
ret = -ENOMEM; goto out;
}
nqnlen = strlen(p); if (nqnlen >= NVMF_NQN_SIZE) {
pr_err("%s needs to be < %d bytes\n",
p, NVMF_NQN_SIZE);
kfree(p);
ret = -EINVAL; goto out;
}
strscpy(hostnqn, p, NVMF_NQN_SIZE);
kfree(p); break; case NVMF_OPT_RECONNECT_DELAY: if (match_int(args, &token)) {
ret = -EINVAL; goto out;
} if (token <= 0) {
pr_err("Invalid reconnect_delay %d\n", token);
ret = -EINVAL; goto out;
}
opts->reconnect_delay = token; break; case NVMF_OPT_HOST_TRADDR:
p = match_strdup(args); if (!p) {
ret = -ENOMEM; goto out;
}
kfree(opts->host_traddr);
opts->host_traddr = p; break; case NVMF_OPT_HOST_IFACE:
p = match_strdup(args); if (!p) {
ret = -ENOMEM; goto out;
}
kfree(opts->host_iface);
opts->host_iface = p; break; case NVMF_OPT_HOST_ID:
p = match_strdup(args); if (!p) {
ret = -ENOMEM; goto out;
}
ret = uuid_parse(p, &hostid); if (ret) {
pr_err("Invalid hostid %s\n", p);
ret = -EINVAL;
kfree(p); goto out;
}
kfree(p); break; case NVMF_OPT_DUP_CONNECT:
opts->duplicate_connect = true; break; case NVMF_OPT_DISABLE_SQFLOW:
opts->disable_sqflow = true; break; case NVMF_OPT_HDR_DIGEST:
opts->hdr_digest = true; break; case NVMF_OPT_DATA_DIGEST:
opts->data_digest = true; break; case NVMF_OPT_NR_WRITE_QUEUES: if (match_int(args, &token)) {
ret = -EINVAL; goto out;
} if (token <= 0) {
pr_err("Invalid nr_write_queues %d\n", token);
ret = -EINVAL; goto out;
}
opts->nr_write_queues = token; break; case NVMF_OPT_NR_POLL_QUEUES: if (match_int(args, &token)) {
ret = -EINVAL; goto out;
} if (token <= 0) {
pr_err("Invalid nr_poll_queues %d\n", token);
ret = -EINVAL; goto out;
}
opts->nr_poll_queues = token; break; case NVMF_OPT_TOS: if (match_int(args, &token)) {
ret = -EINVAL; goto out;
} if (token < 0) {
pr_err("Invalid type of service %d\n", token);
ret = -EINVAL; goto out;
} if (token > 255) {
pr_warn("Clamping type of service to 255\n");
token = 255;
}
opts->tos = token; break; case NVMF_OPT_KEYRING: if (match_int(args, &key_id) || key_id <= 0) {
ret = -EINVAL; goto out;
}
key = nvmf_parse_key(key_id); if (IS_ERR(key)) {
ret = PTR_ERR(key); goto out;
}
key_put(opts->keyring);
opts->keyring = key; break; case NVMF_OPT_TLS_KEY: if (match_int(args, &key_id) || key_id <= 0) {
ret = -EINVAL; goto out;
}
key = nvmf_parse_key(key_id); if (IS_ERR(key)) {
ret = PTR_ERR(key); goto out;
}
key_put(opts->tls_key);
opts->tls_key = key; break; case NVMF_OPT_DISCOVERY:
opts->discovery_nqn = true; break; case NVMF_OPT_DHCHAP_SECRET:
p = match_strdup(args); if (!p) {
ret = -ENOMEM; goto out;
} if (strlen(p) < 11 || strncmp(p, "DHHC-1:", 7)) {
pr_err("Invalid DH-CHAP secret %s\n", p);
ret = -EINVAL; goto out;
}
kfree(opts->dhchap_secret);
opts->dhchap_secret = p; break; case NVMF_OPT_DHCHAP_CTRL_SECRET:
p = match_strdup(args); if (!p) {
ret = -ENOMEM; goto out;
} if (strlen(p) < 11 || strncmp(p, "DHHC-1:", 7)) {
pr_err("Invalid DH-CHAP secret %s\n", p);
ret = -EINVAL; goto out;
}
kfree(opts->dhchap_ctrl_secret);
opts->dhchap_ctrl_secret = p; break; case NVMF_OPT_TLS: if (!IS_ENABLED(CONFIG_NVME_TCP_TLS)) {
pr_err("TLS is not supported\n");
ret = -EINVAL; goto out;
}
opts->tls = true; break; case NVMF_OPT_CONCAT: if (!IS_ENABLED(CONFIG_NVME_TCP_TLS)) {
pr_err("TLS is not supported\n");
ret = -EINVAL; goto out;
}
opts->concat = true; break; default:
pr_warn("unknown parameter or missing value '%s' in ctrl creation request\n",
p);
ret = -EINVAL; goto out;
}
}
if (opts->discovery_nqn) {
opts->nr_io_queues = 0;
opts->nr_write_queues = 0;
opts->nr_poll_queues = 0;
opts->duplicate_connect = true;
} else { if (!opts->kato)
opts->kato = NVME_DEFAULT_KATO;
} if (ctrl_loss_tmo < 0) {
opts->max_reconnects = -1;
} else {
opts->max_reconnects = DIV_ROUND_UP(ctrl_loss_tmo,
opts->reconnect_delay); if (ctrl_loss_tmo < opts->fast_io_fail_tmo)
pr_warn("failfast tmo (%d) larger than controller loss tmo (%d)\n",
opts->fast_io_fail_tmo, ctrl_loss_tmo);
} if (opts->concat) { if (opts->tls) {
pr_err("Secure concatenation over TLS is not supported\n");
ret = -EINVAL; goto out;
} if (opts->tls_key) {
pr_err("Cannot specify a TLS key for secure concatenation\n");
ret = -EINVAL; goto out;
} if (!opts->dhchap_secret) {
pr_err("Need to enable DH-CHAP for secure concatenation\n");
ret = -EINVAL; goto out;
}
}
opts->host = nvmf_host_add(hostnqn, &hostid); if (IS_ERR(opts->host)) {
ret = PTR_ERR(opts->host);
opts->host = NULL; goto out;
}
out:
kfree(options); return ret;
}
void nvmf_set_io_queues(struct nvmf_ctrl_options *opts, u32 nr_io_queues,
u32 io_queues[HCTX_MAX_TYPES])
{ if (opts->nr_write_queues && opts->nr_io_queues < nr_io_queues) { /* * separate read/write queues * hand out dedicated default queues only after we have * sufficient read queues.
*/
io_queues[HCTX_TYPE_READ] = opts->nr_io_queues;
nr_io_queues -= io_queues[HCTX_TYPE_READ];
io_queues[HCTX_TYPE_DEFAULT] =
min(opts->nr_write_queues, nr_io_queues);
nr_io_queues -= io_queues[HCTX_TYPE_DEFAULT];
} else { /* * shared read/write queues * either no write queues were requested, or we don't have * sufficient queue count to have dedicated default queues.
*/
io_queues[HCTX_TYPE_DEFAULT] =
min(opts->nr_io_queues, nr_io_queues);
nr_io_queues -= io_queues[HCTX_TYPE_DEFAULT];
}
if (opts->nr_poll_queues && nr_io_queues) { /* map dedicated poll queues only if we have queues left */
io_queues[HCTX_TYPE_POLL] =
min(opts->nr_poll_queues, nr_io_queues);
}
}
EXPORT_SYMBOL_GPL(nvmf_set_io_queues);
blk_mq_map_queues(&set->map[HCTX_TYPE_DEFAULT]);
blk_mq_map_queues(&set->map[HCTX_TYPE_READ]); if (opts->nr_poll_queues && io_queues[HCTX_TYPE_POLL]) { /* map dedicated poll queues only if we have queues left */
set->map[HCTX_TYPE_POLL].nr_queues = io_queues[HCTX_TYPE_POLL];
set->map[HCTX_TYPE_POLL].queue_offset =
io_queues[HCTX_TYPE_DEFAULT] +
io_queues[HCTX_TYPE_READ];
blk_mq_map_queues(&set->map[HCTX_TYPE_POLL]);
}
/* * Checking the local address or host interfaces is rough. * * In most cases, none is specified and the host port or * host interface is selected by the stack. * * Assume no match if: * - local address or host interface is specified and address * or host interface is not the same * - local address or host interface is not specified but * remote is, or vice versa (admin using specific * host_traddr/host_iface 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)) returnfalse;
} elseif ((opts->mask & NVMF_OPT_HOST_TRADDR) ||
(ctrl->opts->mask & NVMF_OPT_HOST_TRADDR)) { returnfalse;
}
opts = kzalloc(sizeof(*opts), GFP_KERNEL); if (!opts) return ERR_PTR(-ENOMEM);
ret = nvmf_parse_options(opts, buf); if (ret) goto out_free_opts;
request_module("nvme-%s", opts->transport);
/* * Check the generic options first as we need a valid transport for * the lookup below. Then clear the generic flags so that transport * drivers don't have to care about them.
*/
ret = nvmf_check_required_opts(opts, NVMF_REQUIRED_OPTS); if (ret) goto out_free_opts;
opts->mask &= ~NVMF_REQUIRED_OPTS;
down_read(&nvmf_transports_rwsem);
ops = nvmf_lookup_transport(opts); if (!ops) {
pr_info("no handler found for transport %s.\n",
opts->transport);
ret = -EINVAL; goto out_unlock;
}
if (!try_module_get(ops->module)) {
ret = -EBUSY; goto out_unlock;
}
up_read(&nvmf_transports_rwsem);
ret = nvmf_check_required_opts(opts, ops->required_opts); if (ret) goto out_module_put;
ret = nvmf_check_allowed_opts(opts, NVMF_ALLOWED_OPTS |
ops->allowed_opts | ops->required_opts); if (ret) goto out_module_put;
ctrl = ops->create_ctrl(dev, opts); if (IS_ERR(ctrl)) {
ret = PTR_ERR(ctrl); goto out_module_put;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.