From 1b61d481cc5d6409b9dc02c617f0502819bacb80 Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Thu, 14 Oct 2021 05:01:28 +0000 Subject: [PATCH] bdev_fio: add log_flags Allow user to add something like: log_flags=app_config,nvme,bdev to their fio config file to enable log flags. On DEBUG builds, setting at least one log flag will also set the print_level to DEBUG. Signed-off-by: Jim Harris Change-Id: I383512e47ad6ea86b8b2c71a212bdc88fadf2f65 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9870 Tested-by: SPDK CI Jenkins Community-CI: Broadcom CI Reviewed-by: Changpeng Liu Reviewed-by: Tomasz Zawadzki --- examples/bdev/fio_plugin/fio_plugin.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/examples/bdev/fio_plugin/fio_plugin.c b/examples/bdev/fio_plugin/fio_plugin.c index 562dbb12f..7e435310f 100644 --- a/examples/bdev/fio_plugin/fio_plugin.c +++ b/examples/bdev/fio_plugin/fio_plugin.c @@ -66,6 +66,7 @@ struct spdk_fio_options { void *pad; char *conf; char *json_conf; + char *log_flags; unsigned mem_mb; int mem_single_seg; int initial_zone_reset; @@ -286,6 +287,21 @@ spdk_init_thread_poll(void *arg) } spdk_unaffinitize_thread(); + if (eo->log_flags) { + char *tok = strtok(eo->log_flags, ","); + do { + rc = spdk_log_set_flag(tok); + if (rc < 0) { + SPDK_ERRLOG("unknown spdk log flag %s\n", tok); + rc = EINVAL; + goto err_exit; + } + } while ((tok = strtok(NULL, ",")) != NULL); +#ifdef DEBUG + spdk_log_set_print_level(SPDK_LOG_DEBUG); +#endif + } + spdk_thread_lib_init(NULL, 0); /* Create an SPDK thread temporarily */ @@ -1198,6 +1214,15 @@ static struct fio_option options[] = { .category = FIO_OPT_C_ENGINE, .group = FIO_OPT_G_INVALID, }, + { + .name = "log_flags", + .lname = "log flags", + .type = FIO_OPT_STR_STORE, + .off1 = offsetof(struct spdk_fio_options, log_flags), + .help = "SPDK log flags to enable", + .category = FIO_OPT_C_ENGINE, + .group = FIO_OPT_G_INVALID, + }, { .name = "initial_zone_reset", .lname = "Reset Zones on initialization",