Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-15-SP2:Update
nvme-cli
0012-fabrics-move-connect_args-extraction-to-a-...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0012-fabrics-move-connect_args-extraction-to-a-dedicated-.patch of Package nvme-cli
From: Sagi Grimberg <sagi@grimberg.me> Date: Fri, 14 Aug 2020 13:42:38 -0700 Subject: [PATCH] fabrics: move connect_args extraction to a dedicated routin References: bsc#1179825 Git-commit: 1ca2593ee13a052b038ee3d4a16af14ccb9e578b We will need it to track controllers as we are iterating over nested discovery log pages recursion. Signed-off-by: Sagi Grimberg <sagi@grimberg.me> Signed-off-by: Keith Busch <kbusch@kernel.org> --- fabrics.c | 46 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 14 deletions(-) --- a/fabrics.c +++ b/fabrics.c @@ -354,6 +354,31 @@ static char *find_ctrl_with_connectargs( return devname; } +static struct connect_args *extract_connect_args(char *argstr) +{ + struct connect_args *cargs; + + cargs = calloc(1, sizeof(*cargs)); + if (!cargs) + return NULL; + cargs->subsysnqn = parse_conn_arg(argstr, ',', conarg_nqn); + cargs->transport = parse_conn_arg(argstr, ',', conarg_transport); + cargs->traddr = parse_conn_arg(argstr, ',', conarg_traddr); + cargs->trsvcid = parse_conn_arg(argstr, ',', conarg_trsvcid); + cargs->host_traddr = parse_conn_arg(argstr, ',', conarg_host_traddr); + return cargs; +} + +static void free_connect_args(struct connect_args *cargs) +{ + free(cargs->subsysnqn); + free(cargs->transport); + free(cargs->traddr); + free(cargs->trsvcid); + free(cargs->host_traddr); + free(cargs); +} + static int add_ctrl(const char *argstr) { substring_t args[MAX_OPT_ARGS]; @@ -1113,14 +1138,11 @@ static int do_discover(char *argstr, boo int status = 0; if (cfg.device) { - struct connect_args cargs; + struct connect_args *cargs; - memset(&cargs, 0, sizeof(cargs)); - cargs.subsysnqn = parse_conn_arg(argstr, '.', conarg_nqn); - cargs.transport = parse_conn_arg(argstr, '.', conarg_transport); - cargs.traddr = parse_conn_arg(argstr, '.', conarg_traddr); - cargs.trsvcid = parse_conn_arg(argstr, '.', conarg_trsvcid); - cargs.host_traddr = parse_conn_arg(argstr, '.', conarg_host_traddr); + cargs = extract_connect_args(argstr); + if (!cargs) + return -ENOMEM; /* * if the cfg.device passed in matches the connect args @@ -1133,14 +1155,10 @@ static int do_discover(char *argstr, boo * create a new ctrl. * endif */ - if (!ctrl_matches_connectargs(cfg.device, &cargs)) - cfg.device = find_ctrl_with_connectargs(&cargs); + if (!ctrl_matches_connectargs(cfg.device, cargs)) + cfg.device = find_ctrl_with_connectargs(cargs); - free(cargs.subsysnqn); - free(cargs.transport); - free(cargs.traddr); - free(cargs.trsvcid); - free(cargs.host_traddr); + free_connect_args(cargs); } if (!cfg.device)
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