iscsi: Change function names of iSCSI subsystem configuration

Portal, portal group, initiator group, and target node don't use fixed size
array anymore. To use the same naming rule in iSCSI subsystem and in SPDK
is helpful to understand and maintain. Current naming rule is not bad but
to use unified and compact name is prioritized at this time.

This patch changes function names as follows:
- spdk_iscsi_init_tgt_nodes() -> spdk_iscsi_parse_tgt_nodes()
- spdk_cf_add_iscsi_tgt_node() -> spdk_iscsi_parse_tgt_node()

- spdk_iscsi_portal_grp_array_create() -> spdk_iscsi_parse_portal_grps()
- spdk_iscsi_portal_grp_create_from_configfile() -> spdk_iscsi_parse_portal_grp()
- spdk_iscsi_portal_create_from_configline() -> spdk_iscsi_parse_portal()
- spdk_iscsi_portal_grp_array_destroy() -> spdk_iscsi_portal_grps_destroy()

- spdk_iscsi_init_grp_array_create() -> spdk_iscsi_parse_init_grps()
- spdk_iscsi_init_grp_create_from_configfile() -> spdk_iscsi_parse_init_grp()
- spdk_iscsi_init_grp_array_destroy() -> spdk_iscsi_init_grps_destroy()

For example "parse" is already used to explain the operation in portal_grp.c.
Hence using "parse" is familiar and not strange in iSCSI.

Change-Id: Ieff952069d39bd96b7afa1586bfff927968accc2
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/403149
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
Shuhei Matsumoto 2018-03-09 08:25:34 +09:00 committed by Jim Harris
parent 185aeaa1af
commit 3af8e26df8
10 changed files with 65 additions and 66 deletions

View File

@ -327,7 +327,7 @@ cleanup:
/* Read spdk iscsi target's config file and create initiator group */
static int
spdk_iscsi_init_grp_create_from_configfile(struct spdk_conf_section *sp)
spdk_iscsi_parse_init_grp(struct spdk_conf_section *sp)
{
int i, rc = 0;
const char *val = NULL;
@ -622,7 +622,7 @@ spdk_iscsi_init_grp_find_by_tag(int tag)
}
int
spdk_iscsi_init_grp_array_create(void)
spdk_iscsi_parse_init_grps(void)
{
struct spdk_conf_section *sp;
int rc;
@ -634,9 +634,9 @@ spdk_iscsi_init_grp_array_create(void)
SPDK_ERRLOG("Group 0 is invalid\n");
return -1;
}
rc = spdk_iscsi_init_grp_create_from_configfile(sp);
rc = spdk_iscsi_parse_init_grp(sp);
if (rc < 0) {
SPDK_ERRLOG("add_initiator_group() failed\n");
SPDK_ERRLOG("parse_init_group() failed\n");
return -1;
}
}
@ -646,7 +646,7 @@ spdk_iscsi_init_grp_array_create(void)
}
void
spdk_iscsi_init_grp_array_destroy(void)
spdk_iscsi_init_grps_destroy(void)
{
struct spdk_iscsi_init_grp *ig, *tmp;

View File

@ -71,7 +71,7 @@ int spdk_iscsi_init_grp_register(struct spdk_iscsi_init_grp *ig);
struct spdk_iscsi_init_grp *spdk_iscsi_init_grp_unregister(int tag);
struct spdk_iscsi_init_grp *spdk_iscsi_init_grp_find_by_tag(int tag);
void spdk_iscsi_init_grp_destroy(struct spdk_iscsi_init_grp *ig);
int spdk_iscsi_init_grp_array_create(void);
void spdk_iscsi_init_grp_array_destroy(void);
int spdk_iscsi_parse_init_grps(void);
void spdk_iscsi_init_grps_destroy(void);
#endif // SPDK_INIT_GRP_H

View File

@ -600,8 +600,8 @@ spdk_iscsi_opts_free(struct spdk_iscsi_opts *opts)
}
static void
spdk_iscsi_read_parameters_from_config_file(struct spdk_conf_section *sp,
struct spdk_iscsi_opts *opts)
spdk_iscsi_read_config_file_params(struct spdk_conf_section *sp,
struct spdk_iscsi_opts *opts)
{
const char *val;
int MaxSessions;
@ -934,21 +934,21 @@ spdk_iscsi_parse_iscsi_configuration(void *ctx)
{
int rc;
rc = spdk_iscsi_portal_grp_array_create();
rc = spdk_iscsi_parse_portal_grps();
if (rc < 0) {
SPDK_ERRLOG("spdk_iscsi_portal_grp_array_create() failed\n");
SPDK_ERRLOG("spdk_iscsi_parse_portal_grps() failed\n");
goto end;
}
rc = spdk_iscsi_init_grp_array_create();
rc = spdk_iscsi_parse_init_grps();
if (rc < 0) {
SPDK_ERRLOG("spdk_iscsi_init_grp_array_create() failed\n");
SPDK_ERRLOG("spdk_iscsi_parse_init_grps() failed\n");
goto end;
}
rc = spdk_iscsi_init_tgt_nodes();
rc = spdk_iscsi_parse_tgt_nodes();
if (rc < 0) {
SPDK_ERRLOG("spdk_iscsi_init_tgt_nodes() failed\n");
SPDK_ERRLOG("spdk_iscsi_parse_tgt_nodes() failed\n");
}
end:
@ -965,10 +965,10 @@ spdk_iscsi_parse_iscsi_globals(void)
spdk_iscsi_opts_init(&opts);
/* Process parameters */
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "spdk_iscsi_app_read_parameters\n");
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "spdk_iscsi_read_config_file_parmas\n");
sp = spdk_conf_find_section(NULL, "iSCSI");
if (sp != NULL) {
spdk_iscsi_read_parameters_from_config_file(sp, &opts);
spdk_iscsi_read_config_file_params(sp, &opts);
}
rc = spdk_iscsi_initialize_iscsi_globals(&opts);
@ -1027,8 +1027,8 @@ spdk_iscsi_fini_done(void *arg)
spdk_iscsi_free_pools();
spdk_iscsi_shutdown_tgt_nodes();
spdk_iscsi_init_grp_array_destroy();
spdk_iscsi_portal_grp_array_destroy();
spdk_iscsi_init_grps_destroy();
spdk_iscsi_portal_grps_destroy();
free(g_spdk_iscsi.authfile);
free(g_spdk_iscsi.nodebase);
free(g_spdk_iscsi.poll_group);

