]> 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>
Mon, 30 Sep 2019 12:44:00 +0000 (15:44 +0300)
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>
(cherry picked from commit 21103c9bbe13328e2d12f8aa62eb7239126c271c)

Conflicts:
src/osd/OSD.cc (std::scoped_lock in master vs pg->lock() in nautilus)

src/osd/OSD.cc

index 5255cfc843f68b6fe02e1b792b1bdef84e3e8e54..889d735ce7479cf2d716f9b6588cb1b96ecc55bf 100644 (file)
@@ -10308,11 +10308,9 @@ void OSD::set_perf_queries(
   std::vector<PGRef> pgs;
   _get_pgs(&pgs);
   for (auto& pg : pgs) {
-    if (pg->is_primary()) {
-      pg->lock();
-      pg->set_dynamic_perf_stats_queries(supported_queries);
-      pg->unlock();
-    }
+    pg->lock();
+    pg->set_dynamic_perf_stats_queries(supported_queries);
+    pg->unlock();
   }
 }
 
@@ -10322,17 +10320,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;