Skip to content

Commit a9b8933

Browse files
Merge pull request ceph#65014 from MaxKellermann/mgr_mon_osdc__references
mgr, mon, osdc: pass complex parameters by rvalue reference Reviewed-by: Adam Emerson <[email protected]> Reviewed-By: J. Eric Ivancich <[email protected]>
2 parents 141f83a + f82ab1c commit a9b8933

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+541
-675
lines changed

src/common/io_exerciser/RadosIo.cc

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,25 @@ using ConsistencyChecker = ceph::consistency::ConsistencyChecker;
1919
namespace {
2020
template <typename S>
2121
int send_osd_command(int osd, S& s, librados::Rados& rados, const char* name,
22-
ceph::buffer::list& inbl, ceph::buffer::list* outbl,
22+
ceph::buffer::list&& inbl, ceph::buffer::list* outbl,
2323
Formatter* f) {
2424
encode_json(name, s, f);
2525

2626
std::ostringstream oss;
2727
f->flush(oss);
28-
int rc = rados.osd_command(osd, oss.str(), inbl, outbl, nullptr);
28+
int rc = rados.osd_command(osd, oss.str(), std::move(inbl), outbl, nullptr);
2929
return rc;
3030
}
3131

3232
template <typename S>
3333
int send_mon_command(S& s, librados::Rados& rados, const char* name,
34-
ceph::buffer::list& inbl, ceph::buffer::list* outbl,
34+
ceph::buffer::list&& inbl, ceph::buffer::list* outbl,
3535
Formatter* f) {
3636
encode_json(name, s, f);
3737

3838
std::ostringstream oss;
3939
f->flush(oss);
40-
int rc = rados.mon_command(oss.str(), inbl, outbl, nullptr);
40+
int rc = rados.mon_command(oss.str(), std::move(inbl), outbl, nullptr);
4141
return rc;
4242
}
4343
} // namespace
@@ -377,14 +377,14 @@ void RadosIo::applyReadWriteOp(IoOp& op) {
377377
}
378378

