Lines Matching refs:td

88 static struct ioengine_ops *dlopen_ioengine(struct thread_data *td,
99 td_vmsg(td, -1, dlerror(), "dlopen");
125 td_vmsg(td, -1, dlerror(), "dlsym");
134 struct ioengine_ops *load_ioengine(struct thread_data *td, const char *name)
151 ops = dlopen_ioengine(td, name);
174 void free_ioengine(struct thread_data *td)
176 dprint(FD_IO, "free ioengine %s\n", td->io_ops->name);
178 if (td->eo && td->io_ops->options) {
179 options_free(td->io_ops->options, td->eo);
180 free(td->eo);
181 td->eo = NULL;
184 if (td->io_ops->dlhandle)
185 dlclose(td->io_ops->dlhandle);
187 free(td->io_ops);
188 td->io_ops = NULL;
191 void close_ioengine(struct thread_data *td)
193 dprint(FD_IO, "close ioengine %s\n", td->io_ops->name);
195 if (td->io_ops->cleanup) {
196 td->io_ops->cleanup(td);
197 td->io_ops->data = NULL;
200 free_ioengine(td);
203 int td_io_prep(struct thread_data *td, struct io_u *io_u)
206 fio_ro_check(td, io_u);
208 lock_file(td, io_u->file, io_u->ddir);
210 if (td->io_ops->prep) {
211 int ret = td->io_ops->prep(td, io_u);
215 unlock_file(td, io_u->file);
222 int td_io_getevents(struct thread_data *td, unsigned int min, unsigned int max,
231 * td->done is set to 1 after td_io_commit(). In this case,
234 if (td->done)
237 if (min > 0 && td->io_ops->commit) {
238 r = td->io_ops->commit(td);
242 if (max > td->cur_depth)
243 max = td->cur_depth;
248 if (max && td->io_ops->getevents)
249 r = td->io_ops->getevents(td, min, max, t);
256 td->io_u_in_flight -= r;
257 io_u_mark_complete(td, r);
259 td_verror(td, r, "get_events");
265 int td_io_queue(struct thread_data *td, struct io_u *io_u)
270 fio_ro_check(td, io_u);
280 log_io_u(td, io_u);
285 if (td->io_ops->flags & FIO_SYNCIO) {
286 if (fio_fill_issue_time(td))
292 if (td->o.read_iolog_file)
293 memcpy(&td->last_issue, &io_u->issue_time,
298 td->io_issues[acct_ddir(io_u)]++;
300 ret = td->io_ops->queue(td, io_u);
302 unlock_file(td, io_u->file);
306 * back to 'td', do so.
308 if (io_u->error && !td->error)
309 td_verror(td, io_u->error, "td_io_queue");
317 if (io_u->error == EINVAL && td->io_issues[io_u->ddir & 1] == 1 &&
318 td->o.odirect) {
324 if (!td->io_ops->commit || ddir_trim(io_u->ddir)) {
325 io_u_mark_submit(td, 1);
326 io_u_mark_complete(td, 1);
331 io_u_mark_depth(td, 1);
332 td->ts.total_io_u[io_u->ddir]++;
338 td->io_u_queued++;
339 td->ts.total_io_u[io_u->ddir]++;
342 if (td->io_u_queued >= td->o.iodepth_batch) {
343 r = td_io_commit(td);
349 if ((td->io_ops->flags & FIO_SYNCIO) == 0) {
350 if (fio_fill_issue_time(td))
356 if (td->o.read_iolog_file)
357 memcpy(&td->last_issue, &io_u->issue_time,
364 int td_io_init(struct thread_data *td)
368 if (td->io_ops->init) {
369 ret = td->io_ops->init(td);
370 if (ret && td->o.iodepth > 1) {
374 if (!td->error)
375 td->error = ret;
378 if (!ret && (td->io_ops->flags & FIO_NOIO))
379 td->flags |= TD_F_NOIO;
384 int td_io_commit(struct thread_data *td)
388 dprint(FD_IO, "calling ->commit(), depth %d\n", td->cur_depth);
390 if (!td->cur_depth || !td->io_u_queued)
393 io_u_mark_depth(td, td->io_u_queued);
395 if (td->io_ops->commit) {
396 ret = td->io_ops->commit(td);
398 td_verror(td, -ret, "io commit");
404 td->io_u_in_flight += td->io_u_queued;
405 td->io_u_queued = 0;
410 int td_io_open_file(struct thread_data *td, struct fio_file *f)
415 if (td->io_ops->open_file(td, f)) {
416 if (td->error == EINVAL && td->o.odirect)
418 if (td->error == EMFILE) {
420 " at %u of %u)\n", td->nr_open_files,
421 td->o.nr_files);
429 fio_file_reset(td, f);
434 td->nr_open_files++;
438 if (td_random(td)) {
444 if (td->io_ops->flags & FIO_DISKLESSIO)
447 if (td->o.invalidate_cache && file_invalidate_cache(td, f))
450 if (td->o.fadvise_hint &&
454 if (td_random(td))
460 td_verror(td, errno, "fadvise");
470 if (td->o.odirect) {
474 td_verror(td, ret, "fio_set_odirect");
482 log_file(td, f, FIO_LOG_OPEN_FILE);
486 if (td->io_ops->close_file)
487 td->io_ops->close_file(td, f);
491 int td_io_close_file(struct thread_data *td, struct fio_file *f)
494 log_file(td, f, FIO_LOG_CLOSE_FILE);
503 if (td->o.file_lock_mode != FILE_LOCK_NONE)
504 unlock_file_all(td, f);
506 return put_file(td, f);
509 int td_io_get_file_size(struct thread_data *td, struct fio_file *f)
511 if (!td->io_ops->get_file_size)
514 return td->io_ops->get_file_size(td, f);
517 static int do_sync_file_range(struct thread_data *td, struct fio_file *f)
527 return sync_file_range(f->fd, offset, nbytes, td->o.sync_file_range);
530 int do_io_u_sync(struct thread_data *td, struct io_u *io_u)
544 ret = do_sync_file_range(td, io_u->file);
556 int do_io_u_trim(struct thread_data *td, struct io_u *io_u)
577 struct thread_data td;
584 td.io_ops = flist_entry(entry, struct ioengine_ops,
586 log_info("\t%s\n", td.io_ops->name);
596 memset(&td, 0, sizeof(td));
598 td.io_ops = load_ioengine(&td, engine);
599 if (!td.io_ops) {
604 if (td.io_ops->options)
605 ret = show_cmd_help(td.io_ops->options, sep);
607 log_info("IO engine %s has no options\n", td.io_ops->name);
609 free_ioengine(&td);