nvmf: add a name entry to the spdk_nvmf_tgt struct
This will provide a unique identifier which can be used to provide get and set methods within the RPCs. Change-Id: Idd144e99e49b8d26530f60530d2e908b18fa251b Signed-off-by: Seth Howell <seth.howell@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/465330 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
7d6d95db3c
commit
8d6d26bd29
@ -50,6 +50,8 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define NVMF_TGT_NAME_MAX_LENGTH 256
|
||||||
|
|
||||||
struct spdk_nvmf_tgt;
|
struct spdk_nvmf_tgt;
|
||||||
struct spdk_nvmf_subsystem;
|
struct spdk_nvmf_subsystem;
|
||||||
struct spdk_nvmf_ctrlr;
|
struct spdk_nvmf_ctrlr;
|
||||||
@ -64,6 +66,7 @@ struct spdk_json_write_ctx;
|
|||||||
struct spdk_nvmf_transport;
|
struct spdk_nvmf_transport;
|
||||||
|
|
||||||
struct spdk_nvmf_target_opts {
|
struct spdk_nvmf_target_opts {
|
||||||
|
char name[NVMF_TGT_NAME_MAX_LENGTH];
|
||||||
uint32_t max_subsystems;
|
uint32_t max_subsystems;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -186,7 +186,10 @@ spdk_nvmf_parse_nvmf_tgt(void)
|
|||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
int using_deprecated_options;
|
int using_deprecated_options;
|
||||||
struct spdk_nvmf_target_opts opts = { 0 };
|
struct spdk_nvmf_target_opts opts = {
|
||||||
|
.name = "nvmf_tgt",
|
||||||
|
.max_subsystems = 0
|
||||||
|
};
|
||||||
|
|
||||||
if (!g_spdk_nvmf_tgt_max_subsystems) {
|
if (!g_spdk_nvmf_tgt_max_subsystems) {
|
||||||
using_deprecated_options = spdk_nvmf_parse_tgt_max_subsystems();
|
using_deprecated_options = spdk_nvmf_parse_tgt_max_subsystems();
|
||||||
|
@ -221,13 +221,27 @@ spdk_nvmf_tgt_destroy_poll_group_qpairs(struct spdk_nvmf_poll_group *group)
|
|||||||
struct spdk_nvmf_tgt *
|
struct spdk_nvmf_tgt *
|
||||||
spdk_nvmf_tgt_create(struct spdk_nvmf_target_opts *opts)
|
spdk_nvmf_tgt_create(struct spdk_nvmf_target_opts *opts)
|
||||||
{
|
{
|
||||||
struct spdk_nvmf_tgt *tgt;
|
struct spdk_nvmf_tgt *tgt, *tmp_tgt;
|
||||||
|
|
||||||
|
if (strnlen(opts->name, NVMF_TGT_NAME_MAX_LENGTH) == NVMF_TGT_NAME_MAX_LENGTH) {
|
||||||
|
SPDK_ERRLOG("Provided target name exceeds the max length of %u.\n", NVMF_TGT_NAME_MAX_LENGTH);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
TAILQ_FOREACH(tmp_tgt, &g_nvmf_tgts, link) {
|
||||||
|
if (!strncmp(opts->name, tmp_tgt->name, strlen(tmp_tgt->name))) {
|
||||||
|
SPDK_ERRLOG("Provided target name must be unique.\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tgt = calloc(1, sizeof(*tgt));
|
tgt = calloc(1, sizeof(*tgt));
|
||||||
if (!tgt) {
|
if (!tgt) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snprintf(tgt->name, NVMF_TGT_NAME_MAX_LENGTH, "%s", opts->name);
|
||||||
|
|
||||||
if (!opts || !opts->max_subsystems) {
|
if (!opts || !opts->max_subsystems) {
|
||||||
tgt->max_subsystems = SPDK_NVMF_DEFAULT_MAX_SUBSYSTEMS;
|
tgt->max_subsystems = SPDK_NVMF_DEFAULT_MAX_SUBSYSTEMS;
|
||||||
} else {
|
} else {
|
||||||
@ -251,7 +265,7 @@ spdk_nvmf_tgt_create(struct spdk_nvmf_target_opts *opts)
|
|||||||
spdk_nvmf_tgt_create_poll_group,
|
spdk_nvmf_tgt_create_poll_group,
|
||||||
spdk_nvmf_tgt_destroy_poll_group,
|
spdk_nvmf_tgt_destroy_poll_group,
|
||||||
sizeof(struct spdk_nvmf_poll_group),
|
sizeof(struct spdk_nvmf_poll_group),
|
||||||
"nvmf_tgt");
|
tgt->name);
|
||||||
|
|
||||||
return tgt;
|
return tgt;
|
||||||
}
|
}
|
||||||
|
@ -74,6 +74,8 @@ enum spdk_nvmf_qpair_state {
|
|||||||
typedef void (*spdk_nvmf_state_change_done)(void *cb_arg, int status);
|
typedef void (*spdk_nvmf_state_change_done)(void *cb_arg, int status);
|
||||||
|
|
||||||
struct spdk_nvmf_tgt {
|
struct spdk_nvmf_tgt {
|
||||||
|
char name[NVMF_TGT_NAME_MAX_LENGTH];
|
||||||
|
|
||||||
uint64_t discovery_genctr;
|
uint64_t discovery_genctr;
|
||||||
|
|
||||||
uint32_t max_subsystems;
|
uint32_t max_subsystems;
|
||||||
|
@ -264,8 +264,11 @@ static void
|
|||||||
create_transport_test(void)
|
create_transport_test(void)
|
||||||
{
|
{
|
||||||
const struct spdk_nvmf_transport_ops *ops = NULL;
|
const struct spdk_nvmf_transport_ops *ops = NULL;
|
||||||
struct spdk_nvmf_target_opts tgt_opts = { 0 };
|
|
||||||
struct spdk_nvmf_transport_opts opts = { 0 };
|
struct spdk_nvmf_transport_opts opts = { 0 };
|
||||||
|
struct spdk_nvmf_target_opts tgt_opts = {
|
||||||
|
.name = "nvmf_test_tgt",
|
||||||
|
.max_subsystems = 0
|
||||||
|
};
|
||||||
|
|
||||||
allocate_threads(8);
|
allocate_threads(8);
|
||||||
set_thread(0);
|
set_thread(0);
|
||||||
|
Loading…
Reference in New Issue
Block a user