379379
void RadosIo::applyInjectOp(IoOp& op) {
380-
bufferlist osdmap_inbl, inject_inbl, osdmap_outbl, inject_outbl;
380+
bufferlist osdmap_outbl, inject_outbl;
381381
auto formatter = std::make_unique<JSONFormatter>(false);
382382

383383
int osd = -1;
384384
std::vector<int> shard_order;
385385

386386
ceph::messaging::osd::OSDMapRequest osdMapRequest{pool, get_primary_oid(), ""};
387-
int rc = send_mon_command(osdMapRequest, rados, "OSDMapRequest", osdmap_inbl,
387+
int rc = send_mon_command(osdMapRequest, rados, "OSDMapRequest", {},
388388
&osdmap_outbl, formatter.get());
389389
ceph_assert(rc == 0);
390390

@@ -407,7 +407,7 @@ void RadosIo::applyInjectOp(IoOp& op) {
407407
injectErrorRequest{pool, primary_oid, errorOp.shard,
408408
errorOp.type, errorOp.when, errorOp.duration};
409409
int rc = send_osd_command(osd, injectErrorRequest, rados,
410-
"InjectECErrorRequest", inject_inbl,
410+
"InjectECErrorRequest", {},
411411
&inject_outbl, formatter.get());
412412
ceph_assert(rc == 0);
413413
} else if (errorOp.type == 1) {
@@ -416,7 +416,7 @@ void RadosIo::applyInjectOp(IoOp& op) {
416416
injectErrorRequest{pool, primary_oid, errorOp.shard,
417417
errorOp.type, errorOp.when, errorOp.duration};
418418
int rc = send_osd_command(osd, injectErrorRequest, rados,
419-
"InjectECErrorRequest", inject_inbl,
419+
"InjectECErrorRequest", {},
420420
&inject_outbl, formatter.get());
421421
ceph_assert(rc == 0);
422422
} else {
@@ -433,15 +433,15 @@ void RadosIo::applyInjectOp(IoOp& op) {
433433
injectErrorRequest{pool, primary_oid, errorOp.shard,
434434
errorOp.type, errorOp.when, errorOp.duration};
435435
int rc = send_osd_command(osd, injectErrorRequest, rados,
436-
"InjectECErrorRequest", inject_inbl,
436+
"InjectECErrorRequest", {},
437437
&inject_outbl, formatter.get());
438438
ceph_assert(rc == 0);
439439
} else if (errorOp.type == 3) {
440440
ceph::messaging::osd::InjectECErrorRequest<InjectOpType::WriteOSDAbort>
441441
injectErrorRequest{pool, primary_oid, errorOp.shard,
442442
errorOp.type, errorOp.when, errorOp.duration};
443443
int rc = send_osd_command(osd, injectErrorRequest, rados,
444-
"InjectECErrorRequest", inject_inbl,
444+
"InjectECErrorRequest", {},
445445
&inject_outbl, formatter.get());
446446
ceph_assert(rc == 0);
447447

@@ -462,15 +462,15 @@ void RadosIo::applyInjectOp(IoOp& op) {
462462
ceph::messaging::osd::InjectECClearErrorRequest<InjectOpType::ReadEIO>
463463
clearErrorInject{pool, primary_oid, errorOp.shard, errorOp.type};
464464
int rc = send_osd_command(osd, clearErrorInject, rados,
465-
"InjectECClearErrorRequest", inject_inbl,
465+
"InjectECClearErrorRequest", {},
466466
&inject_outbl, formatter.get());
467467
ceph_assert(rc == 0);
468468
} else if (errorOp.type == 1) {
469469
ceph::messaging::osd::InjectECClearErrorRequest<
470470
InjectOpType::ReadMissingShard>
471471
clearErrorInject{pool, primary_oid, errorOp.shard, errorOp.type};
472472
int rc = send_osd_command(osd, clearErrorInject, rados,
473-
"InjectECClearErrorRequest", inject_inbl,
473+
"InjectECClearErrorRequest", {},
474474
&inject_outbl, formatter.get());
475475
ceph_assert(rc == 0);
476476
} else {
@@ -488,15 +488,15 @@ void RadosIo::applyInjectOp(IoOp& op) {
488488
InjectOpType::WriteFailAndRollback>
489489
clearErrorInject{pool, primary_oid, errorOp.shard, errorOp.type};
490490
int rc = send_osd_command(osd, clearErrorInject, rados,
491-
"InjectECClearErrorRequest", inject_inbl,
491+
"InjectECClearErrorRequest", {},
492492
&inject_outbl, formatter.get());
493493
ceph_assert(rc == 0);
494494
} else if (errorOp.type == 3) {
495495
ceph::messaging::osd::InjectECClearErrorRequest<
496496
InjectOpType::WriteOSDAbort>
497497
clearErrorInject{pool, primary_oid, errorOp.shard, errorOp.type};
498498
int rc = send_osd_command(osd, clearErrorInject, rados,
499-
"InjectECClearErrorRequest", inject_inbl,
499+
"InjectECClearErrorRequest", {},
500500
&inject_outbl, formatter.get());
501501
ceph_assert(rc == 0);
502502
} else {

src/erasure-code/consistency/RadosCommands.cc

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ int RadosCommands::get_primary_osd(const std::string& pool_name,
2929
std::ostringstream oss;
3030
formatter.get()->flush(oss);
3131

32-
ceph::bufferlist inbl, outbl;
33-
int rc = rados.mon_command(oss.str(), inbl, &outbl, nullptr);
32+
ceph::bufferlist outbl;
33+
int rc = rados.mon_command(oss.str(), {}, &outbl, nullptr);
3434
ceph_assert(rc == 0);
3535

3636
JSONParser p;
@@ -60,8 +60,8 @@ bool RadosCommands::get_pool_allow_ec_optimizations(const std::string& pool_name
6060
std::ostringstream oss;
6161
formatter.get()->flush(oss);
6262

63-
ceph::bufferlist inbl, outbl;
64-
int rc = rados.mon_command(oss.str(), inbl, &outbl, nullptr);
63+
ceph::bufferlist outbl;
64+
int rc = rados.mon_command(oss.str(), {}, &outbl, nullptr);
6565
ceph_assert(rc == 0);
6666

6767
JSONParser p;
@@ -89,8 +89,8 @@ std::string RadosCommands::get_pool_ec_profile_name(const std::string& pool_name
8989
std::ostringstream oss;
9090
formatter.get()->flush(oss);
9191

92-
ceph::bufferlist inbl, outbl;
93-
int rc = rados.mon_command(oss.str(), inbl, &outbl, nullptr);
92+
ceph::bufferlist outbl;
93+
int rc = rados.mon_command(oss.str(), {}, &outbl, nullptr);
9494
ceph_assert(rc == 0);
9595

9696
JSONParser p;
@@ -123,8 +123,8 @@ ceph::ErasureCodeProfile RadosCommands::get_ec_profile_for_pool(const std::strin
123123
std::ostringstream oss;
124124
formatter.get()->flush(oss);
125125

126-
ceph::bufferlist inbl, outbl;
127-
int rc = rados.mon_command(oss.str(), inbl, &outbl, nullptr);
126+
ceph::bufferlist outbl;
127+
int rc = rados.mon_command(oss.str(), {}, &outbl, nullptr);
128128
ceph_assert(rc == 0);
129129

130130
// Parse the string output into an ErasureCodeProfile
@@ -170,8 +170,8 @@ void RadosCommands::inject_parity_read_on_primary_osd(const std::string& pool_na
170170
std::ostringstream oss;
171171
formatter.get()->flush(oss);
172172

173-
ceph::bufferlist inbl, outbl;
174-
int rc = rados.osd_command(primary_osd, oss.str(), inbl, &outbl, nullptr);
173+
ceph::bufferlist outbl;
174+
int rc = rados.osd_command(primary_osd, oss.str(), {}, &outbl, nullptr);
175175
ceph_assert(rc == 0);
176176
}
177177

@@ -192,7 +192,7 @@ void RadosCommands::inject_clear_parity_read_on_primary_osd(const std::string& p
192192
std::ostringstream oss;
193193
formatter.get()->flush(oss);
194194

195-
ceph::bufferlist inbl, outbl;
196-
int rc = rados.osd_command(primary_osd, oss.str(), inbl, &outbl, nullptr);
195+
ceph::bufferlist outbl;
196+
int rc = rados.osd_command(primary_osd, oss.str(), {}, &outbl, nullptr);
197197
ceph_assert(rc == 0);
198-
}
198+
}

src/include/neorados/RADOS.hpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1737,8 +1737,8 @@ class RADOS final
17371737
std::string, ceph::buffer::list);
17381738
using CommandComp = boost::asio::any_completion_handler<CommandSig>;
17391739
template<boost::asio::completion_token_for<CommandSig> CompletionToken>
1740-
auto osd_command(int osd, std::vector<std::string> cmd,
1741-
ceph::buffer::list in, CompletionToken&& token) {
1740+
auto osd_command(int osd, std::vector<std::string>&& cmd,
1741+
ceph::buffer::list&& in, CompletionToken&& token) {
17421742
auto consigned = consign(std::forward<CompletionToken>(token));
17431743
return boost::asio::async_initiate<decltype(consigned), CommandSig>(
17441744
[osd, this](auto&& handler, std::vector<std::string> cmd,
@@ -1748,8 +1748,8 @@ class RADOS final
17481748
}, consigned, std::move(cmd), std::move(in));
17491749
}
17501750
template<boost::asio::completion_token_for<CommandSig> CompletionToken>
1751-
auto pg_command(PG pg, std::vector<std::string> cmd,
1752-
ceph::buffer::list in, CompletionToken&& token) {
1751+
auto pg_command(PG pg, std::vector<std::string>&& cmd,
1752+
ceph::buffer::list&& in, CompletionToken&& token) {
17531753
auto consigned = consign(std::forward<CompletionToken>(token));
17541754
return boost::asio::async_initiate<decltype(consigned), CommandSig>(
17551755
[this](auto&& handler, PG pg, std::vector<std::string> cmd,
@@ -1760,8 +1760,8 @@ class RADOS final
17601760
}
17611761

17621762
template<boost::asio::completion_token_for<SimpleOpSig> CompletionToken>
1763-
auto mon_command(std::vector<std::string> command,
1764-
ceph::buffer::list bl,
1763+
auto mon_command(std::vector<std::string>&& command,
1764+
ceph::buffer::list&& bl,
17651765
std::string* outs, ceph::buffer::list* outbl,
17661766
CompletionToken&& token) {
17671767
auto consigned = consign(std::forward<CompletionToken>(token));
@@ -1882,13 +1882,13 @@ class RADOS final
18821882
Cursor end, std::uint32_t max,
18831883
ceph::buffer::list filter,
18841884
EnumerateComp c);
1885-
void osd_command_(int osd, std::vector<std::string> cmd,
1886-
ceph::buffer::list in, CommandComp c);
1887-
void pg_command_(PG pg, std::vector<std::string> cmd,
1888-
ceph::buffer::list in, CommandComp c);
1885+
void osd_command_(int osd, std::vector<std::string>&& cmd,
1886+
ceph::buffer::list&& in, CommandComp c);
1887+
void pg_command_(PG pg, std::vector<std::string>&& cmd,
1888+
ceph::buffer::list&& in, CommandComp c);
18891889

1890-
void mon_command_(std::vector<std::string> command,
1891-
ceph::buffer::list bl,
1890+
void mon_command_(std::vector<std::string>&& command,
1891+
ceph::buffer::list&& bl,
18921892
std::string* outs, ceph::buffer::list* outbl,
18931893
SimpleOpComp c);
18941894

src/include/rados/librados.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,13 +1473,13 @@ inline namespace v14_2_0 {
14731473
int get_min_compatible_client(int8_t* min_compat_client,
14741474
int8_t* require_min_compat_client);
14751475

1476-
int mon_command(std::string cmd, const bufferlist& inbl,
1476+
int mon_command(std::string&& cmd, bufferlist&& inbl,
14771477
bufferlist *outbl, std::string *outs);
1478-
int mgr_command(std::string cmd, const bufferlist& inbl,
1478+
int mgr_command(std::string&& cmd, bufferlist&& inbl,
14791479
bufferlist *outbl, std::string *outs);
1480-
int osd_command(int osdid, std::string cmd, const bufferlist& inbl,
1480+
int osd_command(int osdid, std::string&& cmd, bufferlist&& inbl,
14811481
bufferlist *outbl, std::string *outs);
1482-
int pg_command(const char *pgstr, std::string cmd, const bufferlist& inbl,
1482+
int pg_command(const char *pgstr, std::string&& cmd, bufferlist&& inbl,
14831483
bufferlist *outbl, std::string *outs);
14841484

14851485
int ioctx_create(const char *name, IoCtx &pioctx);

src/librados/IoCtxImpl.cc

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2108,10 +2108,7 @@ void librados::IoCtxImpl::application_enable_async(const std::string& app_name,
21082108
}
21092109
cmd << "}";
21102110

2111-
std::vector<std::string> cmds;
2112-
cmds.push_back(cmd.str());
2113-
bufferlist inbl;
2114-
client->mon_command_async(cmds, inbl, nullptr, nullptr,
2111+
client->mon_command_async({cmd.str()}, {}, nullptr, nullptr,
21152112
make_lambda_context(CB_PoolAsync_Safe(c)));
21162113
}
21172114

@@ -2175,10 +2172,7 @@ int librados::IoCtxImpl::application_metadata_set(const std::string& app_name,
21752172
<< "\"value\":\"" << value << "\""
21762173
<< "}";
21772174

2178-
std::vector<std::string> cmds;
2179-
cmds.push_back(cmd.str());
2180-
bufferlist inbl;
2181-
int r = client->mon_command(cmds, inbl, nullptr, nullptr);
2175+
int r = client->mon_command({cmd.str()}, {}, nullptr, nullptr);
21822176
if (r < 0) {
21832177
return r;
21842178
}
@@ -2198,10 +2192,7 @@ int librados::IoCtxImpl::application_metadata_remove(const std::string& app_name
21982192
<< "\"key\":\"" << key << "\""
21992193
<< "}";
22002194

2201-
std::vector<std::string> cmds;
2202-
cmds.push_back(cmd.str());
2203-
bufferlist inbl;
2204-
int r = client->mon_command(cmds, inbl, nullptr, nullptr);
2195+
int r = client->mon_command({cmd.str()}, {}, nullptr, nullptr);
22052196
if (r < 0) {
22062197
return r;
22072198
}

0 commit comments

Comments
 (0)