diff options
author | Bar David <Bar.David@dell.com> | 2021-06-17 15:39:58 +0300 |
---|---|---|
committer | Bar David <bardavvid@gmail.com> | 2021-07-15 08:55:15 +0300 |
commit | 0d71aa983a4dce75a088b3a4831d5b217df066fb (patch) | |
tree | 81b63a555ce0f7353067e3ad0e040fe80c9ac894 /dedupe.c | |
parent | 77c72e0f504364adf6a0e8f1155fdf3fd68ef248 (diff) | |
download | fio-0d71aa983a4dce75a088b3a4831d5b217df066fb.tar.gz fio-0d71aa983a4dce75a088b3a4831d5b217df066fb.tar.bz2 |
dedupe: allow to generate dedupe buffers from working set
This commit introduced new dedupe generation mode "working_set".
Working set mode simulates a more realistic approach to deduped data,
in which deduped buffers are generated from pre-existing working set -
% size of the device or file.
In other words, dedupe is not usually expected to be close
in time with the source buffer, as well as source buffers
are usually composed of small subset of the entire file or device.
Signed-off-by: Bar David <bardavvid@gmail.com>
Diffstat (limited to 'dedupe.c')
-rw-r--r-- | dedupe.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/dedupe.c b/dedupe.c new file mode 100644 index 00000000..043a376c --- /dev/null +++ b/dedupe.c @@ -0,0 +1,28 @@ +#include "fio.h" + +int init_dedupe_working_set_seeds(struct thread_data *td) +{ + unsigned long long i; + struct frand_state dedupe_working_set_state = {0}; + + if (!td->o.dedupe_percentage || !(td->o.dedupe_mode == DEDUPE_MODE_WORKING_SET)) + return 0; + + /* + * The dedupe working set keeps seeds of unique data (generated by buf_state). + * Dedupe-ed pages will be generated using those seeds. + */ + td->num_unique_pages = (td->o.size * (unsigned long long)td->o.dedupe_working_set_percentage / 100) / td->o.min_bs[DDIR_WRITE]; + td->dedupe_working_set_states = malloc(sizeof(struct frand_state) * td->num_unique_pages); + if (!td->dedupe_working_set_states) { + log_err("fio: could not allocate dedupe working set\n"); + return 1; + } + frand_copy(&dedupe_working_set_state, &td->buf_state); + for (i = 0; i < td->num_unique_pages; i++) { + frand_copy(&td->dedupe_working_set_states[i], &dedupe_working_set_state); + __get_next_seed(&dedupe_working_set_state); + } + + return 0; +} |