libfio: add runstate names
authorJens Axboe <axboe@fb.com>
Mon, 27 Jul 2015 18:08:33 +0000 (12:08 -0600)
committerJens Axboe <axboe@fb.com>
Mon, 27 Jul 2015 18:08:33 +0000 (12:08 -0600)
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 <axboe@fb.com>
fio.h
libfio.c

diff --git a/fio.h b/fio.h
index 744d99422ba70d4e4c641eb05023742139e1ab93..81d58e8b3509b5f3610f2cbc62ef8bc8085e051a 100644 (file)
--- 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);
index 30a3acb5614d124910c9c74f326b0bd9910a9877..b0141a7524e2c3d5c18d7f8e14c1503710c73363 100644 (file)
--- 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;
 }