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: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Change-Id: Ie8449e8bcd979b237c68ef94f50fb7a3cb6c19db Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4750 Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Paul Luse <paul.e.luse@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
f62834a6bb
commit
344bb69312
@ -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.
|
||||
|
@ -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);
|
||||
|
@ -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.
|
||||
*
|
||||
|
102
lib/event/app.c
102
lib/event/app.c
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -40,7 +40,6 @@
|
||||
struct spdk_app_opts g_opts = {};
|
||||
static const char g_app_repeat_get_opts_string[] = "t:";
|
||||
static int g_repeat_times = 2;
|
||||
static bool g_exit;
|
||||
|
||||
static void
|
||||
app_repeat_usage(void)
|
||||
@ -74,14 +73,7 @@ app_repeat_started(void *arg1)
|
||||
|
||||
static void _app_repeat_shutdown_cb(void)
|
||||
{
|
||||
printf("Shutdown signal received, exit.\n");
|
||||
g_exit = true;
|
||||
spdk_app_stop(0);
|
||||
}
|
||||
|
||||
static void _app_repeat_usr1_handler(int signal)
|
||||
{
|
||||
printf("USR1 signal received, restart spdk application framework.\n");
|
||||
printf("Shutdown signal received, stop current app iteration\n");
|
||||
spdk_app_stop(0);
|
||||
}
|
||||
|
||||
@ -94,7 +86,6 @@ main(int argc, char **argv)
|
||||
spdk_app_opts_init(&g_opts);
|
||||
g_opts.name = "app_repeat";
|
||||
g_opts.shutdown_cb = _app_repeat_shutdown_cb;
|
||||
g_opts.usr1_handler = _app_repeat_usr1_handler;
|
||||
if ((rc = spdk_app_parse_args(argc, argv, &g_opts, g_app_repeat_get_opts_string,
|
||||
NULL, app_repeat_parse_arg, app_repeat_usage)) !=
|
||||
SPDK_APP_PARSE_ARGS_SUCCESS) {
|
||||
|
@ -25,7 +25,10 @@ function app_repeat_test() {
|
||||
$rootdir/scripts/rpc.py -s $rpc_server bdev_malloc_create 64 4096
|
||||
|
||||
nbd_rpc_data_verify $rpc_server "${bdev_list[*]}" "${nbd_list[*]}"
|
||||
./scripts/rpc.py -s $rpc_server spdk_kill_instance SIGUSR1
|
||||
# This SIGTERM is sent to the app_repeat test app - it doesn't actually
|
||||
# terminate the app, it just causes it go through another
|
||||
# spdk_app_stop/spdk_app_start cycle
|
||||
./scripts/rpc.py -s $rpc_server spdk_kill_instance SIGTERM
|
||||
done
|
||||
|
||||
waitforlisten $repeat_pid $rpc_server
|
||||
|
Loading…
Reference in New Issue
Block a user