X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=backend.c;h=6bf5d679a5898d998f8d5efeb0ce3b9b46b99d81;hp=d8f4f4cfb28e807ba98e2dc8735cc0609acd980e;hb=67f28a8cf74bf64c1c35fde49a425d62bb143fa8;hpb=34febb23fa9c7b9b0d54c324effff1a808a8fe6e diff --git a/backend.c b/backend.c index d8f4f4cf..6bf5d679 100644 --- a/backend.c +++ b/backend.c @@ -571,6 +571,28 @@ static inline bool io_in_polling(struct thread_data *td) return !td->o.iodepth_batch_complete_min && !td->o.iodepth_batch_complete_max; } +/* + * Unlinks files from thread data fio_file structure + */ +static int unlink_all_files(struct thread_data *td) +{ + struct fio_file *f; + unsigned int i; + int ret = 0; + + for_each_file(td, f, i) { + if (f->filetype != FIO_TYPE_FILE) + continue; + ret = td_io_unlink_file(td, f); + if (ret) + break; + } + + if (ret) + td_verror(td, ret, "unlink_all_files"); + + return ret; +} /* * The main verify engine. Runs over the writes we previously submitted, @@ -603,6 +625,15 @@ static void do_verify(struct thread_data *td, uint64_t verify_bytes) if (td->error) return; + /* + * verify_state needs to be reset before verification + * proceeds so that expected random seeds match actual + * random seeds in headers. The main loop will reset + * all random number generators if randrepeat is set. + */ + if (!td->o.rand_repeatable) + td_fill_verify_state_seed(td); + td_set_runstate(td, TD_VERIFYING); io_u = NULL; @@ -643,7 +674,7 @@ static void do_verify(struct thread_data *td, uint64_t verify_bytes) break; while ((io_u = get_io_u(td)) != NULL) { - if (IS_ERR(io_u)) { + if (IS_ERR_OR_NULL(io_u)) { io_u = NULL; ret = FIO_Q_BUSY; goto reap; @@ -1252,6 +1283,7 @@ static int init_io_u(struct thread_data *td) static int switch_ioscheduler(struct thread_data *td) { +#ifdef FIO_HAVE_IOSCHED_SWITCH char tmp[256], tmp2[128]; FILE *f; int ret; @@ -1299,6 +1331,14 @@ static int switch_ioscheduler(struct thread_data *td) */ tmp[strlen(tmp) - 1] = '\0'; + /* + * Write to "none" entry doesn't fail, so check the result here. + */ + if (!strcmp(tmp, "none")) { + log_err("fio: io scheduler is not tunable\n"); + fclose(f); + return 0; + } sprintf(tmp2, "[%s]", td->o.ioscheduler); if (!strstr(tmp, tmp2)) { @@ -1310,6 +1350,9 @@ static int switch_ioscheduler(struct thread_data *td) fclose(f); return 0; +#else + return 0; +#endif } static bool keep_running(struct thread_data *td) @@ -1386,7 +1429,7 @@ static uint64_t do_dry_run(struct thread_data *td) break; io_u = get_io_u(td); - if (!io_u) + if (IS_ERR_OR_NULL(io_u)) break; io_u_set(io_u, IO_U_F_FLIGHT); @@ -1654,9 +1697,13 @@ static void *thread_main(void *data) fio_gettime(&td->start, NULL); memcpy(&td->tv_cache, &td->start, sizeof(td->start)); - if (clear_state) + if (clear_state) { clear_io_state(td, 0); + if (o->unlink_each_loop && unlink_all_files(td)) + break; + } + prune_io_piece_log(td); if (td->o.verify_only && (td_write(td) || td_rw(td))) @@ -2356,7 +2403,7 @@ int fio_backend(struct sk_out *sk_out) for (i = 0; i < DDIR_RWDIR_CNT; i++) { struct io_log *log = agg_io_log[i]; - flush_log(log, 0); + flush_log(log, false); free_log(log); } }