Skip to content

Commit 8b95812

Browse files
committed
tools/rados: abstract the destination (data, omap, xattrs) from writes
Signed-off-by: Radoslaw Zarzynski <[email protected]>
1 parent c9652f4 commit 8b95812

File tree

1 file changed

+25
-30
lines changed

1 file changed

+25
-30
lines changed

src/tools/rados/rados.cc

Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,10 +1056,10 @@ void LoadGen::cleanup()
10561056
}
10571057
}
10581058

1059-
enum OpWriteDest {
1060-
OP_WRITE_DEST_OBJ = 2 << 0,
1061-
OP_WRITE_DEST_OMAP = 2 << 1,
1062-
OP_WRITE_DEST_XATTR = 2 << 2,
1059+
enum OpDest {
1060+
OP_DEST_OBJ = 2 << 0,
1061+
OP_DEST_OMAP = 2 << 1,
1062+
OP_DEST_XATTR = 2 << 2,
10631063
};
10641064

10651065
class RadosBencher : public ObjBencher {
@@ -1068,7 +1068,7 @@ class RadosBencher : public ObjBencher {
10681068
librados::IoCtx& io_ctx;
10691069
librados::NObjectIterator oi;
10701070
bool iterator_valid;
1071-
OpWriteDest write_destination;
1071+
OpDest destination;
10721072

10731073
protected:
10741074
int completions_init(int concurrentios) override {
@@ -1101,7 +1101,7 @@ class RadosBencher : public ObjBencher {
11011101
size_t offset) override {
11021102
librados::ObjectWriteOperation op;
11031103

1104-
if (write_destination & OP_WRITE_DEST_OBJ) {
1104+
if (destination & OP_DEST_OBJ) {
11051105
if (data.hints)
11061106
op.set_alloc_hint2(data.object_size, data.op_size,
11071107
ALLOC_HINT_FLAG_SEQUENTIAL_WRITE |
@@ -1111,13 +1111,13 @@ class RadosBencher : public ObjBencher {
11111111
op.write(offset, bl);
11121112
}
11131113

1114-
if (write_destination & OP_WRITE_DEST_OMAP) {
1114+
if (destination & OP_DEST_OMAP) {
11151115
std::map<std::string, librados::bufferlist> omap;
11161116
omap[string("bench-omap-key-") + stringify(offset)] = bl;
11171117
op.omap_set(omap);
11181118
}
11191119

1120-
if (write_destination & OP_WRITE_DEST_XATTR) {
1120+
if (destination & OP_DEST_XATTR) {
11211121
char key[80];
11221122
snprintf(key, sizeof(key), "bench-xattr-key-%d", (int)offset);
11231123
op.setxattr(key, bl);
@@ -1183,11 +1183,11 @@ class RadosBencher : public ObjBencher {
11831183

11841184
public:
11851185
RadosBencher(CephContext *cct_, librados::Rados& _r, librados::IoCtx& _i)
1186-
: ObjBencher(cct_), completions(NULL), rados(_r), io_ctx(_i), iterator_valid(false), write_destination(OP_WRITE_DEST_OBJ) {}
1186+
: ObjBencher(cct_), completions(NULL), rados(_r), io_ctx(_i), iterator_valid(false), destination(OP_DEST_OBJ) {}
11871187
~RadosBencher() override { }
11881188

1189-
void set_write_destination(OpWriteDest dest) {
1190-
write_destination = dest;
1189+
void set_destination(OpDest dest) {
1190+
destination = dest;
11911191
}
11921192
};
11931193

@@ -1885,7 +1885,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts,
18851885
uint64_t obj_offset = 0;
18861886
bool obj_offset_specified = false;
18871887
bool block_size_specified = false;
1888-
int bench_write_dest = 0;
1888+
int bench_dest = 0;
18891889
bool cleanup = true;
18901890
bool hints = true; // for rados bench
18911891
bool reuse_bench = false;
@@ -2106,17 +2106,17 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts,
21062106
if (i != opts.end()) {
21072107
output = i->second.c_str();
21082108
}
2109-
i = opts.find("write-dest-obj");
2109+
i = opts.find("dest-obj");
21102110
if (i != opts.end()) {
2111-
bench_write_dest |= static_cast<int>(OP_WRITE_DEST_OBJ);
2111+
bench_dest |= static_cast<int>(OP_DEST_OBJ);
21122112
}
2113-
i = opts.find("write-dest-omap");
2113+
i = opts.find("dest-omap");
21142114
if (i != opts.end()) {
2115-
bench_write_dest |= static_cast<int>(OP_WRITE_DEST_OMAP);
2115+
bench_dest |= static_cast<int>(OP_DEST_OMAP);
21162116
}
2117-
i = opts.find("write-dest-xattr");
2117+
i = opts.find("dest-xattr");
21182118
if (i != opts.end()) {
2119-
bench_write_dest |= static_cast<int>(OP_WRITE_DEST_XATTR);
2119+
bench_dest |= static_cast<int>(OP_DEST_XATTR);
21202120
}
21212121
i = opts.find("with-clones");
21222122
if (i != opts.end()) {
@@ -3327,15 +3327,9 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts,
33273327
<< std::endl;
33283328
return 1;
33293329
}
3330-
if (bench_write_dest != 0) {
3331-
cerr << "--write-object, --write-omap and --write-xattr options can "
3332-
"only be used with the 'write' bench test"
3333-
<< std::endl;
3334-
return 1;
3335-
}
33363330
}
3337-
else if (bench_write_dest == 0) {
3338-
bench_write_dest = OP_WRITE_DEST_OBJ;
3331+
if (bench_dest == 0) {
3332+
bench_dest = OP_DEST_OBJ;
33393333
}
33403334

33413335
if (!formatter && output) {
@@ -3345,7 +3339,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts,
33453339
}
33463340
RadosBencher bencher(g_ceph_context, rados, io_ctx);
33473341
bencher.set_show_time(show_time);
3348-
bencher.set_write_destination(static_cast<OpWriteDest>(bench_write_dest));
3342+
bencher.set_destination(static_cast<OpDest>(bench_dest));
33493343

33503344
ostream *outstream = NULL;
33513345
if (formatter) {
@@ -4235,11 +4229,12 @@ int main(int argc, const char **argv)
42354229
} else if (ceph_argparse_witharg(args, i, &val, "-o", "--output", (char*)NULL)) {
42364230
opts["output"] = val;
42374231
} else if (ceph_argparse_flag(args, i, "--write-omap", (char*)NULL)) {
4238-
opts["write-dest-omap"] = "true";
4232+
// write- prefixed dests are legacy
4233+
opts["dest-omap"] = "true";
42394234
} else if (ceph_argparse_flag(args, i, "--write-object", (char*)NULL)) {
4240-
opts["write-dest-obj"] = "true";
4235+
opts["dest-obj"] = "true";
42414236
} else if (ceph_argparse_flag(args, i, "--write-xattr", (char*)NULL)) {
4242-
opts["write-dest-xattr"] = "true";
4237+
opts["dest-xattr"] = "true";
42434238
} else if (ceph_argparse_flag(args, i, "--with-clones", (char*)NULL)) {
42444239
opts["with-clones"] = "true";
42454240
} else if (ceph_argparse_witharg(args, i, &val, "--omap-key-file", (char*)NULL)) {

0 commit comments

Comments
 (0)