diff options
Diffstat (limited to '')
-rw-r--r-- | fabrics.c | 32 |
1 files changed, 18 insertions, 14 deletions
@@ -69,7 +69,7 @@ const char *conarg_host_traddr = "host_traddr"; const char *conarg_host_iface = "host_iface"; struct fabrics_config fabrics_cfg = { - .ctrl_loss_tmo = -1, + .ctrl_loss_tmo = NVMF_DEF_CTRL_LOSS_TMO, .fast_io_fail_tmo = -1, .output_format = "normal", }; @@ -293,13 +293,14 @@ static bool ctrl_matches_connectargs(const char *name, struct connect_args *args return found; addr = nvme_get_ctrl_attr(path, "address"); - if (!addr) { + cargs.subsysnqn = nvme_get_ctrl_attr(path, "subsysnqn"); + cargs.transport = nvme_get_ctrl_attr(path, "transport"); + + if (!addr || !cargs.subsysnqn || !cargs.transport) { fprintf(stderr, "nvme_get_ctrl_attr failed\n"); - return found; + goto out; } - cargs.subsysnqn = nvme_get_ctrl_attr(path, "subsysnqn"); - cargs.transport = nvme_get_ctrl_attr(path, "transport"); cargs.traddr = parse_conn_arg(addr, ' ', conarg_traddr); cargs.trsvcid = parse_conn_arg(addr, ' ', conarg_trsvcid); cargs.host_traddr = parse_conn_arg(addr, ' ', conarg_host_traddr); @@ -340,12 +341,13 @@ static bool ctrl_matches_connectargs(const char *name, struct connect_args *args !strcmp(args->host_iface, "none"))) found = true; - free(cargs.subsysnqn); - free(cargs.transport); free(cargs.traddr); free(cargs.trsvcid); free(cargs.host_traddr); free(cargs.host_iface); +out: + free(cargs.subsysnqn); + free(cargs.transport); free(addr); free(path); @@ -852,9 +854,12 @@ static char *hostnqn_read_file(void) goto out; ret = strndup(hostnqn, strcspn(hostnqn, "\n")); - out: fclose(f); + if (ret && strcmp(ret, "") == 0) { + free(ret); + ret = NULL; + } return ret; } @@ -960,7 +965,7 @@ add_int_argument(char **argstr, int *max_len, char *arg_str, int arg, { int len; - if ((arg && !allow_zero) || (arg != -1 && allow_zero)) { + if (arg || allow_zero) { len = snprintf(*argstr, *max_len, ",%s=%d", arg_str, arg); if (len < 0) return -EINVAL; @@ -1001,9 +1006,6 @@ int build_options(char *argstr, int max_len, bool discover) msg(LOG_ERR, "need a address (-a) argument\n"); return -EINVAL; } - /* Use the default ctrl loss timeout if unset */ - if (fabrics_cfg.ctrl_loss_tmo == -1) - fabrics_cfg.ctrl_loss_tmo = NVMF_DEF_CTRL_LOSS_TMO; } /* always specify nqn as first arg - this will init the string */ @@ -1039,10 +1041,12 @@ int build_options(char *argstr, int max_len, bool discover) (strncmp(fabrics_cfg.transport, "loop", 4) && add_int_argument(&argstr, &max_len, "ctrl_loss_tmo", fabrics_cfg.ctrl_loss_tmo, true)) || + (fabrics_cfg.fast_io_fail_tmo != -1 && add_int_argument(&argstr, &max_len, "fast_io_fail_tmo", - fabrics_cfg.fast_io_fail_tmo, true) || + fabrics_cfg.fast_io_fail_tmo, true)) || + (fabrics_cfg.tos != -1 && add_int_argument(&argstr, &max_len, "tos", - fabrics_cfg.tos, true) || + fabrics_cfg.tos, true)) || add_bool_argument(&argstr, &max_len, "duplicate_connect", fabrics_cfg.duplicate_connect) || add_bool_argument(&argstr, &max_len, "disable_sqflow", |