X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=ioengines.c;h=c0e30c9bbd90f21d574132becc7901504e3e337b;hp=28cdfd49b00cd24915f39c7b117e3d2e96e9e31f;hb=ee56ad500f6692381e131cc37299d23fa910a24a;hpb=2dbdab7e8fb0205c471f72effab1b2ae5f19bfac diff --git a/ioengines.c b/ioengines.c index 28cdfd49..c0e30c9b 100644 --- a/ioengines.c +++ b/ioengines.c @@ -56,12 +56,14 @@ static int check_engine_ops(struct ioengine_ops *ops) void unregister_ioengine(struct ioengine_ops *ops) { + dprint(FD_IO, "ioengine %s unregistered\n", ops->name); list_del(&ops->list); INIT_LIST_HEAD(&ops->list); } void register_ioengine(struct ioengine_ops *ops) { + dprint(FD_IO, "ioengine %s registered\n", ops->name); INIT_LIST_HEAD(&ops->list); list_add_tail(&ops->list, &engine_list); } @@ -86,6 +88,8 @@ static struct ioengine_ops *dlopen_ioengine(struct thread_data *td, struct ioengine_ops *ops; void *dlhandle; + dprint(FD_IO, "dload engine %s\n", engine_lib); + dlerror(); dlhandle = dlopen(engine_lib, RTLD_LAZY); if (!dlhandle) { @@ -113,6 +117,8 @@ struct ioengine_ops *load_ioengine(struct thread_data *td, const char *name) struct ioengine_ops *ops, *ret; char engine[16]; + dprint(FD_IO, "load ioengine %s\n", name); + strncpy(engine, name, sizeof(engine) - 1); /* @@ -145,6 +151,8 @@ struct ioengine_ops *load_ioengine(struct thread_data *td, const char *name) void close_ioengine(struct thread_data *td) { + dprint(FD_IO, "close ioengine %s\n", td->io_ops->name); + if (td->io_ops->cleanup) td->io_ops->cleanup(td); @@ -155,33 +163,54 @@ void close_ioengine(struct thread_data *td) td->io_ops = NULL; } +static void dprint_io_u(struct io_u *io_u, const char *p) +{ + struct fio_file *f = io_u->file; + + dprint(FD_IO, "%s: off=%llu/len=%lu/ddir=%d", p, io_u->offset, + io_u->buflen, io_u->ddir); + if (f) + dprint(FD_IO, "/%s", f->file_name); + dprint(FD_IO, "\n"); +} + int td_io_prep(struct thread_data *td, struct io_u *io_u) { + dprint_io_u(io_u, "prep"); + fio_ro_check(td, io_u); + if (td->io_ops->prep) return td->io_ops->prep(td, io_u); return 0; } -int td_io_getevents(struct thread_data *td, int min, int max, +int td_io_getevents(struct thread_data *td, unsigned int min, unsigned int max, struct timespec *t) { - if (min > 0 && td->io_ops->commit) { - int r = td->io_ops->commit(td); + int r = 0; + if (min > 0 && td->io_ops->commit) { + r = td->io_ops->commit(td); if (r < 0) - return r; + goto out; } - if (td->io_ops->getevents) - return td->io_ops->getevents(td, min, max, t); - return 0; + r = 0; + if (td->io_ops->getevents) + r = td->io_ops->getevents(td, min, max, t); +out: + dprint(FD_IO, "getevents: %d\n", r); + return r; } int td_io_queue(struct thread_data *td, struct io_u *io_u) { int ret; + dprint_io_u(io_u, "queue"); + fio_ro_check(td, io_u); + assert((io_u->flags & IO_U_F_FLIGHT) == 0); io_u->flags |= IO_U_F_FLIGHT; @@ -192,6 +221,7 @@ int td_io_queue(struct thread_data *td, struct io_u *io_u) if (td->io_ops->flags & FIO_SYNCIO) { fio_gettime(&io_u->issue_time, NULL); + memcpy(&td->last_issue, &io_u->issue_time, sizeof(struct timeval)); /* * for a sync engine, set the timeout upfront @@ -220,6 +250,7 @@ int td_io_queue(struct thread_data *td, struct io_u *io_u) if ((td->io_ops->flags & FIO_SYNCIO) == 0) { fio_gettime(&io_u->issue_time, NULL); + memcpy(&td->last_issue, &io_u->issue_time, sizeof(struct timeval)); /* * async engine, set the timeout here @@ -239,7 +270,7 @@ int td_io_init(struct thread_data *td) if (td->io_ops->init) { ret = td->io_ops->init(td); if (ret && td->o.iodepth > 1) - log_err("fio: io engine init failed. Perhaps try reducing io dpeth?\n"); + log_err("fio: io engine init failed. Perhaps try reducing io depth?\n"); } return ret; @@ -247,6 +278,8 @@ int td_io_init(struct thread_data *td) int td_io_commit(struct thread_data *td) { + dprint(FD_IO, "calling ->commit(), depth %d\n", td->cur_depth); + if (!td->cur_depth) return 0; @@ -277,7 +310,7 @@ int td_io_open_file(struct thread_data *td, struct fio_file *f) f->last_free_lookup = 0; f->last_completed_pos = 0; - f->last_pos = 0; + f->last_pos = f->file_offset; f->flags |= FIO_FILE_OPEN; f->flags &= ~FIO_FILE_CLOSING; @@ -307,6 +340,7 @@ int td_io_open_file(struct thread_data *td, struct fio_file *f) memset(f->file_map, 0, f->num_maps * sizeof(long)); done: + log_file(td, f, FIO_LOG_OPEN_FILE); td->nr_open_files++; get_file(f); return 0; @@ -318,6 +352,9 @@ err: void td_io_close_file(struct thread_data *td, struct fio_file *f) { + if (!(f->flags & FIO_FILE_CLOSING)) + log_file(td, f, FIO_LOG_CLOSE_FILE); + /* * mark as closing, do real close when last io on it has completed */