From 185aeaa1afb2d7016535cc20c589c512c386e3f8 Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Fri, 9 Mar 2018 08:23:53 +0900 Subject: [PATCH] iscsi: Aggregate all init operations of iSCSI globals into a function Some variables of struct spdk_iscsi_globals are initialized by using .INI config file but others are initialized without using .INI config file. This patch aggregates all initialization operations into a function spdk_iscsi_initialize_iscsi_globals(). Next patch move the code to read .INI config file from spdk_iscsi_initialize_iscsi_globals() to spdk_iscsi_parse_iscsi_globals() to make implementation cleaner. The purpose of the patch series is - to separate iSCSI subsystem initialization and iSCSI subsystem configuration, and - to develop a new JSON-RPC by reusing the separated iSCSI subsystem initialization. Change-Id: I0bda0de1d8bf1ba5e4b4e5157949fd300ec9ff9d Signed-off-by: Shuhei Matsumoto Reviewed-on: https://review.gerrithub.io/403148 Reviewed-by: Jim Harris Tested-by: SPDK Automated Test System Reviewed-by: Daniel Verkamp --- lib/iscsi/iscsi_subsystem.c | 48 ++++++++++++++----------------------- 1 file changed, 18 insertions(+), 30 deletions(-) diff --git a/lib/iscsi/iscsi_subsystem.c b/lib/iscsi/iscsi_subsystem.c index f0d5dd1f4..acb9ff4bc 100644 --- a/lib/iscsi/iscsi_subsystem.c +++ b/lib/iscsi/iscsi_subsystem.c @@ -759,8 +759,10 @@ spdk_iscsi_read_parameters_from_config_file(struct spdk_conf_section *sp, } static int -spdk_iscsi_initialize_iscsi_global_params(struct spdk_iscsi_opts *opts) +spdk_iscsi_initialize_iscsi_globals(struct spdk_iscsi_opts *opts) { + int rc; + if (!opts->authfile) { SPDK_ERRLOG("opts->authfile is NULL\n"); return -EINVAL; @@ -798,32 +800,6 @@ spdk_iscsi_initialize_iscsi_global_params(struct spdk_iscsi_opts *opts) g_spdk_iscsi.req_discovery_auth_mutual = opts->req_discovery_auth; g_spdk_iscsi.discovery_auth_group = opts->discovery_auth_group; - return 0; -} - -static int -spdk_iscsi_app_read_parameters(void) -{ - struct spdk_conf_section *sp; - struct spdk_iscsi_opts opts; - int rc; - - spdk_iscsi_opts_init(&opts); - - /* Process parameters */ - SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "spdk_iscsi_app_read_parameters\n"); - sp = spdk_conf_find_section(NULL, "iSCSI"); - if (sp != NULL) { - spdk_iscsi_read_parameters_from_config_file(sp, &opts); - } - - rc = spdk_iscsi_initialize_iscsi_global_params(&opts); - spdk_iscsi_opts_free(&opts); - if (rc != 0) { - SPDK_ERRLOG("spdk_iscsi_initialize_iscsi_global_params() failed\n"); - return rc; - } - g_spdk_iscsi.session = spdk_dma_zmalloc(sizeof(void *) * g_spdk_iscsi.MaxSessions, 0, NULL); if (!g_spdk_iscsi.session) { SPDK_ERRLOG("spdk_dma_zmalloc() failed for session array\n"); @@ -982,11 +958,23 @@ end: static int spdk_iscsi_parse_iscsi_globals(void) { + struct spdk_conf_section *sp; + struct spdk_iscsi_opts opts; int rc; - rc = spdk_iscsi_app_read_parameters(); - if (rc < 0) { - SPDK_ERRLOG("spdk_iscsi_app_read_parameters() failed\n"); + spdk_iscsi_opts_init(&opts); + + /* Process parameters */ + SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "spdk_iscsi_app_read_parameters\n"); + sp = spdk_conf_find_section(NULL, "iSCSI"); + if (sp != NULL) { + spdk_iscsi_read_parameters_from_config_file(sp, &opts); + } + + rc = spdk_iscsi_initialize_iscsi_globals(&opts); + spdk_iscsi_opts_free(&opts); + if (rc != 0) { + SPDK_ERRLOG("spdk_iscsi_initialize_iscsi_globals() failed\n"); return rc; }