Commit 185aeaa1 authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Jim Harris
Browse files

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: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/403148


Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
parent 9f9ca644
Loading
Loading
Loading
Loading
+18 −30
Original line number Diff line number Diff line
@@ -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;
	}