From: Jens Axboe Date: Thu, 1 Jul 2021 19:27:39 +0000 (-0600) Subject: Merge branch 'dedupe_bugfix' of https://github.com/bardavid/fio X-Git-Tag: fio-3.28~45 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=77c72e0f504364adf6a0e8f1155fdf3fd68ef248;hp=ea51055cbb2fcbca3935e25c78e8b6d358ca2b3f 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 --- 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; }