View File

@ -217,9 +217,8 @@ spdk_iscsi_portal_close(struct spdk_iscsi_portal *p)
}
static int
spdk_iscsi_portal_create_from_configline(const char *portalstring,
struct spdk_iscsi_portal **ip,
int dry_run)
spdk_iscsi_parse_portal(const char *portalstring, struct spdk_iscsi_portal **ip,
int dry_run)
{
char *host = NULL, *port = NULL, *cpumask = NULL;
int len, rc = -1;
@ -394,7 +393,7 @@ spdk_iscsi_portal_grp_add_portal(struct spdk_iscsi_portal_grp *pg,
}
static int
spdk_iscsi_portal_grp_create_from_configfile(struct spdk_conf_section *sp)
spdk_iscsi_parse_portal_grp(struct spdk_conf_section *sp)
{
struct spdk_iscsi_portal_grp *pg;
struct spdk_iscsi_portal *p;
@ -422,7 +421,7 @@ spdk_iscsi_portal_grp_create_from_configfile(struct spdk_conf_section *sp)
if (label == NULL || portal == NULL) {
break;
}
rc = spdk_iscsi_portal_create_from_configline(portal, &p, 1);
rc = spdk_iscsi_parse_portal(portal, &p, 1);
if (rc < 0) {
SPDK_ERRLOG("parse portal error (%s)\n", portal);
return -1;
@ -449,7 +448,7 @@ spdk_iscsi_portal_grp_create_from_configfile(struct spdk_conf_section *sp)
goto error;
}
rc = spdk_iscsi_portal_create_from_configline(portal, &p, 0);
rc = spdk_iscsi_parse_portal(portal, &p, 0);
if (rc < 0) {
SPDK_ERRLOG("parse portal error (%s)\n", portal);
goto error;
@ -497,7 +496,7 @@ spdk_iscsi_portal_grp_find_by_tag(int tag)
}
int
spdk_iscsi_portal_grp_array_create(void)
spdk_iscsi_parse_portal_grps(void)
{
int rc = 0;
struct spdk_conf_section *sp;
@ -511,7 +510,7 @@ spdk_iscsi_portal_grp_array_create(void)
}
/* Build portal group from cfg section PortalGroup */
rc = spdk_iscsi_portal_grp_create_from_configfile(sp);
rc = spdk_iscsi_parse_portal_grp(sp);
if (rc < 0) {
SPDK_ERRLOG("parse_portal_group() failed\n");
return -1;
@ -523,11 +522,11 @@ spdk_iscsi_portal_grp_array_create(void)
}
void
spdk_iscsi_portal_grp_array_destroy(void)
spdk_iscsi_portal_grps_destroy(void)
{
struct spdk_iscsi_portal_grp *pg;
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "spdk_iscsi_portal_grp_array_destroy\n");
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "spdk_iscsi_portal_grps_destroy\n");
pthread_mutex_lock(&g_spdk_iscsi.mutex);
while (!TAILQ_EMPTY(&g_spdk_iscsi.pg_head)) {
pg = TAILQ_FIRST(&g_spdk_iscsi.pg_head);

View File

@ -67,8 +67,8 @@ void spdk_iscsi_portal_grp_add_portal(struct spdk_iscsi_portal_grp *pg,
struct spdk_iscsi_portal *p);
void spdk_iscsi_portal_grp_destroy(struct spdk_iscsi_portal_grp *pg);
void spdk_iscsi_portal_grp_release(struct spdk_iscsi_portal_grp *pg);
int spdk_iscsi_portal_grp_array_create(void);
void spdk_iscsi_portal_grp_array_destroy(void);
int spdk_iscsi_parse_portal_grps(void);
void spdk_iscsi_portal_grps_destroy(void);
int spdk_iscsi_portal_grp_register(struct spdk_iscsi_portal_grp *pg);
struct spdk_iscsi_portal_grp *spdk_iscsi_portal_grp_unregister(int tag);
struct spdk_iscsi_portal_grp *spdk_iscsi_portal_grp_find_by_tag(int tag);

View File

@ -971,7 +971,7 @@ spdk_iscsi_tgt_node_construct(int target_index,
}
static int
spdk_cf_add_iscsi_tgt_node(struct spdk_conf_section *sp)
spdk_iscsi_parse_tgt_node(struct spdk_conf_section *sp)
{
char buf[MAX_TMPBUF];
struct spdk_iscsi_tgt_node *target;
@ -1192,12 +1192,12 @@ spdk_cf_add_iscsi_tgt_node(struct spdk_conf_section *sp)
return 0;
}
int spdk_iscsi_init_tgt_nodes(void)
int spdk_iscsi_parse_tgt_nodes(void)
{
struct spdk_conf_section *sp;
int rc;
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "spdk_iscsi_init_tgt_nodes\n");
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "spdk_iscsi_parse_tgt_nodes\n");
sp = spdk_conf_first_section(NULL);
while (sp != NULL) {
@ -1208,9 +1208,9 @@ int spdk_iscsi_init_tgt_nodes(void)
SPDK_ERRLOG("tag %d is invalid\n", tag);
return -1;
}
rc = spdk_cf_add_iscsi_tgt_node(sp);
rc = spdk_iscsi_parse_tgt_node(sp);
if (rc < 0) {
SPDK_ERRLOG("spdk_cf_add_iscsi_tgt_node() failed\n");
SPDK_ERRLOG("spdk_iscsi_parse_tgt_node() failed\n");
return -1;
}
}

