+static void account_io_completion(struct thread_data *td, struct io_u *io_u,
+ struct io_completion_data *icd,
+ const enum fio_ddir idx, unsigned int bytes)
+{
+ unsigned long uninitialized_var(lusec);
+
+ if (!td->o.disable_clat || !td->o.disable_bw)
+ lusec = utime_since(&io_u->issue_time, &icd->time);
+
+ if (!td->o.disable_lat) {
+ unsigned long tusec;
+
+ tusec = utime_since(&io_u->start_time, &icd->time);
+ add_lat_sample(td, idx, tusec, bytes);
+ }
+
+ if (!td->o.disable_clat) {
+ add_clat_sample(td, idx, lusec, bytes);
+ io_u_mark_latency(td, lusec);
+ }
+
+ if (!td->o.disable_bw)
+ add_bw_sample(td, idx, bytes, &icd->time);
+
+ add_iops_sample(td, idx, &icd->time);
+}
+
+static long long usec_for_io(struct thread_data *td, enum fio_ddir ddir)
+{
+ unsigned long long secs, remainder, bps, bytes;
+ bytes = td->this_io_bytes[ddir];
+ bps = td->rate_bps[ddir];
+ secs = bytes / bps;
+ remainder = bytes % bps;
+ return remainder * 1000000 / bps + secs * 1000000;
+}
+