Lines Matching refs:td
80 static struct ioengine_ops *dlopen_ioengine(struct thread_data *td, in dlopen_ioengine() argument
91 td_vmsg(td, -1, dlerror(), "dlopen"); in dlopen_ioengine()
117 td_vmsg(td, -1, dlerror(), "dlsym"); in dlopen_ioengine()
122 td->io_ops_dlhandle = dlhandle; in dlopen_ioengine()
126 struct ioengine_ops *load_ioengine(struct thread_data *td, const char *name) in load_ioengine() argument
144 ops = dlopen_ioengine(td, name); in load_ioengine()
163 void free_ioengine(struct thread_data *td) in free_ioengine() argument
165 dprint(FD_IO, "free ioengine %s\n", td->io_ops->name); in free_ioengine()
167 if (td->eo && td->io_ops->options) { in free_ioengine()
168 options_free(td->io_ops->options, td->eo); in free_ioengine()
169 free(td->eo); in free_ioengine()
170 td->eo = NULL; in free_ioengine()
173 if (td->io_ops_dlhandle) in free_ioengine()
174 dlclose(td->io_ops_dlhandle); in free_ioengine()
176 td->io_ops = NULL; in free_ioengine()
179 void close_ioengine(struct thread_data *td) in close_ioengine() argument
181 dprint(FD_IO, "close ioengine %s\n", td->io_ops->name); in close_ioengine()
183 if (td->io_ops->cleanup) { in close_ioengine()
184 td->io_ops->cleanup(td); in close_ioengine()
185 td->io_ops_data = NULL; in close_ioengine()
188 free_ioengine(td); in close_ioengine()
191 int td_io_prep(struct thread_data *td, struct io_u *io_u) in td_io_prep() argument
194 fio_ro_check(td, io_u); in td_io_prep()
196 lock_file(td, io_u->file, io_u->ddir); in td_io_prep()
198 if (td->io_ops->prep) { in td_io_prep()
199 int ret = td->io_ops->prep(td, io_u); in td_io_prep()
203 unlock_file(td, io_u->file); in td_io_prep()
210 int td_io_getevents(struct thread_data *td, unsigned int min, unsigned int max, in td_io_getevents() argument
222 if (td->done) in td_io_getevents()
225 if (min > 0 && td->io_ops->commit) { in td_io_getevents()
226 r = td->io_ops->commit(td); in td_io_getevents()
230 if (max > td->cur_depth) in td_io_getevents()
231 max = td->cur_depth; in td_io_getevents()
236 if (max && td->io_ops->getevents) in td_io_getevents()
237 r = td->io_ops->getevents(td, min, max, t); in td_io_getevents()
244 td->io_u_in_flight -= r; in td_io_getevents()
245 io_u_mark_complete(td, r); in td_io_getevents()
247 td_verror(td, r, "get_events"); in td_io_getevents()
253 int td_io_queue(struct thread_data *td, struct io_u *io_u) in td_io_queue() argument
260 fio_ro_check(td, io_u); in td_io_queue()
263 io_u_set(td, io_u, IO_U_F_FLIGHT); in td_io_queue()
270 log_io_u(td, io_u); in td_io_queue()
275 if (td_ioengine_flagged(td, FIO_SYNCIO)) { in td_io_queue()
276 if (fio_fill_issue_time(td)) in td_io_queue()
282 if (td->o.read_iolog_file) in td_io_queue()
283 memcpy(&td->last_issue, &io_u->issue_time, in td_io_queue()
288 td->io_issues[ddir]++; in td_io_queue()
289 td->io_issue_bytes[ddir] += buflen; in td_io_queue()
290 td->rate_io_issue_bytes[ddir] += buflen; in td_io_queue()
293 ret = td->io_ops->queue(td, io_u); in td_io_queue()
295 unlock_file(td, io_u->file); in td_io_queue()
298 td->io_issues[ddir]--; in td_io_queue()
299 td->io_issue_bytes[ddir] -= buflen; in td_io_queue()
300 td->rate_io_issue_bytes[ddir] -= buflen; in td_io_queue()
301 io_u_clear(td, io_u, IO_U_F_FLIGHT); in td_io_queue()
308 if (io_u->error && !td->error) in td_io_queue()
309 td_verror(td, io_u->error, "td_io_queue"); in td_io_queue()
317 if (io_u->error == EINVAL && td->io_issues[io_u->ddir & 1] == 1 && in td_io_queue()
318 td->o.odirect) { in td_io_queue()
325 if (!td->io_ops->commit || io_u->ddir == DDIR_TRIM) { in td_io_queue()
326 io_u_mark_submit(td, 1); in td_io_queue()
327 io_u_mark_complete(td, 1); in td_io_queue()
332 io_u_mark_depth(td, 1); in td_io_queue()
333 td->ts.total_io_u[io_u->ddir]++; in td_io_queue()
338 td->io_u_queued++; in td_io_queue()
341 td->ts.total_io_u[io_u->ddir]++; in td_io_queue()
343 if (td->io_u_queued >= td->o.iodepth_batch) { in td_io_queue()
344 r = td_io_commit(td); in td_io_queue()
350 if (!td_ioengine_flagged(td, FIO_SYNCIO)) { in td_io_queue()
351 if (fio_fill_issue_time(td)) in td_io_queue()
357 if (td->o.read_iolog_file) in td_io_queue()
358 memcpy(&td->last_issue, &io_u->issue_time, in td_io_queue()
365 int td_io_init(struct thread_data *td) in td_io_init() argument
369 if (td->io_ops->init) { in td_io_init()
370 ret = td->io_ops->init(td); in td_io_init()
373 td->io_ops->name, in td_io_init()
374 td->o.iodepth > 1 ? in td_io_init()
377 td->io_ops_init = 1; in td_io_init()
378 if (!td->error) in td_io_init()
379 td->error = ret; in td_io_init()
385 int td_io_commit(struct thread_data *td) in td_io_commit() argument
389 dprint(FD_IO, "calling ->commit(), depth %d\n", td->cur_depth); in td_io_commit()
391 if (!td->cur_depth || !td->io_u_queued) in td_io_commit()
394 io_u_mark_depth(td, td->io_u_queued); in td_io_commit()
396 if (td->io_ops->commit) { in td_io_commit()
397 ret = td->io_ops->commit(td); in td_io_commit()
399 td_verror(td, -ret, "io commit"); in td_io_commit()
405 td->io_u_in_flight += td->io_u_queued; in td_io_commit()
406 td->io_u_queued = 0; in td_io_commit()
411 int td_io_open_file(struct thread_data *td, struct fio_file *f) in td_io_open_file() argument
416 if (td->io_ops->open_file(td, f)) { in td_io_open_file()
417 if (td->error == EINVAL && td->o.odirect) in td_io_open_file()
419 if (td->error == EMFILE) { in td_io_open_file()
421 " at %u of %u)\n", td->nr_open_files, in td_io_open_file()
422 td->o.nr_files); in td_io_open_file()
430 fio_file_reset(td, f); in td_io_open_file()
435 td->nr_open_files++; in td_io_open_file()
439 if (td_random(td)) { in td_io_open_file()
445 if (td_ioengine_flagged(td, FIO_DISKLESSIO)) in td_io_open_file()
448 if (td->o.invalidate_cache && file_invalidate_cache(td, f)) in td_io_open_file()
451 if (td->o.fadvise_hint != F_ADV_NONE && in td_io_open_file()
455 if (td->o.fadvise_hint == F_ADV_TYPE) { in td_io_open_file()
456 if (td_random(td)) in td_io_open_file()
460 } else if (td->o.fadvise_hint == F_ADV_RANDOM) in td_io_open_file()
462 else if (td->o.fadvise_hint == F_ADV_SEQUENTIAL) in td_io_open_file()
466 td->o.fadvise_hint); in td_io_open_file()
471 td_verror(td, errno, "fadvise"); in td_io_open_file()
476 if (td->o.fadvise_stream && in td_io_open_file()
478 off_t stream = td->o.fadvise_stream; in td_io_open_file()
481 td_verror(td, errno, "fadvise streamid"); in td_io_open_file()
492 if (td->o.odirect) { in td_io_open_file()
496 td_verror(td, ret, "fio_set_odirect"); in td_io_open_file()
509 log_file(td, f, FIO_LOG_OPEN_FILE); in td_io_open_file()
513 if (td->io_ops->close_file) in td_io_open_file()
514 td->io_ops->close_file(td, f); in td_io_open_file()
518 int td_io_close_file(struct thread_data *td, struct fio_file *f) in td_io_close_file() argument
521 log_file(td, f, FIO_LOG_CLOSE_FILE); in td_io_close_file()
530 if (td->o.file_lock_mode != FILE_LOCK_NONE) in td_io_close_file()
531 unlock_file_all(td, f); in td_io_close_file()
533 return put_file(td, f); in td_io_close_file()
536 int td_io_unlink_file(struct thread_data *td, struct fio_file *f) in td_io_unlink_file() argument
538 if (td->io_ops->unlink_file) in td_io_unlink_file()
539 return td->io_ops->unlink_file(td, f); in td_io_unlink_file()
551 int td_io_get_file_size(struct thread_data *td, struct fio_file *f) in td_io_get_file_size() argument
553 if (!td->io_ops->get_file_size) in td_io_get_file_size()
556 return td->io_ops->get_file_size(td, f); in td_io_get_file_size()
562 struct thread_data td; in fio_show_ioengine_help() local
581 memset(&td, 0, sizeof(td)); in fio_show_ioengine_help()
583 io_ops = load_ioengine(&td, engine); in fio_show_ioengine_help()
594 free_ioengine(&td); in fio_show_ioengine_help()