Don't silently terminate td when no I/O performed due to error
[fio.git] / backend.c
index 86e689f838a00e752e8268ef6efda71fda156f00..fb027440711e2128f0acae11805f35fca9b81072 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -813,8 +813,9 @@ static long long usec_for_io(struct thread_data *td, enum fio_ddir ddir)
                val = (int64_t) (1000000 / iops) *
                                -logf(__rand_0_1(&td->poisson_state[ddir]));
                if (val) {
                val = (int64_t) (1000000 / iops) *
                                -logf(__rand_0_1(&td->poisson_state[ddir]));
                if (val) {
-                       dprint(FD_RATE, "poisson rate iops=%llu\n",
-                                       (unsigned long long) 1000000 / val);
+                       dprint(FD_RATE, "poisson rate iops=%llu, ddir=%d\n",
+                                       (unsigned long long) 1000000 / val,
+                                       ddir);
                }
                td->last_usec[ddir] += val;
                return td->last_usec[ddir];
                }
                td->last_usec[ddir] += val;
                return td->last_usec[ddir];
@@ -1456,6 +1457,7 @@ static void *thread_main(void *data)
        struct thread_data *td = fd->td;
        struct thread_options *o = &td->o;
        struct sk_out *sk_out = fd->sk_out;
        struct thread_data *td = fd->td;
        struct thread_options *o = &td->o;
        struct sk_out *sk_out = fd->sk_out;
+       uint64_t bytes_done[DDIR_RWDIR_CNT];
        int deadlock_loop_cnt;
        int clear_state;
        int ret;
        int deadlock_loop_cnt;
        int clear_state;
        int ret;
@@ -1677,7 +1679,9 @@ static void *thread_main(void *data)
                                        sizeof(td->bw_sample_time));
        }
 
                                        sizeof(td->bw_sample_time));
        }
 
+       memset(bytes_done, 0, sizeof(bytes_done));
        clear_state = 0;
        clear_state = 0;
+
        while (keep_running(td)) {
                uint64_t verify_bytes;
 
        while (keep_running(td)) {
                uint64_t verify_bytes;
 
@@ -1696,8 +1700,6 @@ static void *thread_main(void *data)
                if (td->o.verify_only && td_write(td))
                        verify_bytes = do_dry_run(td);
                else {
                if (td->o.verify_only && td_write(td))
                        verify_bytes = do_dry_run(td);
                else {
-                       uint64_t bytes_done[DDIR_RWDIR_CNT];
-
                        do_io(td, bytes_done);
 
                        if (!ddir_rw_sum(bytes_done)) {
                        do_io(td, bytes_done);
 
                        if (!ddir_rw_sum(bytes_done)) {
@@ -1776,6 +1778,18 @@ static void *thread_main(void *data)
                        break;
        }
 
                        break;
        }
 
+       /*
+        * If td ended up with no I/O when it should have had,
+        * then something went wrong unless FIO_NOIO or FIO_DISKLESSIO.
+        * (Are we not missing other flags that can be ignored ?)
+        */
+       if ((td->o.size || td->o.io_size) && !ddir_rw_sum(bytes_done) &&
+           !(td_ioengine_flagged(td, FIO_NOIO) ||
+             td_ioengine_flagged(td, FIO_DISKLESSIO)))
+               log_err("%s: No I/O performed by %s, "
+                        "perhaps try --debug=io option for details?\n",
+                        td->o.name, td->io_ops->name);
+
        td_set_runstate(td, TD_FINISHING);
 
        update_rusage_stat(td);
        td_set_runstate(td, TD_FINISHING);
 
        update_rusage_stat(td);