]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: don't check for primary when updating pg's dynamic perf stats queries
authorMykola Golub <mgolub@suse.com>
Wed, 18 Sep 2019 14:22:53 +0000 (15:22 +0100)
committerMykola Golub <mgolub@suse.com>
Wed, 18 Sep 2019 14:25:43 +0000 (15:25 +0100)
Otherwise situation could be possible when a query is not reset
for a pg because it is not primary at that moment and later the
stats for non-existing query is tried to be added to the report.

Fixes: https://tracker.ceph.com/issues/41891
Signed-off-by: Mykola Golub <mgolub@suse.com>
src/osd/OSD.cc

index 96aed0b706e308d3a9e8776f0f7538f3abed4786..3fbc79a100c883eda04833f8335f93fbaa09fff6 100644 (file)
@@ -10285,10 +10285,8 @@ void OSD::set_perf_queries(
   std::vector<PGRef> pgs;
   _get_pgs(&pgs);
   for (auto& pg : pgs) {
-    if (pg->is_primary()) {
-      std::scoped_lock l{*pg};
-      pg->set_dynamic_perf_stats_queries(supported_queries);
-    }
+    std::scoped_lock l{*pg};
+    pg->set_dynamic_perf_stats_queries(supported_queries);
   }
 }
 
@@ -10298,17 +10296,15 @@ void OSD::get_perf_reports(
   _get_pgs(&pgs);
   DynamicPerfStats dps;
   for (auto& pg : pgs) {
-    if (pg->is_primary()) {
-      // m_perf_queries can be modified only in set_perf_queries by mgr client
-      // request, and it is protected by by mgr client's lock, which is held
-      // when set_perf_queries/get_perf_reports are called, so we may not hold
-      // m_perf_queries_lock here.
-      DynamicPerfStats pg_dps(m_perf_queries);
-      pg->lock();
-      pg->get_dynamic_perf_stats(&pg_dps);
-      pg->unlock();
-      dps.merge(pg_dps);
-    }
+    // m_perf_queries can be modified only in set_perf_queries by mgr client
+    // request, and it is protected by by mgr client's lock, which is held
+    // when set_perf_queries/get_perf_reports are called, so we may not hold
+    // m_perf_queries_lock here.
+    DynamicPerfStats pg_dps(m_perf_queries);
+    pg->lock();
+    pg->get_dynamic_perf_stats(&pg_dps);
+    pg->unlock();
+    dps.merge(pg_dps);
   }
   dps.add_to_reports(m_perf_limits, reports);
   dout(20) << "reports for " << reports->size() << " queries" << dendl;