Improve mixed random append option
If we set ->ddir_nr to o.ddir_nr initally, we can remove the double
else in get_next_offset().
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
diff --git a/init.c b/init.c
index 911ee32..2704032 100644
--- a/init.c
+++ b/init.c
@@ -424,6 +424,7 @@
td->ts.clat_stat[0].min_val = td->ts.clat_stat[1].min_val = ULONG_MAX;
td->ts.slat_stat[0].min_val = td->ts.slat_stat[1].min_val = ULONG_MAX;
td->ts.bw_stat[0].min_val = td->ts.bw_stat[1].min_val = ULONG_MAX;
+ td->ddir_nr = td->o.ddir_nr;
if ((td->o.stonewall || td->o.numjobs > 1 || td->o.new_group)
&& prev_group_jobs) {
diff --git a/io_u.c b/io_u.c
index 45f3757..a171ee4 100644
--- a/io_u.c
+++ b/io_u.c
@@ -52,6 +52,10 @@
while (blocks < nr_blocks) {
unsigned int idx, bit;
+ /*
+ * If we have a mixed random workload, we may
+ * encounter blocks we already did IO to.
+ */
if (!td->o.ddir_nr && !random_map_free(td, f, block))
break;
@@ -110,13 +114,12 @@
int loops = 5;
if (td->o.ddir_nr) {
- if (!td->ddir_nr)
+ if (!--td->ddir_nr)
td->ddir_nr = td->o.ddir_nr;
- else if (--td->ddir_nr) {
+ else {
b = f->last_pos / td->o.min_bs[ddir];
goto out;
- } else
- td->ddir_nr = td->o.ddir_nr;
+ }
}
do {