Skip to content

Commit

Permalink
Merge pull request ceph#56378 from guojidan/snap-stats
Browse files Browse the repository at this point in the history
crimson/osd/osd_operations/snaptrim_event: update PG's stats

Reviewed-by: Matan Breizman <[email protected]>
Reviewed-by: Samuel Just <[email protected]>
  • Loading branch information
athanatos authored Mar 27, 2024
2 parents d82c9aa + 4a180f5 commit ca414b0
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 12 deletions.
4 changes: 1 addition & 3 deletions src/crimson/osd/ops_executer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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> pg,
Expand Down
15 changes: 8 additions & 7 deletions src/crimson/osd/osd_operations/snaptrim_event.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -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);
Expand All @@ -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);
Expand Down
2 changes: 0 additions & 2 deletions src/crimson/osd/osd_operations/snaptrim_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,6 @@ class SnapTrimObjSubEvent : public PhasedOperationT<SnapTrimObjSubEvent> {
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(
Expand Down
9 changes: 9 additions & 0 deletions src/crimson/osd/pg.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/crimson/osd/pg.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_stat_t> pg_stats;
Expand Down

0 comments on commit ca414b0

Please sign in to comment.