summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2021-07-01 13:27:39 -0600
committerJens Axboe <axboe@kernel.dk>2021-07-01 13:27:39 -0600
commit77c72e0f504364adf6a0e8f1155fdf3fd68ef248 (patch)
tree54c9a7690193b0e02b605534bd4fc7038a3f65a0
parentea51055cbb2fcbca3935e25c78e8b6d358ca2b3f (diff)
parentc75f1778b9bbaf5877529103ac803a965fe1973d (diff)
downloadfio-77c72e0f504364adf6a0e8f1155fdf3fd68ef248.tar.gz
fio-77c72e0f504364adf6a0e8f1155fdf3fd68ef248.tar.bz2
Merge branch 'dedupe_bugfix' of https://github.com/bardavid/fio
* 'dedupe_bugfix' of https://github.com/bardavid/fio: dedupe: fixing bug with subsequent dedupe buffer generation
-rw-r--r--fio.h1
-rw-r--r--io_u.c12
2 files changed, 11 insertions, 2 deletions
diff --git a/fio.h b/fio.h
index b05cb3df..83334652 100644
--- a/fio.h
+++ b/fio.h
@@ -259,6 +259,7 @@ struct thread_data {
struct frand_state buf_state;
struct frand_state buf_state_prev;
+ struct frand_state buf_state_ret;
struct frand_state dedupe_state;
struct frand_state zone_state;
struct frand_state prio_state;
diff --git a/io_u.c b/io_u.c
index b421a579..b60488a3 100644
--- a/io_u.c
+++ b/io_u.c
@@ -2182,8 +2182,16 @@ static struct frand_state *get_buf_state(struct thread_data *td)
v = rand_between(&td->dedupe_state, 1, 100);
- if (v <= td->o.dedupe_percentage)
- return &td->buf_state_prev;
+ if (v <= td->o.dedupe_percentage) {
+ /*
+ * The caller advances the returned frand_state.
+ * A copy of prev should be returned instead since
+ * a subsequent intention to generate a deduped buffer
+ * might result in generating a unique one
+ */
+ frand_copy(&td->buf_state_ret, &td->buf_state_prev);
+ return &td->buf_state_ret;
+ }
return &td->buf_state;
}