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 <shuhei.matsumoto.xt@hitachi.com> Reviewed-on: https://review.gerrithub.io/403148 Reviewed-by: Jim Harris <james.r.harris@intel.com> Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
parent
9f9ca64422
commit
185aeaa1af
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user