Home | History | Annotate | Download | only in fio

Lines Matching refs:td

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