X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=backend.c;h=bab202662ca5356ec3b6993ee2af76922565d95d;hb=26251d8d;hp=501c59a322a5551e174a108c7989c70c0db9f09c;hpb=f940128526dbe468a1951cce10c2fe5dbd23875f;p=fio.git diff --git a/backend.c b/backend.c index 501c59a3..bab20266 100644 --- a/backend.c +++ b/backend.c @@ -52,6 +52,7 @@ #include "server.h" #include "lib/getrusage.h" #include "idletime.h" +#include "err.h" static pthread_t disk_util_thread; static struct fio_mutex *disk_thread_mutex; @@ -345,7 +346,7 @@ static inline int runtime_exceeded(struct thread_data *td, struct timeval *t) return 0; if (!td->o.timeout) return 0; - if (mtime_since(&td->epoch, t) >= td->o.timeout * 1000) + if (utime_since(&td->epoch, t) >= td->o.timeout) return 1; return 0; @@ -478,6 +479,12 @@ 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)) { + io_u = NULL; + ret = FIO_Q_BUSY; + goto reap; + } + /* * We are only interested in the places where * we wrote or trimmed IOs. Turn those into @@ -574,6 +581,7 @@ sync_done: * completed io_u's first. Note that we can get BUSY even * without IO queued, if the system is resource starved. */ +reap: full = queue_full(td) || (ret == FIO_Q_BUSY && td->cur_depth); if (full || !td->o.iodepth_batch_complete) { min_events = min(td->o.iodepth_batch_complete, @@ -617,6 +625,7 @@ sync_done: static int io_bytes_exceeded(struct thread_data *td) { + unsigned long long number_ios = 0; unsigned long long bytes; if (td_rw(td)) @@ -628,7 +637,13 @@ static int io_bytes_exceeded(struct thread_data *td) else bytes = td->this_io_bytes[DDIR_TRIM]; - return bytes >= td->o.size; + if (td->o.number_ios) { + number_ios = ddir_rw_sum(td->this_io_blocks); + number_ios += td->io_u_queued + td->io_u_in_flight; + } + + return bytes >= td->o.size || + (number_ios && number_ios >= td->o.number_ios); } /* @@ -692,7 +707,14 @@ static uint64_t do_io(struct thread_data *td) break; io_u = get_io_u(td); - if (!io_u) { + if (IS_ERR_OR_NULL(io_u)) { + int err = PTR_ERR(io_u); + + io_u = NULL; + if (err == -EBUSY) { + ret = FIO_Q_BUSY; + goto reap; + } if (td->o.latency_target) goto reap; break; @@ -1113,6 +1135,14 @@ static int keep_running(struct thread_data *td) return 1; } + if (td->o.number_ios) { + unsigned long long number_ios = ddir_rw_sum(td->this_io_blocks); + + number_ios += td->io_u_queued + td->io_u_in_flight; + if (number_ios >= td->o.number_ios) + return 0; + } + if (td->o.size != -1ULL && ddir_rw_sum(td->io_bytes) < td->o.size) { uint64_t diff; @@ -1124,6 +1154,9 @@ static int keep_running(struct thread_data *td) if (diff < td_max_bs(td)) return 0; + if (fio_files_done(td)) + return 0; + return 1; } @@ -1178,6 +1211,12 @@ static uint64_t do_dry_run(struct thread_data *td) td->ts.total_io_u[io_u->ddir]++; } + if (td_write(td) && io_u->ddir == DDIR_WRITE && + td->o.do_verify && + td->o.verify != VERIFY_NONE && + !td->o.experimental_verify) + log_io_piece(td, io_u); + ret = io_u_sync_complete(td, io_u, bytes_done); (void) ret; } @@ -1235,13 +1274,6 @@ static void *thread_main(void *data) fio_mutex_down(td->mutex); dprint(FD_MUTEX, "done waiting on td->mutex\n"); - /* - * the ->mutex mutex is now no longer used, close it to avoid - * eating a file descriptor - */ - fio_mutex_remove(td->mutex); - td->mutex = NULL; - /* * A new gid requires privilege, so we need to do this before setting * the uid. @@ -1267,6 +1299,15 @@ static void *thread_main(void *data) * allocations. */ if (o->cpumask_set) { + if (o->cpus_allowed_policy == FIO_CPUS_SPLIT) { + ret = fio_cpus_split(&o->cpumask, td->thread_number - 1); + if (!ret) { + log_err("fio: no CPUs set\n"); + log_err("fio: Try increasing number of available CPUs\n"); + td_verror(td, EINVAL, "cpus_split"); + goto err; + } + } ret = fio_setaffinity(td->pid, o->cpumask); if (ret == -1) { td_verror(td, errno, "cpu_set_affinity"); @@ -1450,6 +1491,7 @@ static void *thread_main(void *data) fio_unpin_memory(td); fio_mutex_down(writeout_mutex); + finalize_logs(td); if (td->bw_log) { if (o->bw_log_file) { finish_log_named(td, td->bw_log, @@ -1521,6 +1563,9 @@ err: fio_mutex_remove(td->rusage_sem); td->rusage_sem = NULL; + fio_mutex_remove(td->mutex); + td->mutex = NULL; + td_set_runstate(td, TD_EXITED); return (void *) (uintptr_t) td->error; } @@ -1668,8 +1713,8 @@ static void do_usleep(unsigned int usecs) static void run_threads(void) { struct thread_data *td; - unsigned long spent; unsigned int i, todo, nr_running, m_rate, t_rate, nr_started; + uint64_t spent; if (fio_gtod_offload && fio_start_gtod_thread()) return; @@ -1767,9 +1812,9 @@ static void run_threads(void) } if (td->o.start_delay) { - spent = mtime_since_genesis(); + spent = utime_since_genesis(); - if (td->o.start_delay * 1000 > spent) + if (td->o.start_delay > spent) continue; }