#include <stdexcept>
#include "ObjectModel.h"
-#include "IoSequence.h"
#include "common/debug.h"
#include "common/dout.h"
#include "fmt/format.h"
bool DataGenerator::validate(bufferlist& bufferlist, uint64_t offset,
uint64_t length, std::string_view pool,
- ceph::io_exerciser::Sequence curseq, int step) {
+ ceph::io_exerciser::Sequence seq, int step) {
return bufferlist.contents_equal(generate_data(offset, length));
}
bool HeaderedSeededRandomGenerator::validate(bufferlist& bufferlist, uint64_t offset,
uint64_t length, std::string_view pool,
- ceph::io_exerciser::Sequence curseq,
- int step) {
+ Sequence seq, int step) {
std::vector<uint64_t> invalid_block_offsets;
for (uint64_t block_offset = offset; block_offset < offset + length;
if (!invalid_block_offsets.empty()) {
dout(0) << "Miscompare for read of oid=" << m_model.get_primary_oid() <<
- " offset=" << offset << " length=" << length << " pool=" << pool <<
- ". This occured in test=" << curseq << " step=" << step << dendl;
+ " offset=" << offset << " length=" << length << " pool=" << pool <<
+ (seq != Sequence::SEQUENCE_END ? " sequence=" : "") <<
+ (seq != Sequence::SEQUENCE_END ? std::to_string((int)seq) : "") <<
+ (step != -1 ? " step=" : "") <<
+ (step != -1 ? std::to_string(step) : "") << dendl;
printDebugInformationForOffsets(offset, invalid_block_offsets, bufferlist);
}
virtual bufferlist generate_data(uint64_t length, uint64_t offset) = 0;
virtual bool validate(bufferlist& bufferlist, uint64_t offset,
uint64_t length, std::string_view pool,
- ceph::io_exerciser::Sequence curseq, int step);
+ ceph::io_exerciser::Sequence seq, int step);
// Used for testing debug outputs from data generation
virtual bufferlist generate_wrong_data(uint64_t offset, uint64_t length);
bufferptr generate_wrong_block(uint64_t offset) override;
bool validate(bufferlist& bufferlist, uint64_t offset,
uint64_t length, std::string_view pool,
- ceph::io_exerciser::Sequence curseq, int step) override;
+ ceph::io_exerciser::Sequence seq, int step) override;
private:
using UniqueIdBytes = uint64_t;
const uint64_t Model::get_block_size() const { return block_size; }
int Model::get_num_io() const { return num_io; }
-
-void Model::set_test_step(ceph::io_exerciser::Sequence new_seq, int new_step) {
- curseq = new_seq;
- step = new_step;
-}
std::string primary_oid;
std::string secondary_oid;
uint64_t block_size;
- ceph::io_exerciser::Sequence curseq;
- int step;
bool delete_objects;
int num_objects{0};
virtual bool readyForIoOp(IoOp& op) = 0;
virtual void applyIoOp(IoOp& op) = 0;
- void set_test_step(ceph::io_exerciser::Sequence new_seq, int new_step);
-
- virtual void set_primary_oid(const std::string& new_oid);
- virtual void set_secondary_oid(const std::string& new_oid);
const std::string get_primary_oid() const;
const std::string get_secondary_oid() const;
void swap_primary_secondary_oid();
const std::string& pool, const std::string& primary_oid, const std::string& secondary_oid,
uint64_t block_size, int seed, int threads, ceph::mutex& lock,
ceph::condition_variable& cond, bool is_replicated_pool,
- bool ec_optimizations, bool delete_objects)
+ bool ec_optimizations, std::shared_ptr<ceph::io_exerciser::IoSequence> seq,
+ bool delete_objects)
: Model(primary_oid, secondary_oid, block_size, delete_objects),
rados(rados),
asio(asio),
threads(threads),
lock(lock),
cond(cond),
- outstanding_io(0) {
+ outstanding_io(0),
+ seq(seq) {
int rc;
rc = rados.ioctx_create(pool.c_str(), io);
ceph_assert(rc == 0);
ceph_assert(ec == boost::system::errc::success);
for (int i = 0; i < N; i++) {
ceph_assert(db->validate(op_info->bufferlist[i], op_info->offset[i],
- op_info->length[i], pool, curseq, step));
+ op_info->length[i], pool,
+ seq ? seq->get_id() : Sequence::SEQUENCE_END,
+ seq ? seq->get_step() : -1));
}
finish_io();
};
ceph::condition_variable& cond;
librados::IoCtx io;
int outstanding_io;
+ std::shared_ptr<ceph::io_exerciser::IoSequence> seq;
void start_io();
void finish_io();
const std::string& pool, const std::string& primary_oid, const std::string& secondary_oid,
uint64_t block_size, int seed, int threads, ceph::mutex& lock,
ceph::condition_variable& cond, bool is_replicated_pool,
- bool ec_optimizations, bool delete_objects = true);
+ bool ec_optimizations, std::shared_ptr<ceph::io_exerciser::IoSequence> seq = nullptr,
+ bool delete_objects = true);
~RadosIo();
exerciser_model = std::make_unique<ceph::io_exerciser::RadosIo>(
rados, asio, pool, primary_oid, secondary_oid, sbs.select(), rng(),
threads, lock, cond, spo.is_replicated_pool(),
- spo.get_allow_pool_ec_optimizations(), delete_objects);
+ spo.get_allow_pool_ec_optimizations(), seq, delete_objects);
dout(0) << "= " << primary_oid << " pool=" << pool << " threads=" << threads
<< " blocksize=" << exerciser_model->get_block_size() << " ="
<< dendl;
}
op = seq->next();
- exerciser_model->set_test_step(curseq, seq->get_step());
done = false;
dout(0) << "== " << exerciser_model->get_primary_oid() << " " << curseq << " "
<< seq->get_name_with_seqseed() << " ==" << dendl;
op = seq->next();
}
}
- exerciser_model->set_test_step(curseq, seq->get_step());
return done;
}
// List sequences
std::pair<int, int> obj_size_range = sos.select();
ceph::io_exerciser::Sequence s = ceph::io_exerciser::Sequence::SEQUENCE_BEGIN;
- std::unique_ptr<ceph::io_exerciser::IoSequence> seq;
+ std::shared_ptr<ceph::io_exerciser::IoSequence> seq;
std::optional<std::pair<int, int>> km;
std::optional<std::pair<std::string_view, std::string_view>> mappinglayers;
if (testrecovery) {
std::pair<ceph::io_exerciser::Sequence, ceph::io_exerciser::Sequence>
seq_range;
ceph::io_exerciser::Sequence curseq;
- std::unique_ptr<ceph::io_exerciser::IoSequence> seq;
+ std::shared_ptr<ceph::io_exerciser::IoSequence> seq;
std::unique_ptr<ceph::io_exerciser::IoOp> op;
bool done;
ceph::util::random_number_generator<int>& rng;