From: Jens Axboe Date: Mon, 27 Jul 2015 18:08:33 +0000 (-0600) Subject: libfio: add runstate names X-Git-Tag: fio-2.2.10~34 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=6e760cf3906d0942715c3c0de43040c53c0b8a92 libfio: add runstate names Enables --debug=process to show the actual transitions, instead of numbers you have to look up in the source: process 12113 pid=12123: runstate CREATED -> INITIALIZED instead of process 12113 pid=12123: runstate 1 -> 2 Signed-off-by: Jens Axboe --- diff --git a/fio.h b/fio.h index 744d9942..81d58e8b 100644 --- a/fio.h +++ b/fio.h @@ -517,6 +517,7 @@ enum { TD_FINISHING, TD_EXITED, TD_REAPED, + TD_LAST, }; extern void td_set_runstate(struct thread_data *, int); diff --git a/libfio.c b/libfio.c index 30a3acb5..b0141a75 100644 --- a/libfio.c +++ b/libfio.c @@ -169,13 +169,38 @@ const char *fio_get_arch_string(int nr) return NULL; } +static const char *td_runstates[] = { + "NOT_CREATED", + "CREATED", + "INITIALIZED", + "RAMP", + "SETTING_UP", + "RUNNING", + "PRE_READING", + "VERIFYING", + "FSYNCING", + "FINISHING", + "EXITED", + "REAPED", +}; + +static const char *runstate_to_name(int runstate) +{ + compiletime_assert(TD_LAST == 12, "td runstate list"); + if (runstate >= 0 && runstate < TD_LAST) + return td_runstates[runstate]; + + return "invalid"; +} + void td_set_runstate(struct thread_data *td, int runstate) { if (td->runstate == runstate) return; - dprint(FD_PROCESS, "pid=%d: runstate %d -> %d\n", (int) td->pid, - td->runstate, runstate); + dprint(FD_PROCESS, "pid=%d: runstate %s -> %s\n", (int) td->pid, + runstate_to_name(td->runstate), + runstate_to_name(runstate)); td->runstate = runstate; }