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 <Elliott@hp.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
DDIR_DATASYNC,
DDIR_SYNC_FILE_RANGE,
DDIR_WAIT,
DDIR_DATASYNC,
DDIR_SYNC_FILE_RANGE,
DDIR_WAIT,
+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,
enum td_ddir {
TD_DDIR_READ = 1 << 0,
TD_DDIR_WRITE = 1 << 1,
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);
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;
if (td_non_fatal_error(td, eb, io_u->error) && !td->o.error_dump)
return;
log_err(": %s\n", strerror(io_u->error));
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)
io_u->offset, io_u->xfer_buflen);
if (!td->error)
void log_io_u(struct thread_data *td, struct io_u *io_u)
{
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,
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,
}
void log_file(struct thread_data *td, struct fio_file *f,