+static void set_rwmix_bytes(struct thread_data *td)
+{
+ unsigned long long rbytes;
+ unsigned int diff;
+
+ /*
+ * we do time or byte based switch. this is needed because
+ * buffered writes may issue a lot quicker than they complete,
+ * whereas reads do not.
+ */
+ rbytes = td->io_bytes[td->rwmix_ddir] - td->rwmix_bytes;
+ diff = td->o.rwmixread;
+ if (td->rwmix_ddir == DDIR_WRITE)
+ diff = 100 - diff;
+
+ td->rwmix_bytes = td->io_bytes[td->rwmix_ddir] + (rbytes * (100 - diff)) / diff;
+}
+