22
33#include " fmt/format.h"
44
5+ #include " include/ceph_assert.h"
6+
57using IoOp = ceph::io_exerciser::IoOp;
68using OpType = ceph::io_exerciser::OpType;
79
@@ -15,6 +17,9 @@ using TripleReadOp = ceph::io_exerciser::TripleReadOp;
1517using SingleWriteOp = ceph::io_exerciser::SingleWriteOp;
1618using DoubleWriteOp = ceph::io_exerciser::DoubleWriteOp;
1719using TripleWriteOp = ceph::io_exerciser::TripleWriteOp;
20+ using SingleFailedWriteOp = ceph::io_exerciser::SingleFailedWriteOp;
21+ using DoubleFailedWriteOp = ceph::io_exerciser::DoubleFailedWriteOp;
22+ using TripleFailedWriteOp = ceph::io_exerciser::TripleFailedWriteOp;
1823
1924namespace
2025{
@@ -164,17 +169,23 @@ std::string ceph::io_exerciser::ReadWriteOp<opType, numIOs>
164169 switch (opType)
165170 {
166171 case OpType::Read:
167- [[fallthrough]];
172+ [[ fallthrough ]];
168173 case OpType::Read2:
169- [[fallthrough]];
174+ [[ fallthrough ]];
170175 case OpType::Read3:
171176 return fmt::format (" Read{} ({})" , numIOs, offset_length_desc);
172177 case OpType::Write:
173- [[fallthrough]];
178+ [[ fallthrough ]];
174179 case OpType::Write2:
175- [[fallthrough]];
180+ [[ fallthrough ]];
176181 case OpType::Write3:
177182 return fmt::format (" Write{} ({})" , numIOs, offset_length_desc);
183+ case OpType::FailedWrite:
184+ [[ fallthrough ]];
185+ case OpType::FailedWrite2:
186+ [[ fallthrough ]];
187+ case OpType::FailedWrite3:
188+ return fmt::format (" FailedWrite{} ({})" , numIOs, offset_length_desc);
178189 default :
179190 ceph_abort_msg (fmt::format (" Unsupported op type by ReadWriteOp ({})" , opType));
180191 }
@@ -262,4 +273,159 @@ std::unique_ptr<TripleWriteOp> TripleWriteOp::generate(uint64_t offset1, uint64_
262273 return std::make_unique<TripleWriteOp>(offset1, length1,
263274 offset2, length2,
264275 offset3, length3);
276+ }
277+
278+ SingleFailedWriteOp::SingleFailedWriteOp (uint64_t offset, uint64_t length) :
279+ ReadWriteOp<OpType::FailedWrite, 1>({offset}, {length})
280+ {
281+
282+ }
283+
284+ std::unique_ptr<SingleFailedWriteOp> SingleFailedWriteOp::generate (uint64_t offset,
285+ uint64_t length)
286+ {
287+ return std::make_unique<SingleFailedWriteOp>(offset, length);
288+ }
289+
290+ DoubleFailedWriteOp::DoubleFailedWriteOp (uint64_t offset1, uint64_t length1,
291+ uint64_t offset2, uint64_t length2) :
292+ ReadWriteOp<OpType::FailedWrite2, 2>({offset1, offset2}, {length1, length2})
293+ {
294+
295+ }
296+
297+ std::unique_ptr<DoubleFailedWriteOp> DoubleFailedWriteOp::generate (uint64_t offset1,
298+ uint64_t length1,
299+ uint64_t offset2,
300+ uint64_t length2)
301+ {
302+ return std::make_unique<DoubleFailedWriteOp>(offset1, length1, offset2, length2);
303+ }
304+
305+ TripleFailedWriteOp::TripleFailedWriteOp (uint64_t offset1, uint64_t length1,
306+ uint64_t offset2, uint64_t length2,
307+ uint64_t offset3, uint64_t length3) :
308+ ReadWriteOp<OpType::FailedWrite3, 3>({offset1, offset2, offset3},
309+ {length1, length2, length3})
310+ {
311+
312+ }
313+
314+ std::unique_ptr<TripleFailedWriteOp> TripleFailedWriteOp::generate (uint64_t offset1,
315+ uint64_t length1,
316+ uint64_t offset2,
317+ uint64_t length2,
318+ uint64_t offset3,
319+ uint64_t length3)
320+ {
321+ return std::make_unique<TripleFailedWriteOp>(offset1, length1,
322+ offset2, length2,
323+ offset3, length3);
324+ }
325+
326+ template <ceph::io_exerciser::OpType opType>
327+ ceph::io_exerciser::InjectErrorOp<opType>
328+ ::InjectErrorOp (int shard,
329+ const std::optional<uint64_t >& type,
330+ const std::optional<uint64_t >& when,
331+ const std::optional<uint64_t >& duration) :
332+ TestOp<opType>(),
333+ shard(shard),
334+ type(type),
335+ when(when),
336+ duration(duration)
337+ {
338+
339+ }
340+
341+ template <ceph::io_exerciser::OpType opType>
342+ std::string ceph::io_exerciser::InjectErrorOp<opType>::to_string(uint64_t blocksize) const
343+ {
344+ std::string_view inject_type = get_inject_type_string ();
345+ return fmt::format (" Inject {} error on shard {} of type {}"
346+ " after {} successful inject(s) lasting {} inject(s)" ,
347+ inject_type, shard, type.value_or (0 ),
348+ when.value_or (0 ), duration.value_or (1 ));
349+ }
350+
351+ ceph::io_exerciser::InjectReadErrorOp::InjectReadErrorOp (int shard,
352+ const std::optional<uint64_t >& type,
353+ const std::optional<uint64_t >& when,
354+ const std::optional<uint64_t >& duration) :
355+ InjectErrorOp<OpType::InjectReadError>(shard, type, when, duration)
356+ {
357+
358+ }
359+
360+ std::unique_ptr<ceph::io_exerciser::InjectReadErrorOp> ceph::io_exerciser
361+ ::InjectReadErrorOp::generate (int shard,
362+ const std::optional<uint64_t >& type,
363+ const std::optional<uint64_t >& when,
364+ const std::optional<uint64_t >& duration)
365+ {
366+ return std::make_unique<InjectReadErrorOp>(shard, type, when, duration);
367+ }
368+
369+ ceph::io_exerciser::InjectWriteErrorOp::InjectWriteErrorOp (int shard,
370+ const std::optional<uint64_t >& type,
371+ const std::optional<uint64_t >& when,
372+ const std::optional<uint64_t >& duration) :
373+ InjectErrorOp<OpType::InjectWriteError>(shard, type, when, duration)
374+ {
375+
376+ }
377+
378+ std::unique_ptr<ceph::io_exerciser::InjectWriteErrorOp> ceph::io_exerciser
379+ ::InjectWriteErrorOp::generate (int shard,
380+ const std::optional<uint64_t >& type,
381+ const std::optional<uint64_t >& when,
382+ const std::optional<uint64_t >& duration)
383+ {
384+ return std::make_unique<InjectWriteErrorOp>(shard, type, when, duration);
385+ }
386+
387+
388+
389+ template <ceph::io_exerciser::OpType opType>
390+ ceph::io_exerciser::ClearErrorInjectOp<opType>
391+ ::ClearErrorInjectOp (int shard, const std::optional<uint64_t >& type) :
392+ TestOp<opType>(),
393+ shard(shard),
394+ type(type)
395+ {
396+
397+ }
398+
399+ template <ceph::io_exerciser::OpType opType>
400+ std::string ceph::io_exerciser::ClearErrorInjectOp<opType>::to_string(uint64_t blocksize) const
401+ {
402+ std::string_view inject_type = get_inject_type_string ();
403+ return fmt::format (" Clear {} injects on shard {} of type {}" ,
404+ inject_type, shard, type.value_or (0 ));
405+ }
406+
407+ ceph::io_exerciser::ClearReadErrorInjectOp::ClearReadErrorInjectOp (int shard,
408+ const std::optional<uint64_t >& type) :
409+ ClearErrorInjectOp<OpType::ClearReadErrorInject>(shard, type)
410+ {
411+
412+ }
413+
414+ std::unique_ptr<ceph::io_exerciser::ClearReadErrorInjectOp> ceph::io_exerciser
415+ ::ClearReadErrorInjectOp::generate (int shard, const std::optional<uint64_t >& type)
416+ {
417+ return std::make_unique<ClearReadErrorInjectOp>(shard, type);
418+ }
419+
420+ ceph::io_exerciser::ClearWriteErrorInjectOp::ClearWriteErrorInjectOp (int shard,
421+ const std::optional<uint64_t >& type) :
422+ ClearErrorInjectOp<OpType::ClearWriteErrorInject>(shard, type)
423+ {
424+
425+ }
426+
427+ std::unique_ptr<ceph::io_exerciser::ClearWriteErrorInjectOp> ceph::io_exerciser
428+ ::ClearWriteErrorInjectOp::generate (int shard, const std::optional<uint64_t >& type)
429+ {
430+ return std::make_unique<ClearWriteErrorInjectOp>(shard, type);
265431}
0 commit comments