]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/PG: do not republish unchanged pg stats 3381/head
authorSage Weil <sage@redhat.com>
Fri, 16 Jan 2015 00:56:13 +0000 (16:56 -0800)
committerSage Weil <sage@redhat.com>
Fri, 16 Jan 2015 01:12:16 +0000 (17:12 -0800)
If the PG stats have not changed, do not republish.  Note that previously
we would gratuitously update the timestamp; now we do not if there is
not significant change in the PG state or stats.

Signed-off-by: Sage Weil <sage@redhat.com>
src/osd/PG.cc

index 8980bfdb6ba0be319a97df30c1c8534a15a3ed75..866afe4393163af5e19de76a55386e917a34fd5b 100644 (file)
@@ -2356,17 +2356,12 @@ void PG::publish_stats_to_osd()
 
   pg_stats_publish_lock.Lock();
 
-  // update our stat summary
-  info.stats.reported_epoch = get_osdmap()->get_epoch();
-  ++info.stats.reported_seq;
-
   if (info.stats.stats.sum.num_scrub_errors)
     state_set(PG_STATE_INCONSISTENT);
   else
     state_clear(PG_STATE_INCONSISTENT);
 
   utime_t now = ceph_clock_now(cct);
-  info.stats.last_fresh = now;
   if (info.stats.state != state) {
     info.stats.state = state;
     info.stats.last_change = now;
@@ -2374,28 +2369,45 @@ void PG::publish_stats_to_osd()
        !(info.stats.state & PG_STATE_ACTIVE))
       info.stats.last_became_active = now;
   }
-  if (info.stats.state & PG_STATE_CLEAN)
-    info.stats.last_clean = now;
-  if (info.stats.state & PG_STATE_ACTIVE)
-    info.stats.last_active = now;
-  info.stats.last_unstale = now;
-  if ((info.stats.state & PG_STATE_DEGRADED) == 0)
-    info.stats.last_undegraded = now;
-  if ((info.stats.state & PG_STATE_UNDERSIZED) == 0)
-    info.stats.last_fullsized = now;
 
   _update_calc_stats();
   _update_blocked_by();
 
-  pg_stats_publish_valid = true;
-  pg_stats_publish = info.stats;
-  pg_stats_publish.stats.add(unstable_stats);
-
-  dout(15) << "publish_stats_to_osd " << pg_stats_publish.reported_epoch
-          << ":" << pg_stats_publish.reported_seq << dendl;
+  bool publish = false;
+  utime_t cutoff = now;
+  cutoff -= g_conf->osd_pg_stat_report_interval_max;
+  if (pg_stats_publish_valid && info.stats == pg_stats_publish &&
+      info.stats.last_fresh > cutoff) {
+    dout(15) << "publish_stats_to_osd " << pg_stats_publish.reported_epoch
+            << ": no change since" << dendl;
+  } else {
+    // update our stat summary and timestamps
+    info.stats.reported_epoch = get_osdmap()->get_epoch();
+    ++info.stats.reported_seq;
+
+    info.stats.last_fresh = now;
+    if (info.stats.state & PG_STATE_CLEAN)
+      info.stats.last_clean = now;
+    if (info.stats.state & PG_STATE_ACTIVE)
+      info.stats.last_active = now;
+    info.stats.last_unstale = now;
+    if ((info.stats.state & PG_STATE_DEGRADED) == 0)
+      info.stats.last_undegraded = now;
+    if ((info.stats.state & PG_STATE_UNDERSIZED) == 0)
+      info.stats.last_fullsized = now;
+
+    publish = true;
+    pg_stats_publish_valid = true;
+    pg_stats_publish = info.stats;
+    pg_stats_publish.stats.add(unstable_stats);
+
+    dout(15) << "publish_stats_to_osd " << pg_stats_publish.reported_epoch
+            << ":" << pg_stats_publish.reported_seq << dendl;
+  }
   pg_stats_publish_lock.Unlock();
 
-  osd->pg_stat_queue_enqueue(this);
+  if (publish)
+    osd->pg_stat_queue_enqueue(this);
 }
 
 void PG::clear_publish_stats()