Add support for options being a power-of-2
[fio.git] / io_u.c
diff --git a/io_u.c b/io_u.c
index 50644850463f3e212381ff552f88ce056b5d83b9..e67149d8cd2463e3bb8b06d18a70be9476b7b6d5 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -12,6 +12,7 @@
 #include "lib/rand.h"
 #include "lib/axmap.h"
 #include "err.h"
+#include "lib/pow2.h"
 
 struct io_completion_data {
        int nr;                         /* input */
@@ -1896,8 +1897,10 @@ static struct frand_state *get_buf_state(struct thread_data *td)
 
        if (!td->o.dedupe_percentage)
                return &td->buf_state;
-       else if (td->o.dedupe_percentage == 100)
-               return &td->buf_state_prev;
+       else if (td->o.dedupe_percentage == 100) {
+               frand_copy(&td->buf_state_prev, &td->buf_state);
+               return &td->buf_state;
+       }
 
        r = __rand(&td->dedupe_state);
        v = 1 + (int) (100.0 * (r / (FRAND_MAX + 1.0)));
@@ -1910,7 +1913,9 @@ static struct frand_state *get_buf_state(struct thread_data *td)
 
 static void save_buf_state(struct thread_data *td, struct frand_state *rs)
 {
-       if (rs == &td->buf_state)
+       if (td->o.dedupe_percentage == 100)
+               frand_copy(rs, &td->buf_state_prev);
+       else if (rs == &td->buf_state)
                frand_copy(&td->buf_state_prev, rs);
 }