Skip to content

Commit

Permalink
Merge pull request #195 from hreinecke/disable-sqflow
Browse files Browse the repository at this point in the history
fabrics: kill 'disable_sqflow' argument to nvmf_add_ctrl()
  • Loading branch information
hreinecke authored Jan 21, 2022
2 parents 63ea220 + 0f31881 commit fcf7edf
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 35 deletions.
2 changes: 1 addition & 1 deletion examples/discover-loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ int main()
fprintf(stderr, "Failed to allocate memory\n");
return ENOMEM;
}
ret = nvmf_add_ctrl(h, c, &cfg, false);
ret = nvmf_add_ctrl(h, c, &cfg);
if (ret < 0) {
fprintf(stderr, "no controller found\n");
return errno;
Expand Down
2 changes: 1 addition & 1 deletion libnvme/nvme.i
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ struct nvme_ns {
connect_err = 1;
return;
}
ret = nvmf_add_ctrl(h, $self, cfg, cfg->disable_sqflow);
ret = nvmf_add_ctrl(h, $self, cfg);
if (ret < 0) {
connect_err = 2;
return;
Expand Down
15 changes: 6 additions & 9 deletions src/nvme/fabrics.c
Original file line number Diff line number Diff line change
Expand Up @@ -587,14 +587,12 @@ int nvmf_add_ctrl_opts(nvme_ctrl_t c, struct nvme_fabrics_config *cfg)
}

int nvmf_add_ctrl(nvme_host_t h, nvme_ctrl_t c,
const struct nvme_fabrics_config *cfg,
bool disable_sqflow)
const struct nvme_fabrics_config *cfg)
{
char *argstr;
int ret;

cfg = merge_config(c, cfg);
nvme_ctrl_disable_sqflow(c, disable_sqflow);
nvme_ctrl_set_discovered(c, true);
if (traddr_is_hostname(c)) {
ret = hostname2traddr(c);
Expand Down Expand Up @@ -627,7 +625,6 @@ nvme_ctrl_t nvmf_connect_disc_entry(nvme_host_t h,
const char *transport;
char *traddr = NULL, *trsvcid = NULL;
nvme_ctrl_t c;
bool disable_sqflow = false;
int ret;

switch (e->trtype) {
Expand Down Expand Up @@ -709,24 +706,24 @@ nvme_ctrl_t nvmf_connect_disc_entry(nvme_host_t h,
}

if (e->treq & NVMF_TREQ_DISABLE_SQFLOW)
disable_sqflow = true;
c->cfg.disable_sqflow = true;

if (e->trtype == NVMF_TRTYPE_TCP &&
(e->treq & NVMF_TREQ_REQUIRED ||
e->treq & NVMF_TREQ_NOT_REQUIRED))
c->cfg.tls = true;

ret = nvmf_add_ctrl(h, c, cfg, disable_sqflow);
ret = nvmf_add_ctrl(h, c, cfg);
if (!ret)
return c;

if (errno == EINVAL && disable_sqflow) {
if (errno == EINVAL && c->cfg.disable_sqflow) {
errno = 0;
/* disable_sqflow is unrecognized option on older kernels */
nvme_msg(LOG_INFO, "failed to connect controller, "
"retry with disabling SQ flow control\n");
disable_sqflow = false;
ret = nvmf_add_ctrl(h, c, cfg, disable_sqflow);
c->cfg.disable_sqflow = false;
ret = nvmf_add_ctrl(h, c, cfg);
if (!ret)
return c;
}
Expand Down
18 changes: 10 additions & 8 deletions src/nvme/fabrics.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,17 +160,19 @@ void nvmf_default_config(struct nvme_fabrics_config *cfg);
int nvmf_add_ctrl_opts(nvme_ctrl_t c, struct nvme_fabrics_config *cfg);

/**
* nvmf_add_ctrl() -
* @h:
* @c:
* @cfg:
* @disable_sqflow:
* nvmf_add_ctrl() - Connect a controller and update topology
* @h: Host to which the controller should be attached
* @c: Controller to be connected
* @cfg: Default configuration for the controller
*
* Return:
* Issues a 'connect' command to the NVMe-oF controller and inserts @c
* into the topology using @h as parent.
* @c must be initialized and not connected to the topology.
*
* Return: 0 on success; on failure errno is set and -1 is returned.
*/
int nvmf_add_ctrl(nvme_host_t h, nvme_ctrl_t c,
const struct nvme_fabrics_config *cfg,
bool disable_sqflow);
const struct nvme_fabrics_config *cfg);

/**
* nvmf_get_discovery_log() -
Expand Down
7 changes: 0 additions & 7 deletions src/nvme/tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -749,13 +749,6 @@ void nvme_ctrl_set_dhchap_key(nvme_ctrl_t c, const char *key)
c->dhchap_key = strdup(key);
}

void nvme_ctrl_disable_sqflow(nvme_ctrl_t c, bool disable_sqflow)
{
c->cfg.disable_sqflow = disable_sqflow;
if (c->s && c->s->h && c->s->h->r)
c->s->h->r->modified = true;
}

void nvme_ctrl_set_discovered(nvme_ctrl_t c, bool discovered)
{
c->discovered = discovered;
Expand Down
9 changes: 0 additions & 9 deletions src/nvme/tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -873,15 +873,6 @@ void nvme_ctrl_set_discovery_ctrl(nvme_ctrl_t c, bool discovery);
*/
bool nvme_ctrl_is_discovery_ctrl(nvme_ctrl_t c);

/**
* nvme_ctrl_disable_sqflow() -
* @c:
* @disable_sqflow:
*
* Return:
*/
void nvme_ctrl_disable_sqflow(nvme_ctrl_t c, bool disable_sqflow);

/**
* nvme_ctrl_identify() -
* @c:
Expand Down

0 comments on commit fcf7edf

Please sign in to comment.