]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/PG: avoid most of publish_stats_to_osd for non-primary
authorSage Weil <sage@redhat.com>
Fri, 16 Jan 2015 00:41:22 +0000 (16:41 -0800)
committerSage Weil <sage@redhat.com>
Fri, 16 Jan 2015 01:12:15 +0000 (17:12 -0800)
No need to take the lock in the non-primary case.  Just make sure we reset
the valid flag so that it is always false on a non-primary.

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

index 8cc4e4eda3e75a0c362382b0352fddf65d15de69..8980bfdb6ba0be319a97df30c1c8534a15a3ed75 100644 (file)
@@ -2351,53 +2351,51 @@ void PG::_update_blocked_by()
 
 void PG::publish_stats_to_osd()
 {
+  if (!is_primary())
+    return;
+
   pg_stats_publish_lock.Lock();
-  if (is_primary()) {
-    // 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;
-      if ((state & PG_STATE_ACTIVE) &&
-         !(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;
-  } else {
-    pg_stats_publish_valid = false;
-    dout(15) << "publish_stats_to_osd -- not primary" << dendl;
-  }
+  // 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;
+    if ((state & PG_STATE_ACTIVE) &&
+       !(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;
   pg_stats_publish_lock.Unlock();
 
-  if (is_primary())
-    osd->pg_stat_queue_enqueue(this);
+  osd->pg_stat_queue_enqueue(this);
 }
 
 void PG::clear_publish_stats()
@@ -4636,6 +4634,10 @@ void PG::start_peering_interval(
     info.stats.mapping_epoch = info.history.same_interval_since;
   }
 
+  pg_stats_publish_lock.Lock();
+  pg_stats_publish_valid = false;
+  pg_stats_publish_lock.Unlock();
+
   // This will now be remapped during a backfill in cases
   // that it would not have been before.
   if (up != acting)