nvme_fio: add log_flags

Allow user to add something like:

log_flags=nvme,nvme_vfio

to their fio config file to enable log flags.  On
DEBUG builds, setting at least one flag will also
set the print_level to DEBUG.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I7a409445d23c96845bc7afa9641966a964b7f44f
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9871
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
Jim Harris 2021-10-14 05:26:11 +00:00 committed by Tomasz Zawadzki
parent 1b61d481cc
commit 4963728855

View File

@ -62,6 +62,7 @@
#define NVME_IO_ALIGN 4096
static bool g_spdk_env_initialized;
static bool g_log_flag_error;
static int g_spdk_enable_sgl = 0;
static uint32_t g_spdk_sge_size = 4096;
static uint32_t g_spdk_bit_bucket_data_len = 0;
@ -95,6 +96,7 @@ struct spdk_fio_options {
int initial_zone_reset;
int zone_append;
int print_qid_mappings;
char *log_flags;
};
struct spdk_fio_request {
@ -561,6 +563,13 @@ static int spdk_fio_setup(struct thread_data *td)
return 1;
}
if (g_log_flag_error) {
/* The first thread found an error when parsing log flags, so
* just return error immediately for all of the other threads.
*/
return 1;
}
pthread_mutex_lock(&g_mutex);
fio_thread = calloc(1, sizeof(*fio_thread));
@ -596,6 +605,22 @@ static int spdk_fio_setup(struct thread_data *td)
pthread_mutex_unlock(&g_mutex);
return 1;
}
if (fio_options->log_flags) {
char *tok = strtok(fio_options->log_flags, ",");
do {
rc = spdk_log_set_flag(tok);
if (rc < 0) {
SPDK_ERRLOG("unknown log flag %s\n", tok);
g_log_flag_error = true;
return 1;
}
} while ((tok = strtok(NULL, ",")) != NULL);
#ifdef DEBUG
spdk_log_set_print_level(SPDK_LOG_DEBUG);
#endif
}
g_spdk_env_initialized = true;
spdk_unaffinitize_thread();
@ -1659,6 +1684,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 = "Enable log flags (comma-separated list)",
.category = FIO_OPT_C_ENGINE,
.group = FIO_OPT_G_INVALID,
},
{
.name = NULL,
},