Add max_latency option

If set, fio will exit if it sees a total IO latency that exceeds
this value.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
diff --git a/io_u.c b/io_u.c
index e047677..b049b61 100644
--- a/io_u.c
+++ b/io_u.c
@@ -1325,6 +1325,13 @@
 
 		tusec = utime_since(&io_u->start_time, &icd->time);
 		add_lat_sample(td, idx, tusec, bytes);
+
+		if (td->o.max_latency && tusec > td->o.max_latency) {
+			if (!td->error)
+				log_err("fio: latency of %lu usec exceeds specified max (%u usec)\n", tusec, td->o.max_latency);
+			td_verror(td, ETIME, "max latency exceeded");
+			icd->error = ETIME;
+		}
 	}
 
 	if (!td->o.disable_clat) {