+/*
+ * See if we should reuse the last seed, if dedupe is enabled
+ */
+static struct frand_state *get_buf_state(struct thread_data *td)
+{
+ unsigned int v;
+ unsigned long r;
+
+ if (!td->o.dedupe_percentage)
+ return &td->buf_state;
+ else if (td->o.dedupe_percentage == 100)
+ return &td->buf_state_prev;
+
+ r = __rand(&td->dedupe_state);
+ v = 1 + (int) (100.0 * (r / (FRAND_MAX + 1.0)));
+
+ if (v <= td->o.dedupe_percentage)
+ return &td->buf_state_prev;
+
+ return &td->buf_state;
+}
+
+static void save_buf_state(struct thread_data *td, struct frand_state *rs)
+{
+ if (rs == &td->buf_state)
+ frand_copy(&td->buf_state_prev, rs);
+}
+