summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBar David <Bar.David@dell.com>2021-06-17 15:39:58 +0300
committerBar David <bardavvid@gmail.com>2021-07-15 08:55:15 +0300
commit0d71aa983a4dce75a088b3a4831d5b217df066fb (patch)
tree81b63a555ce0f7353067e3ad0e040fe80c9ac894 /lib
parent77c72e0f504364adf6a0e8f1155fdf3fd68ef248 (diff)
downloadfio-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 'lib')
-rw-r--r--lib/rand.c10
-rw-r--r--lib/rand.h10
2 files changed, 12 insertions, 8 deletions
diff --git a/lib/rand.c b/lib/rand.c
index 5eb6e60a..e74da609 100644
--- a/lib/rand.c
+++ b/lib/rand.c
@@ -125,10 +125,7 @@ void __fill_random_buf(void *buf, unsigned int len, uint64_t seed)
uint64_t fill_random_buf(struct frand_state *fs, void *buf,
unsigned int len)
{
- uint64_t r = __rand(fs);
-
- if (sizeof(int) != sizeof(long *))
- r *= (unsigned long) __rand(fs);
+ uint64_t r = __get_next_seed(fs);
__fill_random_buf(buf, len, r);
return r;
@@ -188,10 +185,7 @@ uint64_t fill_random_buf_percentage(struct frand_state *fs, void *buf,
unsigned int segment, unsigned int len,
char *pattern, unsigned int pbytes)
{
- uint64_t r = __rand(fs);
-
- if (sizeof(int) != sizeof(long *))
- r *= (unsigned long) __rand(fs);
+ uint64_t r = __get_next_seed(fs);
__fill_random_buf_percentage(r, buf, percentage, segment, len,
pattern, pbytes);
diff --git a/lib/rand.h b/lib/rand.h
index 46c1c5e0..a8060045 100644
--- a/lib/rand.h
+++ b/lib/rand.h
@@ -150,6 +150,16 @@ static inline uint64_t rand_between(struct frand_state *state, uint64_t start,
return start + rand32_upto(state, end - start);
}
+static inline uint64_t __get_next_seed(struct frand_state *fs)
+{
+ uint64_t r = __rand(fs);
+
+ if (sizeof(int) != sizeof(long *))
+ r *= (unsigned long) __rand(fs);
+
+ return r;
+}
+
extern void init_rand(struct frand_state *, bool);
extern void init_rand_seed(struct frand_state *, uint64_t seed, bool);
extern void __fill_random_buf(void *buf, unsigned int len, uint64_t seed);