-
Notifications
You must be signed in to change notification settings - Fork 0
/
dedupe.c
28 lines (24 loc) · 970 Bytes
/
dedupe.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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;
}