Skip to content

Commit 0d3378f

Browse files
committed
libnvme: Introduct _nvme_ctrl_match_config()
To simplify the interface. Signed-off-by: Hannes Reinecke <[email protected]>
1 parent bdb48f0 commit 0d3378f

3 files changed

Lines changed: 14 additions & 10 deletions

File tree

libnvme/src/nvme/fabrics.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2925,10 +2925,7 @@ __public int nvmf_discovery(struct nvme_global_ctx *ctx, struct nvmf_context *fc
29252925
ret = nvme_scan_ctrl(ctx, fctx->device, &c);
29262926
if (!ret) {
29272927
/* Check if device matches command-line options */
2928-
if (!nvme_ctrl_match_config(c, fctx->transport,
2929-
fctx->traddr, fctx->trsvcid,
2930-
fctx->subsysnqn, fctx->host_traddr,
2931-
fctx->host_iface)) {
2928+
if (!_nvme_ctrl_match_config(c, fctx)) {
29322929
nvme_msg(ctx, LOG_ERR,
29332930
"ctrl device %s found, ignoring non matching command-line options\n",
29342931
fctx->device);

libnvme/src/nvme/private.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@ int _nvme_create_ctrl(struct nvme_global_ctx *ctx,
387387
nvme_ctrl_t __nvme_lookup_ctrl(nvme_subsystem_t s,
388388
struct nvmf_context *fctx,
389389
nvme_ctrl_t p);
390+
bool _nvme_ctrl_match_config(struct nvme_ctrl *c, struct nvmf_context *fctx);
390391

391392
void *__nvme_alloc(size_t len);
392393

libnvme/src/nvme/tree.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1472,13 +1472,22 @@ nvme_ctrl_t __nvme_lookup_ctrl(nvme_subsystem_t s, struct nvmf_context *fctx,
14721472
return matching_c;
14731473
}
14741474

1475+
bool _nvme_ctrl_match_config(struct nvme_ctrl *c, struct nvmf_context *fctx)
1476+
{
1477+
struct candidate_args candidate = {};
1478+
ctrl_match_t ctrl_match;
1479+
1480+
/* Init candidate and get the matching function to use */
1481+
ctrl_match = _candidate_init(c->ctx, &candidate, fctx);
1482+
1483+
return ctrl_match(c, &candidate);
1484+
}
1485+
14751486
__public bool nvme_ctrl_match_config(struct nvme_ctrl *c, const char *transport,
14761487
const char *traddr, const char *trsvcid,
14771488
const char *subsysnqn, const char *host_traddr,
14781489
const char *host_iface)
14791490
{
1480-
struct candidate_args candidate = {};
1481-
ctrl_match_t ctrl_match;
14821491
struct nvmf_context fctx = {
14831492
.transport = transport,
14841493
.traddr = traddr,
@@ -1488,10 +1497,7 @@ __public bool nvme_ctrl_match_config(struct nvme_ctrl *c, const char *transport,
14881497
.subsysnqn = subsysnqn,
14891498
};
14901499

1491-
/* Init candidate and get the matching function to use */
1492-
ctrl_match = _candidate_init(c->ctx, &candidate, &fctx);
1493-
1494-
return ctrl_match(c, &candidate);
1500+
return _nvme_ctrl_match_config(c, &fctx);
14951501
}
14961502

14971503
nvme_ctrl_t nvme_ctrl_find(nvme_subsystem_t s, struct nvmf_context *fctx)

0 commit comments

Comments
 (0)