Commit 344bb693 authored by Tomasz Zawadzki's avatar Tomasz Zawadzki Committed by Jim Harris
Browse files

event: remove printing legacy config for apps



Remove spdk_app_get_running_config() that allowed printing
legacy configuration by the apps.
Along with usr1_handler callback that was used to call that
function.

It was only used in iscsi_tgt so it is removed there.

The app_repeat test was using SIGUSR1 to trigger a
spdk_app_stop/spdk_app_start cycle.  But we can use
SIGTERM for that instead.  While here, do a bit of
cleanup in the app_repeat test app.

Signed-off-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: Ie8449e8bcd979b237c68ef94f50fb7a3cb6c19db
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4750


Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarPaul Luse <paul.e.luse@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent f62834a6
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -27,6 +27,9 @@ function has been deprecated.

Removed `spdk_subsystem_config` callback for submodules as part of legacy config removal.

Removed `spdk_app_get_running_config` function that printed configuration in legacy format,
and removed `usr1_handler` from `struct spdk_app_opts` callback that was used to call it.

### dpdk

Updated DPDK submodule to DPDK 20.08.
+0 −16
Original line number Diff line number Diff line
@@ -41,21 +41,6 @@

static int g_daemon_mode = 0;

static void
spdk_sigusr1(int signo __attribute__((__unused__)))
{
	char *config_str = NULL;
	if (spdk_app_get_running_config(&config_str, "iscsi.conf") < 0) {
		fprintf(stderr, "Error getting config\n");
	} else {
		fprintf(stdout, "============================\n");
		fprintf(stdout, " iSCSI target running config\n");
		fprintf(stdout, "=============================\n");
		fprintf(stdout, "%s", config_str);
	}
	free(config_str);
}

static void
iscsi_usage(void)
{
@@ -106,7 +91,6 @@ main(int argc, char **argv)
	}

	opts.shutdown_cb = NULL;
	opts.usr1_handler = spdk_sigusr1;

	/* Blocks until the application is exiting */
	rc = spdk_app_start(&opts, spdk_startup, NULL);
+0 −11
Original line number Diff line number Diff line
@@ -99,7 +99,6 @@ struct spdk_app_opts {
	int shm_id;

	spdk_app_shutdown_cb	shutdown_cb;
	spdk_sighandler_t	usr1_handler;

	bool			enable_coredump;
	int			mem_channel;
@@ -207,16 +206,6 @@ void spdk_app_start_shutdown(void);
 */
void spdk_app_stop(int rc);

/**
 * Generate a configuration file that corresponds to the current running state.
 *
 * \param config_str Values obtained from the generated configuration file.
 * \param name Prefix for name of temporary configuration file to save the current config.
 *
 * \return 0 on success, -1 on failure.
 */
int spdk_app_get_running_config(char **config_str, char *name);

/**
 * Return the shared memory id for this application.
 *
+0 −102
Original line number Diff line number Diff line
@@ -137,98 +137,6 @@ static const struct option g_cmdline_options[] = {
	{"base-virtaddr",		required_argument,	NULL, BASE_VIRTADDR_OPT_IDX},
};

/* Global section */
#define GLOBAL_CONFIG_TMPL \
"# Configuration file\n" \
"#\n" \
"# Please write all parameters using ASCII.\n" \
"# The parameter must be quoted if it includes whitespace.\n" \
"#\n" \
"# Configuration syntax:\n" \
"# Spaces at head of line are deleted, other spaces are as separator\n" \
"# Lines starting with '#' are comments and not evaluated.\n" \
"# Lines ending with '\\' are concatenated with the next line.\n" \
"# Bracketed keys are section keys grouping the following value keys.\n" \
"# Number of section key is used as a tag number.\n" \
"#  Ex. [TargetNode1] = TargetNode section key with tag number 1\n" \
"[Global]\n" \
"  Comment \"Global section\"\n" \
"\n" \
"  # Users can restrict work items to only run on certain cores by\n" \
"  #  specifying a ReactorMask.  Default is to allow work items to run\n" \
"  #  on all cores.  Core 0 must be set in the mask if one is specified.\n" \
"  # Default: 0xFFFF (cores 0-15)\n" \
"  ReactorMask \"0x%s\"\n" \
"\n" \
"  # Tracepoint group mask for spdk trace buffers\n" \
"  # Default: 0x0 (all tracepoint groups disabled)\n" \
"  # Set to 0xFFFF to enable all tracepoint groups.\n" \
"  TpointGroupMask \"0x%" PRIX64 "\"\n" \
"\n" \

static void
app_config_dump_global_section(FILE *fp)
{
	const struct spdk_cpuset *coremask;
	struct spdk_cpuset tmp_mask;

	if (NULL == fp) {
		return;
	}

	coremask = spdk_app_get_core_mask();
	spdk_cpuset_copy(&tmp_mask, coremask);

	fprintf(fp, GLOBAL_CONFIG_TMPL, spdk_cpuset_fmt(&tmp_mask),
		spdk_trace_get_tpoint_group_mask());
}

int
spdk_app_get_running_config(char **config_str, char *name)
{
	FILE *fp = NULL;
	int fd = -1;
	long length = 0, ret = 0;
	char vbuf[BUFSIZ];
	char config_template[64];

	snprintf(config_template, sizeof(config_template), "/tmp/%s.XXXXXX", name);
	/* Create temporary file to hold config */
	fd = mkstemp(config_template);
	if (fd == -1) {
		SPDK_ERRLOG("mkstemp failed\n");
		return -1;
	}
	fp = fdopen(fd, "wb+");
	if (NULL == fp) {
		SPDK_ERRLOG("error opening tmpfile fd = %d\n", fd);
		return -1;
	}

	/* Buffered IO */
	setvbuf(fp, vbuf, _IOFBF, BUFSIZ);

	app_config_dump_global_section(fp);

	length = ftell(fp);

	*config_str = malloc(length + 1);
	if (!*config_str) {
		SPDK_ERRLOG("out-of-memory for config\n");
		fclose(fp);
		return -1;
	}
	fseek(fp, 0, SEEK_SET);
	ret = fread(*config_str, sizeof(char), length, fp);
	if (ret < length) {
		SPDK_ERRLOG("short read\n");
	}
	fclose(fp);
	(*config_str)[length] = '\0';

	return 0;
}

static void
app_start_shutdown(void *ctx)
{
@@ -332,16 +240,6 @@ app_setup_signal_handlers(struct spdk_app_opts *opts)
	}
	sigaddset(&sigmask, SIGTERM);

	if (opts->usr1_handler != NULL) {
		sigact.sa_handler = opts->usr1_handler;
		rc = sigaction(SIGUSR1, &sigact, NULL);
		if (rc < 0) {
			SPDK_ERRLOG("sigaction(SIGUSR1) failed\n");
			return rc;
		}
		sigaddset(&sigmask, SIGUSR1);
	}

	pthread_sigmask(SIG_UNBLOCK, &sigmask, NULL);

	return 0;
+0 −1
Original line number Diff line number Diff line
@@ -7,7 +7,6 @@
	spdk_app_fini;
	spdk_app_start_shutdown;
	spdk_app_stop;
	spdk_app_get_running_config;
	spdk_app_get_shm_id;
	spdk_app_parse_core_mask;
	spdk_app_get_core_mask;
Loading