mds: avoid recursive locks dumping state

Also: fix return to std::string. A string_view is not a thread-safe return.

Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
This commit is contained in:
Patrick Donnelly 2023-07-26 20:17:02 -04:00
parent 36eaa495eb
commit 60d1bdb1f5
No known key found for this signature in database
GPG Key ID: FA47FD0B0367D313
3 changed files with 9 additions and 4 deletions

View File

@ -392,9 +392,9 @@ public:
warn_interval_multiplier = 0;
}
virtual std::string_view state_string() const {
std::string state_string() const {
std::lock_guard l(lock);
return events.empty() ? std::string_view() : std::string_view(events.rbegin()->str);
return _get_state_string();
}
void dump(utime_t now, ceph::Formatter *f) const;
@ -414,6 +414,11 @@ public:
friend void intrusive_ptr_release(TrackedOp *o) {
o->put();
}
protected:
virtual std::string _get_state_string() const {
return events.empty() ? std::string() : std::string(events.rbegin()->str);
}
};

View File

@ -481,7 +481,7 @@ void MDRequestImpl::dump(Formatter *f) const
void MDRequestImpl::_dump(Formatter *f) const
{
f->dump_string("flag_point", state_string());
f->dump_string("flag_point", _get_state_string());
f->dump_stream("reqid") << reqid;
{
msg_lock.lock();

View File

@ -113,7 +113,7 @@ public:
return latest_flag_point;
}
std::string_view state_string() const override {
std::string _get_state_string() const override {
switch(latest_flag_point) {
case flag_queued_for_pg: return "queued for pg";
case flag_reached_pg: return "reached pg";