From c6a4f34940eda641f582b6c30143a774ef1be928 Mon Sep 17 00:00:00 2001 From: xie xingguo Date: Fri, 25 Mar 2016 10:56:46 +0800 Subject: [PATCH] osd/pg: avoid publishing pg_stat twice in a short interval Signed-off-by: xie xingguo --- src/osd/PG.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/osd/PG.cc b/src/osd/PG.cc index e7974df77a056..b3d126e7b41e0 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -6621,6 +6621,7 @@ boost::statechart::result PG::RecoveryState::Active::react(const AdvMap& advmap) } } + bool need_publish = false; /* Check for changes in pool size (if the acting set changed as a result, * this does not matter) */ if (advmap.lastmap->get_pg_size(pg->info.pgid.pgid) != @@ -6636,16 +6637,19 @@ boost::statechart::result PG::RecoveryState::Active::react(const AdvMap& advmap) pg->state_set(PG_STATE_UNDERSIZED); pg->state_set(PG_STATE_DEGRADED); } - pg->publish_stats_to_osd(); // degraded may have changed + need_publish = true; // degraded may have changed } // if we haven't reported our PG stats in a long time, do so now. if (pg->info.stats.reported_epoch + pg->cct->_conf->osd_pg_stat_report_interval_max < advmap.osdmap->get_epoch()) { dout(20) << "reporting stats to osd after " << (advmap.osdmap->get_epoch() - pg->info.stats.reported_epoch) << " epochs" << dendl; - pg->publish_stats_to_osd(); + need_publish = true; } + if (need_publish) + pg->publish_stats_to_osd(); + return forward_event(); } -- 2.39.5