double opduration = op->get_duration();
duration.insert(make_pair(opduration, op));
arrived.insert(make_pair(op->get_initiated(), op));
- if (opduration >= history_slow_op_threshold)
+ if (opduration >= history_slow_op_threshold.load())
slow_op.insert(make_pair(op->get_initiated(), op));
cleanup(now);
}
{
while (arrived.size() &&
(now - arrived.begin()->first >
- (double)(history_duration))) {
+ (double)(history_duration.load()))) {
duration.erase(make_pair(
arrived.begin()->second->get_duration(),
arrived.begin()->second));
arrived.erase(arrived.begin());
}
- while (duration.size() > history_size) {
+ while (duration.size() > history_size.load()) {
arrived.erase(make_pair(
duration.begin()->second->get_initiated(),
duration.begin()->second));
duration.erase(duration.begin());
}
- while (slow_op.size() > history_slow_op_size) {
+ while (slow_op.size() > history_slow_op_size.load()) {
slow_op.erase(make_pair(
slow_op.begin()->second->get_initiated(),
slow_op.begin()->second));
std::lock_guard history_lock(ops_history_lock);
cleanup(now);
f->open_object_section("op_history");
- f->dump_int("size", history_size);
- f->dump_int("duration", history_duration);
+ f->dump_int("size", history_size.load());
+ f->dump_int("duration", history_duration.load());
{
f->open_array_section("ops");
auto dump_fn = [&f, &now, &filters](auto begin_iter, auto end_iter) {
std::lock_guard history_lock(ops_history_lock);
cleanup(now);
f->open_object_section("OpHistory slow ops");
- f->dump_int("num to keep", history_slow_op_size);
- f->dump_int("threshold to keep", history_slow_op_threshold);
+ f->dump_int("num to keep", history_slow_op_size.load());
+ f->dump_int("threshold to keep", history_slow_op_threshold.load());
{
f->open_array_section("Ops");
for (set<pair<utime_t, TrackedOpRef> >::const_iterator i =
std::set<std::pair<utime_t, TrackedOpRef> > slow_op;
ceph::mutex ops_history_lock = ceph::make_mutex("OpHistory::ops_history_lock");
void cleanup(utime_t now);
- uint32_t history_size;
- uint32_t history_duration;
- uint32_t history_slow_op_size;
- uint32_t history_slow_op_threshold;
- std::atomic_bool shutdown;
+ std::atomic_size_t history_size{0};
+ std::atomic_uint32_t history_duration{0};
+ std::atomic_size_t history_slow_op_size{0};
+ std::atomic_uint32_t history_slow_op_threshold{0};
+ std::atomic_bool shutdown{false};
OpHistoryServiceThread opsvc;
friend class OpHistoryServiceThread;
public:
- OpHistory()
- : history_size(0), history_duration(0),
- history_slow_op_size(0), history_slow_op_threshold(0),
- shutdown(false), opsvc(this) {
+ OpHistory() : opsvc(this) {
opsvc.create("OpHistorySvc");
}
~OpHistory() {
void dump_ops(utime_t now, ceph::Formatter *f, std::set<std::string> filters = {""}, bool by_duration=false);
void dump_slow_ops(utime_t now, ceph::Formatter *f, std::set<std::string> filters = {""});
void on_shutdown();
- void set_size_and_duration(uint32_t new_size, uint32_t new_duration) {
+ void set_size_and_duration(size_t new_size, uint32_t new_duration) {
history_size = new_size;
history_duration = new_duration;
}
- void set_slow_op_size_and_threshold(uint32_t new_size, uint32_t new_threshold) {
+ void set_slow_op_size_and_threshold(size_t new_size, uint32_t new_threshold) {
history_slow_op_size = new_size;
history_slow_op_threshold = new_threshold;
}