Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Step:FrontRunner
libnvme.24569
0005-tree-Factor-lookup-code-for-controller.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0005-tree-Factor-lookup-code-for-controller.patch of Package libnvme.24569
From: Daniel Wagner <dwagner@suse.de> Date: Thu, 19 May 2022 10:44:24 +0200 Subject: tree: Factor lookup code for controller Git-commit: c6611bb0962424f1cfbc528c2264bbbb5a0a661e References: bsc#1199503 nvme_lookup_ctrl() will create a controller if it is not found. In the case where we really just want the lookup if a controller is in the tree we are missing a pure lookup function. Hence factor out the lookup into a internal function. Signed-off-by: Daniel Wagner <dwagner@suse.de> --- src/nvme/private.h | 5 +++++ src/nvme/tree.c | 34 ++++++++++++++++++++++++++-------- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/src/nvme/private.h b/src/nvme/private.h index be570f6ec35d..5299b13ace63 100644 --- a/src/nvme/private.h +++ b/src/nvme/private.h @@ -132,6 +132,11 @@ int json_update_config(nvme_root_t r, const char *config_file); int json_dump_tree(nvme_root_t r); +nvme_ctrl_t __nvme_lookup_ctrl(nvme_subsystem_t s, const char *transport, + const char *traddr, const char *host_traddr, + const char *host_iface, const char *trsvcid, + nvme_ctrl_t p); + #if (LOG_FUNCNAME == 1) #define __nvme_log_func __func__ #else diff --git a/src/nvme/tree.c b/src/nvme/tree.c index a7b039779f54..79525293eec5 100644 --- a/src/nvme/tree.c +++ b/src/nvme/tree.c @@ -1020,17 +1020,14 @@ struct nvme_ctrl *nvme_create_ctrl(nvme_root_t r, return c; } -nvme_ctrl_t nvme_lookup_ctrl(nvme_subsystem_t s, const char *transport, - const char *traddr, const char *host_traddr, - const char *host_iface, const char *trsvcid, - nvme_ctrl_t p) +nvme_ctrl_t __nvme_lookup_ctrl(nvme_subsystem_t s, const char *transport, + const char *traddr, const char *host_traddr, + const char *host_iface, const char *trsvcid, + nvme_ctrl_t p) + { - nvme_root_t r; struct nvme_ctrl *c; - if (!s || !transport) - return NULL; - r = s->h ? s->h->r : NULL; c = p ? nvme_subsystem_next_ctrl(s, p) : nvme_subsystem_first_ctrl(s); for (; c != NULL; c = nvme_subsystem_next_ctrl(s, c)) { if (strcmp(c->transport, transport)) @@ -1049,6 +1046,27 @@ nvme_ctrl_t nvme_lookup_ctrl(nvme_subsystem_t s, const char *transport, continue; return c; } + + return NULL; +} + +nvme_ctrl_t nvme_lookup_ctrl(nvme_subsystem_t s, const char *transport, + const char *traddr, const char *host_traddr, + const char *host_iface, const char *trsvcid, + nvme_ctrl_t p) +{ + nvme_root_t r; + struct nvme_ctrl *c; + + if (!s || !transport) + return NULL; + + c = __nvme_lookup_ctrl(s, transport, traddr, host_traddr, + host_iface, trsvcid, p); + if (c) + return c; + + r = s->h ? s->h->r : NULL; c = nvme_create_ctrl(r, s->subsysnqn, transport, traddr, host_traddr, host_iface, trsvcid); if (c) { -- 2.36.1
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor