Skip to content

Commit 0ba11d2

Browse files
dwsuseigaw
authored andcommitted
fabrics: add ctrl connect interface
A controller can already be created by the config, thus it is already in the tree. Adding to the tree is wrong and will lead to double frees when releasing the tree. Signed-off-by: Daniel Wagner <[email protected]>
1 parent e0db450 commit 0ba11d2

3 files changed

Lines changed: 30 additions & 0 deletions

File tree

src/libnvme.map

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ LIBNVME_1.11 {
99
nvme_ctrl_set_tls_key_identity;
1010
nvme_export_tls_key_versioned;
1111
nvme_import_tls_key_versioned;
12+
nvmf_connect_ctrl;
1213
};
1314

1415

src/nvme/fabrics.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -979,6 +979,24 @@ int nvmf_add_ctrl(nvme_host_t h, nvme_ctrl_t c,
979979
return nvme_init_ctrl(h, c, ret);
980980
}
981981

982+
int nvmf_connect_ctrl(nvme_ctrl_t c)
983+
{
984+
_cleanup_free_ char *argstr = NULL;
985+
int ret;
986+
987+
ret = build_options(c->s->h, c, &argstr);
988+
if (ret)
989+
return ret;
990+
991+
ret = __nvmf_add_ctrl(c->s->h->r, argstr);
992+
if (ret < 0) {
993+
errno = -ret;
994+
return -1;
995+
}
996+
997+
return 0;
998+
}
999+
9821000
nvme_ctrl_t nvmf_connect_disc_entry(nvme_host_t h,
9831001
struct nvmf_disc_log_entry *e,
9841002
const struct nvme_fabrics_config *cfg,

src/nvme/fabrics.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,17 @@ void nvmf_update_config(nvme_ctrl_t c, const struct nvme_fabrics_config *cfg);
223223
int nvmf_add_ctrl(nvme_host_t h, nvme_ctrl_t c,
224224
const struct nvme_fabrics_config *cfg);
225225

226+
/**
227+
* nvmf_connect_ctrl() - Connect a controller
228+
* @c: Controller to be connected
229+
*
230+
* Issues a 'connect' command to the NVMe-oF controller.
231+
* @c must be initialized and not connected to the topology.
232+
*
233+
* Return: 0 on success; on failure errno is set and -1 is returned.
234+
*/
235+
int nvmf_connect_ctrl(nvme_ctrl_t c);
236+
226237
/**
227238
* nvmf_get_discovery_log() - Return the discovery log page
228239
* @c: Discovery controller to use

0 commit comments

Comments
 (0)