View File

@ -87,7 +87,7 @@ struct spdk_iscsi_tgt_node {
TAILQ_ENTRY(spdk_iscsi_tgt_node) tailq;
};
int spdk_iscsi_init_tgt_nodes(void);
int spdk_iscsi_parse_tgt_nodes(void);
void spdk_iscsi_shutdown_tgt_nodes(void);
int spdk_iscsi_shutdown_tgt_node_by_name(const char *target_name);

View File

@ -73,10 +73,10 @@ create_from_config_file_cases(void)
break;
}
rc = spdk_iscsi_init_grp_create_from_configfile(sp);
rc = spdk_iscsi_parse_init_grp(sp);
CU_ASSERT(rc == 0);
spdk_iscsi_init_grp_array_destroy();
spdk_iscsi_init_grps_destroy();
section_index++;
}
@ -90,10 +90,10 @@ create_from_config_file_cases(void)
break;
}
rc = spdk_iscsi_init_grp_create_from_configfile(sp);
rc = spdk_iscsi_parse_init_grp(sp);
CU_ASSERT(rc != 0);
spdk_iscsi_init_grp_array_destroy();
spdk_iscsi_init_grps_destroy();
section_index++;
}

View File

@ -163,7 +163,7 @@ portal_create_twice_case(void)
}
static void
portal_create_from_configline_ipv4_normal_case(void)
parse_portal_ipv4_normal_case(void)
{
const char *string = "192.168.2.0:3260@1";
const char *host_str = "192.168.2.0";
@ -177,7 +177,7 @@ portal_create_from_configline_ipv4_normal_case(void)
spdk_cpuset_set_cpu(cpumask_val, 0, true);
rc = spdk_iscsi_portal_create_from_configline(string, &p, 0);
rc = spdk_iscsi_parse_portal(string, &p, 0);
CU_ASSERT(rc == 0);
CU_ASSERT(strcmp(p->host, host_str) == 0);
CU_ASSERT(strcmp(p->port, port_str) == 0);
@ -190,7 +190,7 @@ portal_create_from_configline_ipv4_normal_case(void)
}
static void
portal_create_from_configline_ipv6_normal_case(void)
parse_portal_ipv6_normal_case(void)
{
const char *string = "[2001:ad6:1234::]:3260@1";
const char *host_str = "[2001:ad6:1234::]";
@ -204,7 +204,7 @@ portal_create_from_configline_ipv6_normal_case(void)
spdk_cpuset_set_cpu(cpumask_val, 0, true);
rc = spdk_iscsi_portal_create_from_configline(string, &p, 0);
rc = spdk_iscsi_parse_portal(string, &p, 0);
CU_ASSERT(rc == 0);
CU_ASSERT(strcmp(p->host, host_str) == 0);
CU_ASSERT(strcmp(p->port, port_str) == 0);
@ -217,7 +217,7 @@ portal_create_from_configline_ipv6_normal_case(void)
}
static void
portal_create_from_configline_ipv4_skip_cpumask_case(void)
parse_portal_ipv4_skip_cpumask_case(void)
{
const char *string = "192.168.2.0:3260";
const char *host_str = "192.168.2.0";
@ -228,7 +228,7 @@ portal_create_from_configline_ipv4_skip_cpumask_case(void)
cpumask_val = spdk_app_get_core_mask();
rc = spdk_iscsi_portal_create_from_configline(string, &p, 0);
rc = spdk_iscsi_parse_portal(string, &p, 0);
CU_ASSERT(rc == 0);
CU_ASSERT(strcmp(p->host, host_str) == 0);
CU_ASSERT(strcmp(p->port, port_str) == 0);
@ -239,7 +239,7 @@ portal_create_from_configline_ipv4_skip_cpumask_case(void)
}
static void
portal_create_from_configline_ipv6_skip_cpumask_case(void)
parse_portal_ipv6_skip_cpumask_case(void)
{
const char *string = "[2001:ad6:1234::]:3260";
const char *host_str = "[2001:ad6:1234::]";
@ -250,7 +250,7 @@ portal_create_from_configline_ipv6_skip_cpumask_case(void)
cpumask_val = spdk_app_get_core_mask();
rc = spdk_iscsi_portal_create_from_configline(string, &p, 0);
rc = spdk_iscsi_parse_portal(string, &p, 0);
CU_ASSERT(rc == 0);
CU_ASSERT(strcmp(p->host, host_str) == 0);
CU_ASSERT(strcmp(p->port, port_str) == 0);
@ -261,7 +261,7 @@ portal_create_from_configline_ipv6_skip_cpumask_case(void)
}
static void
portal_create_from_configline_ipv4_skip_port_and_cpumask_case(void)
parse_portal_ipv4_skip_port_and_cpumask_case(void)
{
const char *string = "192.168.2.0";
const char *host_str = "192.168.2.0";
@ -272,7 +272,7 @@ portal_create_from_configline_ipv4_skip_port_and_cpumask_case(void)
cpumask_val = spdk_app_get_core_mask();
rc = spdk_iscsi_portal_create_from_configline(string, &p, 0);
rc = spdk_iscsi_parse_portal(string, &p, 0);
CU_ASSERT(rc == 0);
CU_ASSERT(strcmp(p->host, host_str) == 0);
CU_ASSERT(strcmp(p->port, port_str) == 0);
@ -283,7 +283,7 @@ portal_create_from_configline_ipv4_skip_port_and_cpumask_case(void)
}
static void
portal_create_from_configline_ipv6_skip_port_and_cpumask_case(void)
parse_portal_ipv6_skip_port_and_cpumask_case(void)
{
const char *string = "[2001:ad6:1234::]";
const char *host_str = "[2001:ad6:1234::]";
@ -294,7 +294,7 @@ portal_create_from_configline_ipv6_skip_port_and_cpumask_case(void)
cpumask_val = spdk_app_get_core_mask();
rc = spdk_iscsi_portal_create_from_configline(string, &p, 0);
rc = spdk_iscsi_parse_portal(string, &p, 0);
CU_ASSERT(rc == 0);
CU_ASSERT(strcmp(p->host, host_str) == 0);
CU_ASSERT(strcmp(p->port, port_str) == 0);
@ -439,18 +439,18 @@ main(int argc, char **argv)
portal_create_cpumask_no_bit_on_case) == NULL
|| CU_add_test(suite, "portal create twice case",
portal_create_twice_case) == NULL
|| CU_add_test(suite, "portal create from configline ipv4 normal case",
portal_create_from_configline_ipv4_normal_case) == NULL
|| CU_add_test(suite, "portal create from configline ipv6 normal case",
portal_create_from_configline_ipv6_normal_case) == NULL
|| CU_add_test(suite, "portal create from configline ipv4 skip cpumask case",
portal_create_from_configline_ipv4_skip_cpumask_case) == NULL
|| CU_add_test(suite, "portal create from configline ipv6 skip cpumask case",
portal_create_from_configline_ipv6_skip_cpumask_case) == NULL
|| CU_add_test(suite, "portal create from configline ipv4 skip port and cpumask case",
portal_create_from_configline_ipv4_skip_port_and_cpumask_case) == NULL
|| CU_add_test(suite, "portal create from configline ipv6 skip port and cpumask case",
portal_create_from_configline_ipv6_skip_port_and_cpumask_case) == NULL
|| CU_add_test(suite, "parse portal ipv4 normal case",
parse_portal_ipv4_normal_case) == NULL
|| CU_add_test(suite, "parse portal ipv6 normal case",
parse_portal_ipv6_normal_case) == NULL
|| CU_add_test(suite, "parse portal ipv4 skip cpumask case",
parse_portal_ipv4_skip_cpumask_case) == NULL
|| CU_add_test(suite, "parse portal ipv6 skip cpumask case",
parse_portal_ipv6_skip_cpumask_case) == NULL
|| CU_add_test(suite, "parse portal ipv4 skip port and cpumask case",
parse_portal_ipv4_skip_port_and_cpumask_case) == NULL
|| CU_add_test(suite, "parse portal ipv6 skip port and cpumask case",
parse_portal_ipv6_skip_port_and_cpumask_case) == NULL
|| CU_add_test(suite, "portal group register/unregister case",
portal_grp_register_unregister_case) == NULL
|| CU_add_test(suite, "portal group register twice case",

View File

@ -179,7 +179,7 @@ config_file_fail_cases(void)
if (sp == NULL) {
break;
}
rc = spdk_cf_add_iscsi_tgt_node(sp);
rc = spdk_iscsi_parse_tgt_node(sp);
CU_ASSERT(rc < 0);
section_index++;
}