nvme: add hostid token to fabric options
Currently we have no way to define a stable host-id but always use the one which is randomly generated when we add the host or use the default host. Provide a "hostid=%s" for user-space to pass in a persistent host-id which overrides the randomly generated one. Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Sagi Grimberg <sagi@grimberg.me> Signed-off-by: Keith Busch <keith.busch@intel.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
3f7f25a910
commit
6bfe04255d
|
@ -58,7 +58,6 @@ static struct nvmf_host *nvmf_host_add(const char *hostnqn)
|
||||||
|
|
||||||
kref_init(&host->ref);
|
kref_init(&host->ref);
|
||||||
memcpy(host->nqn, hostnqn, NVMF_NQN_SIZE);
|
memcpy(host->nqn, hostnqn, NVMF_NQN_SIZE);
|
||||||
uuid_gen(&host->id);
|
|
||||||
|
|
||||||
list_add_tail(&host->list, &nvmf_hosts);
|
list_add_tail(&host->list, &nvmf_hosts);
|
||||||
out_unlock:
|
out_unlock:
|
||||||
|
@ -75,7 +74,6 @@ static struct nvmf_host *nvmf_host_default(void)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
kref_init(&host->ref);
|
kref_init(&host->ref);
|
||||||
uuid_gen(&host->id);
|
|
||||||
snprintf(host->nqn, NVMF_NQN_SIZE,
|
snprintf(host->nqn, NVMF_NQN_SIZE,
|
||||||
"nqn.2014-08.org.nvmexpress:NVMf:uuid:%pUb", &host->id);
|
"nqn.2014-08.org.nvmexpress:NVMf:uuid:%pUb", &host->id);
|
||||||
|
|
||||||
|
@ -565,6 +563,7 @@ static const match_table_t opt_tokens = {
|
||||||
{ NVMF_OPT_KATO, "keep_alive_tmo=%d" },
|
{ NVMF_OPT_KATO, "keep_alive_tmo=%d" },
|
||||||
{ NVMF_OPT_HOSTNQN, "hostnqn=%s" },
|
{ NVMF_OPT_HOSTNQN, "hostnqn=%s" },
|
||||||
{ NVMF_OPT_HOST_TRADDR, "host_traddr=%s" },
|
{ NVMF_OPT_HOST_TRADDR, "host_traddr=%s" },
|
||||||
|
{ NVMF_OPT_HOST_ID, "hostid=%s" },
|
||||||
{ NVMF_OPT_ERR, NULL }
|
{ NVMF_OPT_ERR, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -576,6 +575,7 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts,
|
||||||
int token, ret = 0;
|
int token, ret = 0;
|
||||||
size_t nqnlen = 0;
|
size_t nqnlen = 0;
|
||||||
int ctrl_loss_tmo = NVMF_DEF_CTRL_LOSS_TMO;
|
int ctrl_loss_tmo = NVMF_DEF_CTRL_LOSS_TMO;
|
||||||
|
uuid_t hostid;
|
||||||
|
|
||||||
/* Set defaults */
|
/* Set defaults */
|
||||||
opts->queue_size = NVMF_DEF_QUEUE_SIZE;
|
opts->queue_size = NVMF_DEF_QUEUE_SIZE;
|
||||||
|
@ -586,6 +586,8 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts,
|
||||||
if (!options)
|
if (!options)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
uuid_gen(&hostid);
|
||||||
|
|
||||||
while ((p = strsep(&o, ",\n")) != NULL) {
|
while ((p = strsep(&o, ",\n")) != NULL) {
|
||||||
if (!*p)
|
if (!*p)
|
||||||
continue;
|
continue;
|
||||||
|
@ -742,6 +744,17 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts,
|
||||||
}
|
}
|
||||||
opts->host_traddr = p;
|
opts->host_traddr = p;
|
||||||
break;
|
break;
|
||||||
|
case NVMF_OPT_HOST_ID:
|
||||||
|
p = match_strdup(args);
|
||||||
|
if (!p) {
|
||||||
|
ret = -ENOMEM;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
if (uuid_parse(p, &hostid)) {
|
||||||
|
ret = -EINVAL;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
pr_warn("unknown parameter or missing value '%s' in ctrl creation request\n",
|
pr_warn("unknown parameter or missing value '%s' in ctrl creation request\n",
|
||||||
p);
|
p);
|
||||||
|
@ -761,6 +774,8 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts,
|
||||||
opts->host = nvmf_default_host;
|
opts->host = nvmf_default_host;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uuid_copy(&opts->host->id, &hostid);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if (!opts->discovery_nqn && !opts->kato)
|
if (!opts->discovery_nqn && !opts->kato)
|
||||||
opts->kato = NVME_DEFAULT_KATO;
|
opts->kato = NVME_DEFAULT_KATO;
|
||||||
|
@ -821,7 +836,8 @@ EXPORT_SYMBOL_GPL(nvmf_free_options);
|
||||||
|
|
||||||
#define NVMF_REQUIRED_OPTS (NVMF_OPT_TRANSPORT | NVMF_OPT_NQN)
|
#define NVMF_REQUIRED_OPTS (NVMF_OPT_TRANSPORT | NVMF_OPT_NQN)
|
||||||
#define NVMF_ALLOWED_OPTS (NVMF_OPT_QUEUE_SIZE | NVMF_OPT_NR_IO_QUEUES | \
|
#define NVMF_ALLOWED_OPTS (NVMF_OPT_QUEUE_SIZE | NVMF_OPT_NR_IO_QUEUES | \
|
||||||
NVMF_OPT_KATO | NVMF_OPT_HOSTNQN)
|
NVMF_OPT_KATO | NVMF_OPT_HOSTNQN | \
|
||||||
|
NVMF_OPT_HOST_ID)
|
||||||
|
|
||||||
static struct nvme_ctrl *
|
static struct nvme_ctrl *
|
||||||
nvmf_create_ctrl(struct device *dev, const char *buf, size_t count)
|
nvmf_create_ctrl(struct device *dev, const char *buf, size_t count)
|
||||||
|
|
|
@ -56,6 +56,7 @@ enum {
|
||||||
NVMF_OPT_RECONNECT_DELAY = 1 << 9,
|
NVMF_OPT_RECONNECT_DELAY = 1 << 9,
|
||||||
NVMF_OPT_HOST_TRADDR = 1 << 10,
|
NVMF_OPT_HOST_TRADDR = 1 << 10,
|
||||||
NVMF_OPT_CTRL_LOSS_TMO = 1 << 11,
|
NVMF_OPT_CTRL_LOSS_TMO = 1 << 11,
|
||||||
|
NVMF_OPT_HOST_ID = 1 << 12,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue