Skip to content

Commit 003176a

Browse files
committed
libnvme: drop fabric_args
Remove the final references to 'fabric_args' and remove the structure. Signed-off-by: Hannes Reinecke <[email protected]>
1 parent 23c85f5 commit 003176a

2 files changed

Lines changed: 17 additions & 66 deletions

File tree

libnvme/src/nvme/fabrics.c

Lines changed: 17 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -2542,11 +2542,10 @@ static bool validate_uri(struct nvme_global_ctx *ctx,
25422542
static int nbft_connect(struct nvme_global_ctx *ctx,
25432543
struct nvmf_context *fctx, struct nvme_host *h,
25442544
struct nvmf_disc_log_entry *e,
2545-
struct nbft_info_subsystem_ns *ss, struct fabric_args *trcfg,
2545+
struct nbft_info_subsystem_ns *ss,
25462546
struct nvme_fabrics_config *cfg)
25472547
{
25482548
nvme_ctrl_t c;
2549-
struct nvmf_context nfctx = *fctx;
25502549
int saved_log_level;
25512550
bool saved_log_tstamp;
25522551
bool saved_log_pid;
@@ -2555,21 +2554,13 @@ static int nbft_connect(struct nvme_global_ctx *ctx,
25552554
saved_log_level = nvme_get_logging_level(ctx, &saved_log_tstamp,
25562555
&saved_log_pid);
25572556

2558-
/* Already connected ? */
2559-
nfctx.subsysnqn = trcfg->subsysnqn;
2560-
nfctx.transport = trcfg->transport;
2561-
nfctx.traddr = trcfg->traddr;
2562-
nfctx.trsvcid = trcfg->trsvcid;
2563-
nfctx.host_traddr = trcfg->host_traddr;
2564-
nfctx.host_iface = trcfg->host_iface;
2565-
2566-
c = lookup_ctrl(h, &nfctx);
2557+
c = lookup_ctrl(h, fctx);
25672558
if (c && nvme_ctrl_get_name(c))
25682559
return 0;
25692560

2570-
ret = nvme_create_ctrl(ctx, nfctx.subsysnqn, nfctx.transport,
2571-
nfctx.traddr, nfctx.host_traddr,
2572-
nfctx.host_iface, nfctx.trsvcid, &c);
2561+
ret = nvme_create_ctrl(ctx, fctx->subsysnqn, fctx->transport,
2562+
fctx->traddr, fctx->host_traddr,
2563+
fctx->host_iface, fctx->trsvcid, &c);
25732564
if (ret)
25742565
return ret;
25752566

@@ -2607,16 +2598,16 @@ static int nbft_connect(struct nvme_global_ctx *ctx,
26072598
return ret;
26082599
}
26092600

2610-
if (nfctx.connected)
2611-
nfctx.connected(&nfctx, c, nfctx.user_data);
2601+
if (fctx->connected)
2602+
fctx->connected(fctx, c, fctx->user_data);
26122603

26132604
return 0;
26142605
}
26152606

26162607
static int nbft_discovery(struct nvme_global_ctx *ctx,
26172608
struct nvmf_context *fctx, struct nbft_info_discovery *dd,
26182609
struct nvme_host *h, struct nvme_ctrl *c,
2619-
struct nvme_fabrics_config *defcfg, struct fabric_args *deftrcfg)
2610+
struct nvme_fabrics_config *defcfg)
26202611
{
26212612
struct nvmf_discovery_log *log = NULL;
26222613
int ret;
@@ -2650,15 +2641,6 @@ static int nbft_discovery(struct nvme_global_ctx *ctx,
26502641
nfctx.traddr = e->traddr;
26512642
nfctx.trsvcid = e->trsvcid;
26522643

2653-
struct fabric_args trcfg = {
2654-
.subsysnqn = e->subnqn,
2655-
.transport = nvmf_trtype_str(e->trtype),
2656-
.traddr = e->traddr,
2657-
.host_traddr = fctx->host_traddr,
2658-
.host_iface = fctx->host_iface,
2659-
.trsvcid = e->trsvcid,
2660-
};
2661-
26622644
if (e->subtype == NVME_NQN_CURR)
26632645
continue;
26642646

@@ -2680,27 +2662,26 @@ static int nbft_discovery(struct nvme_global_ctx *ctx,
26802662
defcfg, NULL, &child);
26812663
if (ret)
26822664
continue;
2683-
nbft_discovery(ctx, &nfctx, dd, h, child,
2684-
defcfg, &trcfg);
2665+
nbft_discovery(ctx, &nfctx, dd, h, child, defcfg);
26852666
nvme_disconnect_ctrl(child);
26862667
nvme_free_ctrl(child);
26872668
} else {
26882669
ret = nbft_connect(ctx, &nfctx, h, e, NULL,
2689-
&trcfg, defcfg);
2670+
defcfg);
26902671

26912672
/*
26922673
* With TCP/DHCP, it can happen that the OS
26932674
* obtains a different local IP address than the
26942675
* firmware had. Retry without host_traddr.
26952676
*/
26962677
if (ret == -ENVME_CONNECT_ADDRNOTAVAIL &&
2697-
!strcmp(trcfg.transport, "tcp") &&
2678+
!strcmp(nfctx.transport, "tcp") &&
26982679
strlen(dd->hfi->tcp_info.dhcp_server_ipaddr) > 0) {
2699-
const char *htradr = trcfg.host_traddr;
2680+
const char *htradr = nfctx.host_traddr;
27002681

2701-
trcfg.host_traddr = NULL;
2682+
nfctx.host_traddr = NULL;
27022683
ret = nbft_connect(ctx, &nfctx, h, e, NULL,
2703-
&trcfg, defcfg);
2684+
defcfg);
27042685

27052686
if (ret == 0)
27062687
nvme_msg(ctx, LOG_INFO,
@@ -2811,17 +2792,8 @@ int nvmf_discovery_nbft(struct nvme_global_ctx *ctx,
28112792
nfctx.trsvcid = (*ss)->trsvcid;
28122793
nfctx.host_iface = NULL;
28132794

2814-
struct fabric_args trcfg = {
2815-
.subsysnqn = (*ss)->subsys_nqn,
2816-
.transport = (*ss)->transport,
2817-
.traddr = (*ss)->traddr,
2818-
.trsvcid = (*ss)->trsvcid,
2819-
.host_traddr = host_traddr,
2820-
.host_iface = NULL,
2821-
};
2822-
28232795
rr = nbft_connect(ctx, &nfctx, h, NULL,
2824-
*ss, &trcfg, fctx->cfg);
2796+
*ss, fctx->cfg);
28252797

28262798
/*
28272799
* With TCP/DHCP, it can happen that the OS
@@ -2831,11 +2803,10 @@ int nvmf_discovery_nbft(struct nvme_global_ctx *ctx,
28312803
if (rr == -ENVME_CONNECT_ADDRNOTAVAIL &&
28322804
!strcmp(nfctx.transport, "tcp") &&
28332805
strlen(hfi->tcp_info.dhcp_server_ipaddr) > 0) {
2834-
trcfg.host_traddr = NULL;
28352806
nfctx.host_traddr = NULL;
28362807

28372808
rr = nbft_connect(ctx, &nfctx, h, NULL,
2838-
*ss, &trcfg, fctx->cfg);
2809+
*ss, fctx->cfg);
28392810

28402811
if (rr == 0)
28412812
nvme_msg(ctx, LOG_INFO,
@@ -2903,15 +2874,6 @@ int nvmf_discovery_nbft(struct nvme_global_ctx *ctx,
29032874
strdup(nvmf_get_default_trsvcid(
29042875
uri->protocol, true));
29052876

2906-
struct fabric_args trcfg = {
2907-
.subsysnqn = NVME_DISC_SUBSYS_NAME,
2908-
.transport = uri->protocol,
2909-
.traddr = uri->host,
2910-
.trsvcid = trsvcid,
2911-
.host_traddr = host_traddr,
2912-
.host_iface = NULL,
2913-
};
2914-
29152877
nfctx.subsysnqn = NVME_DISC_SUBSYS_NAME;
29162878
nfctx.transport = uri->protocol;
29172879
nfctx.traddr = uri->host;
@@ -2930,7 +2892,6 @@ int nvmf_discovery_nbft(struct nvme_global_ctx *ctx,
29302892
if (ret == -ENVME_CONNECT_ADDRNOTAVAIL &&
29312893
!strcmp(nfctx.transport, "tcp") &&
29322894
strlen(hfi->tcp_info.dhcp_server_ipaddr) > 0) {
2933-
trcfg.host_traddr = NULL;
29342895
nfctx.traddr = NULL;
29352896
ret = nvmf_create_discovery_ctrl(ctx,
29362897
&nfctx, h, fctx->cfg, &c);
@@ -2945,8 +2906,7 @@ int nvmf_discovery_nbft(struct nvme_global_ctx *ctx,
29452906
goto out_free;
29462907
}
29472908

2948-
rr = nbft_discovery(ctx, &nfctx, *dd, h, c, fctx->cfg,
2949-
&trcfg);
2909+
rr = nbft_discovery(ctx, &nfctx, *dd, h, c, fctx->cfg);
29502910
if (!persistent)
29512911
nvme_disconnect_ctrl(c);
29522912
nvme_free_ctrl(c);

libnvme/src/nvme/private.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -405,15 +405,6 @@ struct nvmf_context {
405405
void *user_data;
406406
};
407407

408-
struct fabric_args {
409-
const char *subsysnqn;
410-
const char *transport;
411-
const char *traddr;
412-
const char *trsvcid;
413-
const char *host_traddr;
414-
const char *host_iface;
415-
};
416-
417408
int nvme_set_attr(const char *dir, const char *attr, const char *value);
418409

419410
int json_read_config(struct nvme_global_ctx *ctx, const char *config_file);

0 commit comments

Comments
 (0)