Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 16 additions & 32 deletions fabrics.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,25 +334,23 @@ static int hook_parser_next_line(struct libnvmf_context *fctx, void *user_data)
OPT_FLAG("force", 0, &force, "Force persistent discovery controller creation"));

memcpy(&fa, hfd->fa, sizeof(fa));
next:
if (fgets(line, sizeof(line), hfd->f) == NULL)
return -EOF;
do {
if (fgets(line, sizeof(line), hfd->f) == NULL)
return -EOF;

if (line[0] == '#' || line[0] == '\n')
goto next;
if (line[0] == '#' || line[0] == '\n')
continue;

argc = 1;
p = line;
while ((ptr = strsep(&p, " =\n")) != NULL)
hfd->argv[argc++] = ptr;
hfd->argv[argc] = NULL;
argc = 1;
p = line;
while ((ptr = strsep(&p, " =\n")) != NULL)
hfd->argv[argc++] = ptr;
hfd->argv[argc] = NULL;

fa.subsysnqn = NVME_DISC_SUBSYS_NAME;
ret = argconfig_parse(argc, hfd->argv, "config", opts);
if (ret)
goto next;
if (!fa.transport && !fa.traddr)
goto next;
fa.subsysnqn = NVME_DISC_SUBSYS_NAME;
if (argconfig_parse(argc, hfd->argv, "config", opts))
continue;
} while (!fa.transport && !fa.traddr);

if (!fa.trsvcid)
fa.trsvcid = libnvmf_get_default_trsvcid(fa.transport, true);
Expand All @@ -361,10 +359,6 @@ static int hook_parser_next_line(struct libnvmf_context *fctx, void *user_data)
if (ret)
return ret;

ret = set_fabrics_options(fctx, &fa);
if (ret)
return ret;

libnvmf_context_set_discovery_hooks(fctx, hook_discovery_log,
hook_parser_init, hook_parser_cleanup, hook_parser_next_line);

Expand Down Expand Up @@ -395,7 +389,7 @@ static int setup_common_context(struct libnvmf_context *fctx,
if (err)
return err;

return 0;
return set_fabrics_options(fctx, fa);
}

static int create_common_context(struct libnvme_global_ctx *ctx,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose it would make sense to drop the common in the function names. I introduced it because I thought there will be a need to differentiate between the 'base' info and the rest. But looks like it's not really the case.

Expand All @@ -410,17 +404,7 @@ static int create_common_context(struct libnvme_global_ctx *ctx,
if (err)
return err;

err = libnvmf_context_set_connection(fctx, fa->subsysnqn,
fa->transport, fa->traddr, fa->trsvcid,
fa->host_traddr, fa->host_iface);
if (err)
goto err;

err = libnvmf_context_set_hostnqn(fctx, fa->hostnqn, fa->hostid);
if (err)
goto err;

err = set_fabrics_options(fctx, fa);
err = setup_common_context(fctx, fa);
if (err)
goto err;

Expand Down
Loading