11#pragma once
22
3+ #include < array>
34#include < string>
45#include < memory>
56#include " include/ceph_assert.h"
67
8+ #include " OpType.h"
9+
710/* Overview
8- *
9- * enum OpType
10- * Enumeration of different types of I/O operation
1111 *
1212 * class IoOp
1313 * Stores details for an I/O operation. Generated by IoSequences
1717namespace ceph {
1818 namespace io_exerciser {
1919
20- enum class OpType {
21- Done, // End of I/O sequence
22- BARRIER, // Barrier - all prior I/Os must complete
23- CREATE, // Create object and pattern with data
24- REMOVE, // Remove object
25- READ, // Read
26- READ2, // 2 Reads in one op
27- READ3, // 3 Reads in one op
28- WRITE, // Write
29- WRITE2, // 2 Writes in one op
30- WRITE3 // 3 Writes in one op
20+ class IoOp
21+ {
22+ public:
23+ IoOp ();
24+ virtual ~IoOp () = default ;
25+ virtual std::string to_string (uint64_t block_size) const = 0;
26+ virtual constexpr OpType getOpType () const = 0;
3127 };
3228
33- class IoOp {
34- protected:
35- std::string value_to_string (uint64_t v) const ;
36-
37- public:
38- OpType op;
39- uint64_t offset1;
40- uint64_t length1;
41- uint64_t offset2;
42- uint64_t length2;
43- uint64_t offset3;
44- uint64_t length3;
45-
46- IoOp ( OpType op,
47- uint64_t offset1 = 0 , uint64_t length1 = 0 ,
48- uint64_t offset2 = 0 , uint64_t length2 = 0 ,
49- uint64_t offset3 = 0 , uint64_t length3 = 0 );
50-
51- static std::unique_ptr<IoOp> generate_done ();
29+ template <OpType opType>
30+ class TestOp : public IoOp
31+ {
32+ public:
33+ TestOp ();
34+ constexpr OpType getOpType () const override { return opType; }
35+ };
5236
53- static std::unique_ptr<IoOp> generate_barrier ();
37+ class DoneOp : public TestOp <OpType::Done>
38+ {
39+ public:
40+ DoneOp ();
41+ static std::unique_ptr<DoneOp> generate ();
42+ std::string to_string (uint64_t block_size) const override ;
43+ };
5444
55- static std::unique_ptr<IoOp> generate_create (uint64_t size);
45+ class BarrierOp : public TestOp <OpType::Barrier>
46+ {
47+ public:
48+ BarrierOp ();
49+ static std::unique_ptr<BarrierOp> generate ();
50+ std::string to_string (uint64_t block_size) const override ;
51+ };
5652
57- static std::unique_ptr<IoOp> generate_remove ();
53+ class CreateOp : public TestOp <OpType::Create>
54+ {
55+ public:
56+ CreateOp (uint64_t size);
57+ static std::unique_ptr<CreateOp> generate (uint64_t size);
58+ std::string to_string (uint64_t block_size) const override ;
59+ uint64_t size;
60+ };
5861
59- static std::unique_ptr<IoOp> generate_read (uint64_t offset,
60- uint64_t length);
62+ class RemoveOp : public TestOp <OpType::Remove>
63+ {
64+ public:
65+ RemoveOp ();
66+ static std::unique_ptr<RemoveOp> generate ();
67+ std::string to_string (uint64_t block_size) const override ;
68+ };
6169
62- static std::unique_ptr<IoOp> generate_read2 (uint64_t offset1,
63- uint64_t length1,
64- uint64_t offset2,
65- uint64_t length2);
70+ template <OpType opType, int numIOs>
71+ class ReadWriteOp : public TestOp <opType>
72+ {
73+ public:
74+ std::array<uint64_t , numIOs> offset;
75+ std::array<uint64_t , numIOs> length;
76+
77+ protected:
78+ ReadWriteOp (std::array<uint64_t , numIOs>&& offset,
79+ std::array<uint64_t , numIOs>&& length);
80+ std::string to_string (uint64_t block_size) const override ;
81+ };
6682
67- static std::unique_ptr<IoOp> generate_read3 (uint64_t offset1,
68- uint64_t length1,
69- uint64_t offset2,
70- uint64_t length2,
71- uint64_t offset3,
72- uint64_t length3);
83+ class SingleReadOp : public ReadWriteOp <OpType::Read, 1 >
84+ {
85+ public:
86+ SingleReadOp (uint64_t offset, uint64_t length);
87+ static std::unique_ptr<SingleReadOp> generate (uint64_t offset,
88+ uint64_t length);
89+ };
7390
74- static std::unique_ptr<IoOp> generate_write (uint64_t offset,
75- uint64_t length);
91+ class DoubleReadOp : public ReadWriteOp <OpType::Read2, 2 >
92+ {
93+ public:
94+ DoubleReadOp (uint64_t offset1, uint64_t length1,
95+ uint64_t offset2, uint64_t length2);
96+ static std::unique_ptr<DoubleReadOp> generate (uint64_t offset1,
97+ uint64_t length1,
98+ uint64_t offset2,
99+ uint64_t length2);
100+ };
76101
77- static std::unique_ptr<IoOp> generate_write2 (uint64_t offset1,
78- uint64_t length1,
79- uint64_t offset2,
80- uint64_t length2);
102+ class TripleReadOp : public ReadWriteOp <OpType::Read3, 3 >
103+ {
104+ public:
105+ TripleReadOp (uint64_t offset1, uint64_t length1,
106+ uint64_t offset2, uint64_t length2,
107+ uint64_t offset3, uint64_t length3);
108+ static std::unique_ptr<TripleReadOp> generate (uint64_t offset1,
109+ uint64_t length1,
110+ uint64_t offset2,
111+ uint64_t length2,
112+ uint64_t offset3,
113+ uint64_t length3);
114+ };
81115
82- static std::unique_ptr<IoOp> generate_write3 (uint64_t offset1,
83- uint64_t length1,
84- uint64_t offset2,
85- uint64_t length2,
86- uint64_t offset3,
87- uint64_t length3);
116+ class SingleWriteOp : public ReadWriteOp <OpType::Write, 1 >
117+ {
118+ public:
119+ SingleWriteOp (uint64_t offset, uint64_t length);
120+ static std::unique_ptr<SingleWriteOp> generate (uint64_t offset,
121+ uint64_t length);
122+ };
88123
89- bool done ();
124+ class DoubleWriteOp : public ReadWriteOp <OpType::Write2, 2 >
125+ {
126+ public:
127+ DoubleWriteOp (uint64_t offset1, uint64_t length1,
128+ uint64_t offset2, uint64_t length2);
129+ static std::unique_ptr<DoubleWriteOp> generate (uint64_t offset1,
130+ uint64_t length1,
131+ uint64_t offset2,
132+ uint64_t length2);
133+ };
90134
91- std::string to_string (uint64_t block_size) const ;
135+ class TripleWriteOp : public ReadWriteOp <OpType::Write3, 3 >
136+ {
137+ public:
138+ TripleWriteOp (uint64_t offset1, uint64_t length1,
139+ uint64_t offset2, uint64_t length2,
140+ uint64_t offset3, uint64_t length3);
141+ static std::unique_ptr<TripleWriteOp> generate (uint64_t offset1,
142+ uint64_t length1,
143+ uint64_t offset2,
144+ uint64_t length2,
145+ uint64_t offset3,
146+ uint64_t length3);
92147 };
93148 }
94149}
0 commit comments