Skip to content

Commit 514ff50

Browse files
committed
Merge PR ceph#60216 into main
* refs/pull/60216/head: common/options: pass name as rvalue reference common/config: use libfmt to build strings common/config: use emplace_back() instead of push_back() common/HeartbeatMap: pass name as rvalue reference common/config_obs_mgr: use the erase() return value common/SloppyCRCMap: use the erase() return value common: disable `boost::intrusive::constant_time_size` Reviewed-by: Patrick Donnelly <[email protected]>
2 parents bb13534 + 9441e9a commit 514ff50

File tree

11 files changed

+23
-21
lines changed

11 files changed

+23
-21
lines changed

src/common/HeartbeatMap.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ HeartbeatMap::~HeartbeatMap()
4343
ceph_assert(m_workers.empty());
4444
}
4545

46-
heartbeat_handle_d *HeartbeatMap::add_worker(const string& name, pthread_t thread_id)
46+
heartbeat_handle_d *HeartbeatMap::add_worker(string&& name, pthread_t thread_id)
4747
{
4848
std::unique_lock locker{m_rwlock};
4949
ldout(m_cct, 10) << "add_worker '" << name << "'" << dendl;
50-
heartbeat_handle_d *h = new heartbeat_handle_d(name);
50+
heartbeat_handle_d *h = new heartbeat_handle_d(std::move(name));
5151
ANNOTATE_BENIGN_RACE_SIZED(&h->timeout, sizeof(h->timeout),
5252
"heartbeat_handle_d timeout");
5353
ANNOTATE_BENIGN_RACE_SIZED(&h->suicide_timeout, sizeof(h->suicide_timeout),

src/common/HeartbeatMap.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ struct heartbeat_handle_d {
4848
ceph::timespan suicide_grace = ceph::timespan::zero();
4949
std::list<heartbeat_handle_d*>::iterator list_item;
5050

51-
explicit heartbeat_handle_d(const std::string& n)
52-
: name(n)
51+
explicit heartbeat_handle_d(std::string&& n)
52+
: name(std::move(n))
5353
{ }
5454
};
5555

5656
class HeartbeatMap {
5757
public:
5858
// register/unregister
59-
heartbeat_handle_d *add_worker(const std::string& name, pthread_t thread_id);
59+
heartbeat_handle_d *add_worker(std::string&& name, pthread_t thread_id);
6060
void remove_worker(const heartbeat_handle_d *h);
6161

6262
// reset the timeout so that it expects another touch within grace amount of time

src/common/LRUSet.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class LRUSet {
4343
// lru
4444
boost::intrusive::list<
4545
Node,
46+
boost::intrusive::constant_time_size<false>,
4647
boost::intrusive::member_hook<Node,
4748
boost::intrusive::list_member_hook<>,
4849
&Node::lru_item>

src/common/SloppyCRCMap.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ void SloppyCRCMap::truncate(uint64_t offset)
7373
offset -= offset % block_size;
7474
std::map<uint64_t,uint32_t>::iterator p = crc_map.lower_bound(offset);
7575
while (p != crc_map.end())
76-
crc_map.erase(p++);
76+
p = crc_map.erase(p);
7777
}
7878

7979
void SloppyCRCMap::zero(uint64_t offset, uint64_t len)

src/common/TrackedOp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ class TrackedOp : public boost::intrusive::list_base_hook<> {
243243
public:
244244
typedef boost::intrusive::list<
245245
TrackedOp,
246+
boost::intrusive::constant_time_size<false>,
246247
boost::intrusive::member_hook<
247248
TrackedOp,
248249
boost::intrusive::list_member_hook<>,

src/common/config.cc

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
#include "common/hostname.h"
2525
#include "common/dout.h"
2626

27+
#include <fmt/core.h>
28+
2729
/* Don't use standard Ceph logging in this file.
2830
* We can't use logging until it's initialized, and a lot of the necessary
2931
* initialization happens here.
@@ -131,14 +133,11 @@ md_config_t::md_config_t(ConfigValues& values,
131133
// Define the debug_* options as well.
132134
subsys_options.reserve(values.subsys.get_num());
133135
for (unsigned i = 0; i < values.subsys.get_num(); ++i) {
134-
string name = string("debug_") + values.subsys.get_name(i);
135-
subsys_options.push_back(
136-
Option(name, Option::TYPE_STR, Option::LEVEL_ADVANCED));
136+
subsys_options.emplace_back(
137+
fmt::format("debug_{}", values.subsys.get_name(i)), Option::TYPE_STR, Option::LEVEL_ADVANCED);
137138
Option& opt = subsys_options.back();
138-
opt.set_default(stringify(values.subsys.get_log_level(i)) + "/" +
139-
stringify(values.subsys.get_gather_level(i)));
140-
string desc = string("Debug level for ") + values.subsys.get_name(i);
141-
opt.set_description(desc.c_str());
139+
opt.set_default(fmt::format("{}/{}", values.subsys.get_log_level(i), values.subsys.get_gather_level(i)));
140+
opt.set_description(fmt::format("Debug level for {}", values.subsys.get_name(i)).c_str());
142141
opt.set_flag(Option::FLAG_RUNTIME);
143142
opt.set_long_description("The value takes the form 'N' or 'N/M' where N and M are values between 0 and 99. N is the debug level to log (all values below this are included), and M is the level to gather and buffer in memory. In the event of a crash, the most recent items <= M are dumped to the log file.");
144143
opt.set_subsys(i);
@@ -158,7 +157,7 @@ md_config_t::md_config_t(ConfigValues& values,
158157
} else {
159158
// normalize to M/N
160159
n = m;
161-
*value = stringify(m) + "/" + stringify(n);
160+
*value = fmt::format("{}/{}", m, n);
162161
}
163162
} else {
164163
*error_message = "value must take the form N or N/M, where N and M are integers";
@@ -775,7 +774,7 @@ int md_config_t::parse_option(ConfigValues& values,
775774
option_name = opt.name;
776775
if (ceph_argparse_witharg(
777776
args, i, &val, err,
778-
string(string("--default-") + opt.name).c_str(), (char*)NULL)) {
777+
fmt::format("--default-{}", opt.name).c_str(), (char*)NULL)) {
779778
if (!err.str().empty()) {
780779
error_message = err.str();
781780
ret = -EINVAL;
@@ -1268,7 +1267,7 @@ Option::value_t md_config_t::_expand_meta(
12681267
<< Option::to_str(*i->second) << "\n";
12691268
}
12701269
}
1271-
return Option::value_t(std::string("$") + o->name);
1270+
return Option::value_t(fmt::format("${}", o->name));
12721271
} else {
12731272
// recursively evaluate!
12741273
string n;

src/common/config_obs_mgr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ typename ObserverMgr<ConfigObs>::config_obs_wptr ObserverMgr<ConfigObs>::remove_
7575
for (auto o = observers.begin(); o != observers.end(); ) {
7676
if (*o->second == observer) {
7777
ptr = std::move(o->second);
78-
observers.erase(o++);
78+
o = observers.erase(o);
7979
found_obs = true;
8080
} else {
8181
++o;

src/common/intrusive_lru.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ class intrusive_lru {
125125

126126
using lru_list_t = boost::intrusive::list<
127127
base_t,
128+
boost::intrusive::constant_time_size<false>,
128129
boost::intrusive::member_hook<
129130
base_t,
130131
boost::intrusive::list_member_hook<>,

src/common/options.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,8 @@ struct Option {
207207
typedef std::function<int(std::string *, std::string *)> validator_fn_t;
208208
validator_fn_t validator;
209209

210-
Option(std::string const &name, type_t t, level_t l)
211-
: name(name), type(t), level(l)
210+
Option(std::string &&name, type_t t, level_t l)
211+
: name(std::move(name)), type(t), level(l)
212212
{
213213
// While value_t is nullable (via std::monostate), we don't ever
214214
// want it set that way in an Option instance: within an instance,

src/mon/ConfigMap.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ int ConfigMap::add_option(
266266
ldout(cct, 10) << __func__ << " unrecognized option '" << name << "'" << dendl;
267267
stray_options.push_back(
268268
std::unique_ptr<Option>(
269-
new Option(name, Option::TYPE_STR, Option::LEVEL_UNKNOWN)));
269+
new Option(std::string{name}, Option::TYPE_STR, Option::LEVEL_UNKNOWN)));
270270
opt = stray_options.back().get();
271271
}
272272

0 commit comments

Comments
 (0)