summaryrefslogtreecommitdiff
path: root/dedupe.c
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2021-07-15 09:54:03 -0600
committerJens Axboe <axboe@kernel.dk>2021-07-15 09:54:03 -0600
commitae5c7cdd710dfa97705d965dcf001a96504e5f31 (patch)
treeaf6159f11a6d31c1373884b83878e822a4f286b4 /dedupe.c
parentaaedde68bfb2d15c3a444df496ba26ac0956445c (diff)
parent0d71aa983a4dce75a088b3a4831d5b217df066fb (diff)
downloadfio-ae5c7cdd710dfa97705d965dcf001a96504e5f31.tar.gz
fio-ae5c7cdd710dfa97705d965dcf001a96504e5f31.tar.bz2
Merge branch 'dedupe_workset' of https://github.com/bardavid/fio
* 'dedupe_workset' of https://github.com/bardavid/fio: dedupe: allow to generate dedupe buffers from working set
Diffstat (limited to 'dedupe.c')
-rw-r--r--dedupe.c28
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;
+}