1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
|
#include "IoOp.h"
using IoOp = ceph::io_exerciser::IoOp;
IoOp::IoOp( OpType op,
uint64_t offset1, uint64_t length1,
uint64_t offset2, uint64_t length2,
uint64_t offset3, uint64_t length3) :
op(op),
offset1(offset1), length1(length1),
offset2(offset2), length2(length2),
offset3(offset3), length3(length3)
{
}
std::string IoOp::value_to_string(uint64_t v) const
{
if (v < 1024 || (v % 1024) != 0) {
return std::to_string(v);
}else if (v < 1024*1024 || (v % (1024 * 1024)) != 0 ) {
return std::to_string(v / 1024) + "K";
}else{
return std::to_string(v / 1024 / 1024) + "M";
}
}
std::unique_ptr<IoOp> IoOp
::generate_done() {
return std::make_unique<IoOp>(OpType::Done);
}
std::unique_ptr<IoOp> IoOp
::generate_barrier() {
return std::make_unique<IoOp>(OpType::BARRIER);
}
std::unique_ptr<IoOp> IoOp
::generate_create(uint64_t size) {
return std::make_unique<IoOp>(OpType::CREATE,0,size);
}
std::unique_ptr<IoOp> IoOp
::generate_remove() {
return std::make_unique<IoOp>(OpType::REMOVE);
}
std::unique_ptr<IoOp> IoOp
::generate_read(uint64_t offset, uint64_t length) {
return std::make_unique<IoOp>(OpType::READ, offset, length);
}
std::unique_ptr<IoOp> IoOp
::generate_read2(uint64_t offset1, uint64_t length1,
uint64_t offset2, uint64_t length2) {
if (offset1 < offset2) {
ceph_assert( offset1 + length1 <= offset2 );
} else {
ceph_assert( offset2 + length2 <= offset1 );
}
return std::make_unique<IoOp>(OpType::READ2,
offset1, length1,
offset2, length2);
}
std::unique_ptr<IoOp> IoOp
::generate_read3(uint64_t offset1, uint64_t length1,
uint64_t offset2, uint64_t length2,
uint64_t offset3, uint64_t length3) {
if (offset1 < offset2) {
ceph_assert( offset1 + length1 <= offset2 );
} else {
ceph_assert( offset2 + length2 <= offset1 );
}
if (offset1 < offset3) {
ceph_assert( offset1 + length1 <= offset3 );
} else {
ceph_assert( offset3 + length3 <= offset1 );
}
if (offset2 < offset3) {
ceph_assert( offset2 + length2 <= offset3 );
} else {
ceph_assert( offset3 + length3 <= offset2 );
}
return std::make_unique<IoOp>(OpType::READ3,
offset1, length1,
offset2, length2,
offset3, length3);
}
std::unique_ptr<IoOp> IoOp::generate_write(uint64_t offset, uint64_t length) {
return std::make_unique<IoOp>(OpType::WRITE, offset, length);
}
std::unique_ptr<IoOp> IoOp::generate_write2(uint64_t offset1, uint64_t length1,
uint64_t offset2, uint64_t length2) {
if (offset1 < offset2) {
ceph_assert( offset1 + length1 <= offset2 );
} else {
ceph_assert( offset2 + length2 <= offset1 );
}
return std::make_unique<IoOp>(OpType::WRITE2,
offset1, length1,
offset2, length2);
}
std::unique_ptr<IoOp> IoOp::generate_write3(uint64_t offset1, uint64_t length1,
uint64_t offset2, uint64_t length2,
uint64_t offset3, uint64_t length3) {
if (offset1 < offset2) {
ceph_assert( offset1 + length1 <= offset2 );
} else {
ceph_assert( offset2 + length2 <= offset1 );
}
if (offset1 < offset3) {
ceph_assert( offset1 + length1 <= offset3 );
} else {
ceph_assert( offset3 + length3 <= offset1 );
}
if (offset2 < offset3) {
ceph_assert( offset2 + length2 <= offset3 );
} else {
ceph_assert( offset3 + length3 <= offset2 );
}
return std::make_unique<IoOp>(OpType::WRITE3,
offset1, length1,
offset2, length2,
offset3, length3);
}
bool IoOp::done() {
return (op == OpType::Done);
}
std::string IoOp::to_string(uint64_t block_size) const
{
switch (op) {
case OpType::Done:
return "Done";
case OpType::BARRIER:
return "Barrier";
case OpType::CREATE:
return "Create (size=" + value_to_string(length1 * block_size) + ")";
case OpType::REMOVE:
return "Remove";
case OpType::READ:
return "Read (offset=" + value_to_string(offset1 * block_size) +
",length=" + value_to_string(length1 * block_size) + ")";
case OpType::READ2:
return "Read2 (offset1=" + value_to_string(offset1 * block_size) +
",length1=" + value_to_string(length1 * block_size) +
",offset2=" + value_to_string(offset2 * block_size) +
",length2=" + value_to_string(length2 * block_size) + ")";
case OpType::READ3:
return "Read3 (offset1=" + value_to_string(offset1 * block_size) +
",length1=" + value_to_string(length1 * block_size) +
",offset2=" + value_to_string(offset2 * block_size) +
",length2=" + value_to_string(length2 * block_size) +
",offset3=" + value_to_string(offset3 * block_size) +
",length3=" + value_to_string(length3 * block_size) + ")";
case OpType::WRITE:
return "Write (offset=" + value_to_string(offset1 * block_size) +
",length=" + value_to_string(length1 * block_size) + ")";
case OpType::WRITE2:
return "Write2 (offset1=" + value_to_string(offset1 * block_size) +
",length1=" + value_to_string(length1 * block_size) +
",offset2=" + value_to_string(offset2 * block_size) +
",length2=" + value_to_string(length2 * block_size) + ")";
case OpType::WRITE3:
return "Write3 (offset1=" + value_to_string(offset1 * block_size) +
",length1=" + value_to_string(length1 * block_size) +
",offset2=" + value_to_string(offset2 * block_size) +
",length2=" + value_to_string(length2 * block_size) +
",offset3=" + value_to_string(offset3 * block_size) +
",length3=" + value_to_string(length3 * block_size) + ")";
default:
break;
}
return "Unknown";
}
|