Skip to content

Commit

Permalink
crimson/osd/osd_operation: fix dump_historic_slow_ops command works
Browse files Browse the repository at this point in the history
* The first 'local_conf()->osd_op_history_slow_op_size' elements
  in the history_cliend_registry list store the slow ops log,
  while the last 'local_conf()->osd_op_history_size' elements
  store the normal history ops log
* dump_historic_slow_ops command will output real slow ops log
  and slow ops numbers

Fixes: https://tracker.ceph.com/issues/65531
Signed-off-by: junxiang Mu <1948535941@qq.com>
  • Loading branch information
guojidan committed May 21, 2024
1 parent 5e689ef commit 6c19b51
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/crimson/osd/osd_operation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ OSDOperationRegistry::OSDOperationRegistry()
constexpr auto historic_reg_index =
static_cast<size_t>(OperationTypeCode::historic_client_request);
auto& historic_registry = get_registry<historic_reg_index>();
last_of_recents = std::begin(historic_registry);
last_of_recents = std::end(historic_registry);
}

static auto get_duration(const ClientRequest& client_request)
Expand All @@ -63,7 +63,7 @@ void OSDOperationRegistry::put_historic(const ClientRequest& op)
static_cast<size_t>(OperationTypeCode::historic_client_request);
auto& client_registry = get_registry<client_reg_index>();
auto& historic_registry = get_registry<historic_reg_index>();
historic_registry.splice(std::end(historic_registry),
historic_registry.splice(last_of_recents,
client_registry,
client_registry.iterator_to(op));
ClientRequest::ICRef(
Expand All @@ -75,11 +75,11 @@ void OSDOperationRegistry::put_historic(const ClientRequest& op)
// NOTE: Operation uses the auto-unlink feature of boost::intrusive.
// NOTE: the cleaning happens in OSDOperationRegistry::do_stop()
using crimson::common::local_conf;
if (num_recent_ops >= local_conf()->osd_op_history_size) {
++last_of_recents;
if (get_duration(op) > local_conf()->osd_op_complaint_time) {
++num_slow_ops;
} else {
++num_recent_ops;
--last_of_recents;
}
if (num_slow_ops > local_conf()->osd_op_history_slow_op_size) {
// we're interested in keeping slowest ops. if the slow op history
Expand All @@ -100,6 +100,10 @@ void OSDOperationRegistry::put_historic(const ClientRequest& op)
ClientRequest::ICRef(&fastest_historic_op, /* add_ref= */false);
--num_slow_ops;
}
if (num_recent_ops > local_conf()->osd_op_history_size) {
historic_registry.pop_back();
--num_recent_ops;
}
}

size_t OSDOperationRegistry::dump_historic_client_requests(ceph::Formatter* f) const
Expand Down Expand Up @@ -128,7 +132,7 @@ size_t OSDOperationRegistry::dump_slowest_historic_client_requests(ceph::Formatt
const auto& historic_client_registry =
get_registry<static_cast<size_t>(OperationTypeCode::historic_client_request)>(); //ClientRequest::type)>();
f->open_object_section("op_history");
f->dump_int("size", historic_client_registry.size());
f->dump_int("size", num_slow_ops);
// TODO: f->dump_int("duration", history_duration.load());
// the intrusive list is configured to not store the size
std::multimap<utime_t,
Expand All @@ -137,7 +141,7 @@ size_t OSDOperationRegistry::dump_slowest_historic_client_requests(ceph::Formatt
// iterating over the entire registry as a slow op could be also
// in the "recently added" part.
std::transform(std::begin(historic_client_registry),
std::end(historic_client_registry),
last_of_recents,
std::inserter(sorted_slowest_ops, std::end(sorted_slowest_ops)),
[] (const Operation& op) {
const auto& cop = static_cast<const ClientRequest&>(op);
Expand Down

0 comments on commit 6c19b51

Please sign in to comment.