diff --git a/src/crimson/osd/ops_executer.cc b/src/crimson/osd/ops_executer.cc index 7e11868d0abb3..f9c7c7d3b8b3e 100644 --- a/src/crimson/osd/ops_executer.cc +++ b/src/crimson/osd/ops_executer.cc @@ -1049,9 +1049,7 @@ ObjectContextRef OpsExecuter::prepare_clone( void OpsExecuter::apply_stats() { - pg->get_peering_state().apply_op_stats(get_target(), delta_stats); - pg->scrubber.handle_op_stats(get_target(), delta_stats); - pg->publish_stats_to_osd(); + pg->apply_stats(get_target(), delta_stats); } OpsExecuter::OpsExecuter(Ref pg, diff --git a/src/crimson/osd/osd_operations/snaptrim_event.cc b/src/crimson/osd/osd_operations/snaptrim_event.cc index aaa432e295f93..d75b8e4461a89 100644 --- a/src/crimson/osd/osd_operations/snaptrim_event.cc +++ b/src/crimson/osd/osd_operations/snaptrim_event.cc @@ -381,7 +381,6 @@ SnapTrimObjSubEvent::remove_or_update( } return seastar::do_with(ceph::os::Transaction{}, [=, this](auto &txn) { - int64_t num_objects_before_trim = delta_stats.num_objects; osd_op_p.at_version = pg->get_next_version(); auto ret = remove_or_update_iertr::now(); if (new_snaps.empty()) { @@ -396,8 +395,7 @@ SnapTrimObjSubEvent::remove_or_update( ret = adjust_snaps(obc, head_obc, new_snaps, txn); } return std::move(ret).si_then( - [&txn, obc, num_objects_before_trim, - head_obc=std::move(head_obc), this]() mutable { + [&txn, obc, head_obc=std::move(head_obc), this]() mutable { // save head snapset logger().debug("{}: {} new snapset {} on {}", *this, coid, head_obc->ssc->snapset, head_obc->obs.oi); @@ -407,11 +405,14 @@ SnapTrimObjSubEvent::remove_or_update( update_head(obc, head_obc, txn); } // Stats reporting - Set number of objects trimmed - if (num_objects_before_trim > delta_stats.num_objects) { - //int64_t num_objects_trimmed = - // num_objects_before_trim - delta_stats.num_objects; - //add_objects_trimmed_count(num_objects_trimmed); + if (delta_stats.num_objects < 0) { + int64_t num_objects_trimmed = std::abs(delta_stats.num_objects); + pg->get_peering_state().update_stats_wo_resched( + [num_objects_trimmed](auto &history, auto &stats) { + stats.objects_trimmed += num_objects_trimmed; + }); } + pg->apply_stats(coid, delta_stats); }).si_then( [&txn] () mutable { return std::move(txn); diff --git a/src/crimson/osd/osd_operations/snaptrim_event.h b/src/crimson/osd/osd_operations/snaptrim_event.h index 23f8be26c8416..66132543b13d2 100644 --- a/src/crimson/osd/osd_operations/snaptrim_event.h +++ b/src/crimson/osd/osd_operations/snaptrim_event.h @@ -134,8 +134,6 @@ class SnapTrimObjSubEvent : public PhasedOperationT { CommonPGPipeline& client_pp(); private: - /* TODO: we don't actually update the PG's stats - * https://tracker.ceph.com/issues/63307 */ object_stat_sum_t delta_stats; snap_trim_obj_subevent_ret_t remove_clone( diff --git a/src/crimson/osd/pg.cc b/src/crimson/osd/pg.cc index 8c7dd32f19b7c..5809c370e4339 100644 --- a/src/crimson/osd/pg.cc +++ b/src/crimson/osd/pg.cc @@ -212,6 +212,15 @@ pg_stat_t PG::get_stats() const return pg_stats.value_or(pg_stat_t{}); } +void PG::apply_stats( + const hobject_t &soid, + const object_stat_sum_t &delta_stats) +{ + peering_state.apply_op_stats(soid, delta_stats); + scrubber.handle_op_stats(soid, delta_stats); + publish_stats_to_osd(); +} + void PG::queue_check_readable(epoch_t last_peering_reset, ceph::timespan delay) { // handle the peering event in the background diff --git a/src/crimson/osd/pg.h b/src/crimson/osd/pg.h index 0552d49f2ad49..c8cb4010cf066 100644 --- a/src/crimson/osd/pg.h +++ b/src/crimson/osd/pg.h @@ -664,6 +664,9 @@ class PG : public boost::intrusive_ref_counter< void publish_stats_to_osd() final; void clear_publish_stats() final; pg_stat_t get_stats() const; + void apply_stats( + const hobject_t &soid, + const object_stat_sum_t &delta_stats); private: std::optional pg_stats;