Commit 800b18d0 authored by Vitaliy Mysak's avatar Vitaliy Mysak Committed by Tomasz Zawadzki
Browse files

lib/conf: allow multiple sections with same name



Add disable_sections_merge() procedure that will allow
to have multiple sections with a same name.
This behaviour is how FIO treats such sections
and so will be used in bdevperf config file.

Change-Id: If221daeb7753d91b5d2608d25ccbb16f2d43ccce
Signed-off-by: default avatarVitaliy Mysak <vitaliy.mysak@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/3433


Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
parent a7972f0a
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -201,6 +201,13 @@ bool spdk_conf_section_get_boolval(struct spdk_conf_section *sp, const char *key
 */
void spdk_conf_set_as_default(struct spdk_conf *cp);

/**
 * Disable sections merging during 'spdk_conf_read()'
 *
 * \param cp Configuration to be read
 */
void spdk_conf_disable_sections_merge(struct spdk_conf *cp);

#ifdef __cplusplus
}
#endif
+1 −1
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ SPDK_ROOT_DIR := $(abspath $(CURDIR)/../..)
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk

SO_VER := 2
SO_MINOR := 0
SO_MINOR := 1

C_SRCS = conf.c
LIBNAME = conf
+20 −2
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ struct spdk_conf {
	char *file;
	struct spdk_conf_section *current_section;
	struct spdk_conf_section *section;
	bool merge_sections;
};

#define CF_DELIM " \t"
@@ -72,7 +73,13 @@ static struct spdk_conf *default_config = NULL;
struct spdk_conf *
spdk_conf_allocate(void)
{
	return calloc(1, sizeof(struct spdk_conf));
	struct spdk_conf *ret = calloc(1, sizeof(struct spdk_conf));

	if (ret) {
		ret->merge_sections = true;
	}

	return ret;
}

static void
@@ -480,7 +487,12 @@ parse_line(struct spdk_conf *cp, char *lp)
			num = 0;
		}

		if (cp->merge_sections) {
			sp = spdk_conf_find_section(cp, key);
		} else {
			sp = NULL;
		}

		if (sp == NULL) {
			sp = allocate_cf_section();
			append_cf_section(cp, sp);
@@ -684,3 +696,9 @@ spdk_conf_set_as_default(struct spdk_conf *cp)
{
	default_config = cp;
}

void
spdk_conf_disable_sections_merge(struct spdk_conf *cp)
{
	cp->merge_sections = false;
}
+1 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
	spdk_conf_section_get_intval;
	spdk_conf_section_get_boolval;
	spdk_conf_set_as_default;
	spdk_conf_disable_sections_merge;

	local: *;
};