diff options
Diffstat (limited to 'src/common/CDC.cc')
-rw-r--r-- | src/common/CDC.cc | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/common/CDC.cc b/src/common/CDC.cc index 69cb978278f..e478ba46e51 100644 --- a/src/common/CDC.cc +++ b/src/common/CDC.cc @@ -20,3 +20,26 @@ std::unique_ptr<CDC> CDC::create( } return nullptr; } + +void generate_buffer(int size, bufferlist *outbl, int seed) +{ + std::mt19937_64 engine, engine2; + engine.seed(seed); + engine2.seed(seed); + + // assemble from randomly-sized segments! + outbl->clear(); + auto left = size; + while (left) { + size_t l = std::min<size_t>((engine2() & 0xffff0) + 16, left); + left -= l; + bufferptr p(l); + p.set_length(l); + char *b = p.c_str(); + for (size_t i = 0; i < l / sizeof(uint64_t); ++i) { + ((ceph_le64 *)b)[i] = init_le64(engine()); + } + outbl->append(p); + } +} + |