]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/pg: avoid publishing pg_stat twice in a short interval
authorxie xingguo <xie.xingguo@zte.com.cn>
Fri, 25 Mar 2016 02:56:46 +0000 (10:56 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Fri, 25 Mar 2016 14:14:21 +0000 (22:14 +0800)
Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/osd/PG.cc

index e7974df77a056231b8e712f305c65748cdc8e8e4..b3d126e7b41e0eb84063e584f66cd1428b1ed930 100644 (file)
@@ -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();
 }