From: Jens Axboe Date: Wed, 17 Sep 2014 02:07:59 +0000 (-0600) Subject: Fixup data-direction to name translation X-Git-Tag: fio-2.1.13~63 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=173375c210386387624779febf287ead301fda01 Fixup data-direction to name translation We had two of them, and they were both wrong since trim got introduced. Replace by a single implementation in io_ddir.h, right where it's defined. Reported-by: Elliott, Robert Signed-off-by: Jens Axboe --- diff --git a/io_ddir.h b/io_ddir.h index eb25c500..a23ea626 100644 --- a/io_ddir.h +++ b/io_ddir.h @@ -10,9 +10,21 @@ enum fio_ddir { DDIR_DATASYNC, DDIR_SYNC_FILE_RANGE, DDIR_WAIT, + DDIR_LAST, DDIR_INVAL = -1, }; +static inline const char *io_ddir_name(enum fio_ddir ddir) +{ + const char *name[] = { "read", "write", "trim", "sync", "datasync", + "sync_file_range", "write", }; + + if (ddir < DDIR_LAST) + return name[ddir]; + + return "invalid"; +} + enum td_ddir { TD_DDIR_READ = 1 << 0, TD_DDIR_WRITE = 1 << 1, diff --git a/io_u.c b/io_u.c index be2f242a..2adaf258 100644 --- a/io_u.c +++ b/io_u.c @@ -1528,8 +1528,6 @@ err_put: void io_u_log_error(struct thread_data *td, struct io_u *io_u) { enum error_type_bit eb = td_error_type(io_u->ddir, io_u->error); - const char *msg[] = { "read", "write", "sync", "datasync", - "sync_file_range", "wait", "trim" }; if (td_non_fatal_error(td, eb, io_u->error) && !td->o.error_dump) return; @@ -1541,7 +1539,7 @@ void io_u_log_error(struct thread_data *td, struct io_u *io_u) log_err(": %s\n", strerror(io_u->error)); - log_err(" %s offset=%llu, buflen=%lu\n", msg[io_u->ddir], + log_err(" %s offset=%llu, buflen=%lu\n", io_ddir_name(io_u->ddir), io_u->offset, io_u->xfer_buflen); if (!td->error) diff --git a/iolog.c b/iolog.c index f9e835d4..ef8b8414 100644 --- a/iolog.c +++ b/iolog.c @@ -30,17 +30,12 @@ void queue_io_piece(struct thread_data *td, struct io_piece *ipo) void log_io_u(struct thread_data *td, struct io_u *io_u) { - const char *act[] = { "read", "write", "sync", "datasync", - "sync_file_range", "wait", "trim" }; - - assert(io_u->ddir <= 6); - if (!td->o.write_iolog_file) return; fprintf(td->iolog_f, "%s %s %llu %lu\n", io_u->file->file_name, - act[io_u->ddir], io_u->offset, - io_u->buflen); + io_ddir_name(io_u->ddir), + io_u->offset, io_u->buflen); } void log_file(struct thread_data *td, struct fio_file *f,