#include <algorithm>
#include <execution>
#include <iterator>
-
-#include "common/debug.h"
-#include "common/dout.h"
-
-#define dout_subsys ceph_subsys_rados
-#define dout_context g_ceph_context
+#include <random>
using ObjectModel = ceph::io_exerciser::ObjectModel;
ObjectModel::ObjectModel(const std::string& primary_oid, const std::string& secondary_oid,
uint64_t block_size, int seed, bool delete_objects)
- : Model(primary_oid, secondary_oid, block_size, delete_objects), primary_created(false), secondary_created(false) {
- rng.seed(seed);
-}
+ : Model(primary_oid, secondary_oid, block_size, delete_objects),
+ primary_created(false), secondary_created(false), rng(seed) {}
int ObjectModel::get_seed(uint64_t offset) const {
ceph_assert(offset < primary_contents.size());
constexpr int64_t max = static_cast<int64_t>(std::numeric_limits<int>::max());
constexpr uint64_t range = static_cast<uint64_t>(max - min + 1);
uint64_t rand_value = rng();
- int64_t result = static_cast<int64_t>(rand_value % range + min);
- dout(0) << "S1 rand_value: " << rand_value << " range: "
- << range << " result: " << result << " addr: " << &rng << dendl;
- return result;
+ return static_cast<int64_t>(rand_value % range + min);
};
auto verify_and_record_read_op =
#include <random>
#include <string>
-#include "common/debug.h"
-#include "common/dout.h"
#include "include/ceph_assert.h"
#include "include/random.h"
-#define dout_subsys ceph_subsys_rados
-#define dout_context g_ceph_context
-
/* Overview
*
* class ProgramOptionReader
uint64_t range = static_cast<uint64_t>(num_selections);
uint64_t rand_value = rng();
size_t index = static_cast<size_t>(rand_value % range);
- dout(0) << "S4 rand_value: " << rand_value << " range: "
- << range << " index: " << index << " addr: " << &rng << dendl;
return selections_array[index];
}
}
uint64_t range = static_cast<uint64_t>(num_selections_stable);
uint64_t rand_value = rng();
size_t index = static_cast<size_t>(rand_value % range);
- dout(0) << "S2 rand_value: " << rand_value << " range: "
- << range << " index: " << index << " addr: " << &rng << dendl;
return selections_array_stable[index];
} else {
uint64_t range = static_cast<uint64_t>(num_selections);
uint64_t rand_value = rng();
size_t index = static_cast<size_t>(rand_value % range);
- dout(0) << "S6 rand_value: " << rand_value << " range: "
- << range << " index: " << index << " addr: " << &rng << dendl;
return selections_array[index];
}
}
uint64_t range = static_cast<uint64_t>(selection.size());
uint64_t rand_value = rng();
size_t index = static_cast<size_t>(rand_value % range);
- dout(0) << "S3 rand_value: " << rand_value << " range: "
- << range << " index: " << index << " addr: " << &rng << dendl;
return selection[index];
} else {
return std::nullopt;
auto generate_random_int = [this](uint64_t range) -> uint64_t {
uint64_t rand_value = rng();
- uint64_t index = rand_value % range;
- dout(0) << "S5 rand_value: " << rand_value << " range: "
- << range << " index: " << index << " addr: " << &rng << dendl;
- return index;
+ return rand_value % range;;
};
if (4096 % minimum_chunksize == 0) {
choices.push_back(4096);
} else {
- uint64_t r = generate_random_int(4); // 0–3
+ uint64_t r = generate_random_int(4); // [0–3]
choices.push_back(minimum_chunksize * (r + 1));
}
if ((64 * 1024) % minimum_chunksize == 0) {
choices.push_back(64 * 1024);
} else {
- uint64_t r = generate_random_int(64); // 0–63
+ uint64_t r = generate_random_int(64); // [0–63]
choices.push_back(minimum_chunksize * (r + 1));
}
if ((256 * 1024) % minimum_chunksize == 0) {
choices.push_back(256 * 1024);
} else {
- uint64_t r = generate_random_int(256); // 0–255
+ uint64_t r = generate_random_int(256); // [0–255]
choices.push_back(minimum_chunksize * (r + 1));
}
: rng(rng), verbose(verbose), seqseed(seqseed), testrecovery(testrecovery), checkconsistency(checkconsistency),
delete_objects(delete_objects) {
if (dryrun) {
+ int model_seed = rng();
exerciser_model = std::make_unique<ceph::io_exerciser::ObjectModel>(
- primary_oid, secondary_oid, sbs.select(), rng(), delete_objects);
+ primary_oid, secondary_oid, sbs.select(), model_seed, delete_objects);
} else {
const std::string pool = spo.select();
if (!dryrun) {
bufferlist outbl;
auto formatter = std::make_unique<JSONFormatter>(false);
-
+ int model_seed = rng();
exerciser_model = std::make_unique<ceph::io_exerciser::RadosIo>(
- rados, asio, pool, primary_oid, secondary_oid, sbs.select(), rng(),
+ rados, asio, pool, primary_oid, secondary_oid, sbs.select(), model_seed,
threads, lock, cond, spo.is_replicated_pool(),
spo.get_allow_pool_ec_optimizations(), delete_objects);
dout(0) << "= " << primary_oid << " pool=" << pool << " threads=" << threads
std::unique_ptr<ceph::io_exerciser::Model> model;
if (dryrun) {
+ int model_seed = rng();
model = std::make_unique<ceph::io_exerciser::ObjectModel>(
- primary_object_name, secondary_object_name, sbs.select(), rng());
+ primary_object_name, secondary_object_name, sbs.select(), model_seed);
} else {
const std::string pool = spo.select();
dout(0) << "Pool name: " << pool << dendl;
-
+ int model_seed = rng();
model = std::make_unique<ceph::io_exerciser::RadosIo>(
- rados, asio, pool, primary_object_name, secondary_object_name, sbs.select(), rng(),
+ rados, asio, pool, primary_object_name, secondary_object_name, sbs.select(), model_seed,
1, // 1 thread
lock, cond, spo.is_replicated_pool(),
spo.get_allow_pool_ec_optimizations());