Skip to content

Commit aeb4894

Browse files
committed
libnvme/fabrics: remove duplicate discovery functions
During merge two sets of discovery functions had been created with identical content. Delete one set. Signed-off-by: Hannes Reinecke <[email protected]>
1 parent 5c8fa81 commit aeb4894

1 file changed

Lines changed: 1 addition & 87 deletions

File tree

libnvme/src/nvme/fabrics.c

Lines changed: 1 addition & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -2936,92 +2936,6 @@ int nvmf_discovery_nbft(struct nvme_global_ctx *ctx,
29362936
return ret;
29372937
}
29382938

2939-
static int __create_discover_ctrl(struct nvme_global_ctx *ctx,
2940-
struct nvmf_context *fctx, nvme_host_t h,
2941-
struct nvme_fabrics_config *cfg, struct fabric_args *trcfg,
2942-
struct nvme_ctrl **ctrl)
2943-
{
2944-
struct nvme_ctrl *c;
2945-
int tmo, ret;
2946-
2947-
ret = nvme_create_ctrl(ctx, trcfg->subsysnqn, trcfg->transport,
2948-
trcfg->traddr, trcfg->host_traddr,
2949-
trcfg->host_iface, trcfg->trsvcid, &c);
2950-
if (ret)
2951-
return ret;
2952-
2953-
nvme_ctrl_set_discovery_ctrl(c, true);
2954-
nvme_ctrl_set_unique_discovery_ctrl(c,
2955-
strcmp(trcfg->subsysnqn, NVME_DISC_SUBSYS_NAME));
2956-
tmo = set_discovery_kato(fctx, cfg);
2957-
2958-
ret = nvme_add_ctrl(fctx, h, c, cfg);
2959-
cfg->keep_alive_tmo = tmo;
2960-
if (ret) {
2961-
nvme_free_ctrl(c);
2962-
return ret;
2963-
}
2964-
2965-
*ctrl = c;
2966-
return 0;
2967-
}
2968-
2969-
static int nvmf_create_discover_ctrl(struct nvme_global_ctx *ctx,
2970-
struct nvmf_context *fctx,
2971-
struct nvme_host *h, struct nvme_fabrics_config *cfg,
2972-
struct fabric_args *trcfg, struct nvme_ctrl **ctrl)
2973-
{
2974-
_cleanup_free_ struct nvme_id_ctrl *id = NULL;
2975-
struct nvme_ctrl *c;
2976-
int ret;
2977-
2978-
ret = __create_discover_ctrl(ctx, fctx, h, cfg, trcfg, &c);
2979-
if (ret)
2980-
return ret;
2981-
2982-
if (nvme_ctrl_is_unique_discovery_ctrl(c)) {
2983-
*ctrl = c;
2984-
return 0;
2985-
}
2986-
2987-
id = __nvme_alloc(sizeof(*id));
2988-
if (!id) {
2989-
nvme_free_ctrl(c);
2990-
return -ENOMEM;
2991-
}
2992-
2993-
/* Find out the name of discovery controller */
2994-
ret = nvme_ctrl_identify(c, id);
2995-
if (ret) {
2996-
nvme_msg(ctx, LOG_ERR,
2997-
"failed to identify controller, error %s\n",
2998-
nvme_strerror(-ret));
2999-
nvme_disconnect_ctrl(c);
3000-
nvme_free_ctrl(c);
3001-
return ret;
3002-
}
3003-
3004-
if (!strcmp(id->subnqn, NVME_DISC_SUBSYS_NAME)) {
3005-
*ctrl = c;
3006-
return 0;
3007-
}
3008-
3009-
/*
3010-
* The subsysnqn is not the well-known name. Prefer the unique
3011-
* subsysnqn over the well-known one.
3012-
*/
3013-
nvme_disconnect_ctrl(c);
3014-
nvme_free_ctrl(c);
3015-
3016-
trcfg->subsysnqn = id->subnqn;
3017-
ret = __create_discover_ctrl(ctx, fctx, h, cfg, trcfg, &c);
3018-
if (ret)
3019-
return ret;
3020-
3021-
*ctrl = c;
3022-
return 0;
3023-
}
3024-
30252939
int nvmf_discovery(struct nvme_global_ctx *ctx, struct nvmf_context *fctx,
30262940
bool connect, bool force)
30272941
{
@@ -3111,7 +3025,7 @@ int nvmf_discovery(struct nvme_global_ctx *ctx, struct nvmf_context *fctx,
31113025
}
31123026
if (!c) {
31133027
/* No device or non-matching device, create a new controller */
3114-
ret = nvmf_create_discover_ctrl(ctx, fctx, h, fctx->cfg,
3028+
ret = nvmf_create_discovery_ctrl(ctx, fctx, h, fctx->cfg,
31153029
&trcfg, &c);
31163030
if (ret) {
31173031
if (ret != -ENVME_CONNECT_IGNORED)

0 commit comments

Comments
 (0)