]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr: lock pg_map too for osd_pool_stats and notify_osdmap
authorSage Weil <sage@redhat.com>
Thu, 15 Nov 2018 22:27:18 +0000 (16:27 -0600)
committerSage Weil <sage@redhat.com>
Fri, 16 Nov 2018 10:55:43 +0000 (04:55 -0600)
Fixes: http://tracker.ceph.com/issues/36766
Signed-off-by: Sage Weil <sage@redhat.com>
src/mgr/ActivePyModules.cc
src/mgr/ClusterState.cc
src/mgr/Mgr.cc

index 81dbe30705ce5ef3d16aa58b360a8260de2213e3..f712ec96c55dd362c09b30732550d534451302df 100644 (file)
@@ -336,15 +336,13 @@ PyObject *ActivePyModules::get_python(const std::string &what)
     int64_t poolid = -ENOENT;
     string pool_name;
     PyFormatter f;
-    cluster_state.with_pgmap([&](const PGMap& pg_map) {
-      return cluster_state.with_osdmap([&](const OSDMap& osdmap) {
+    cluster_state.with_osdmap_and_pgmap([&](const OSDMap& osdmap, const PGMap& pg_map) {
         f.open_array_section("pool_stats");
         for (auto &p : osdmap.get_pools()) {
           poolid = p.first;
           pg_map.dump_pool_stats_and_io_rate(poolid, osdmap, &f, nullptr);
         }
         f.close_section();
-      });
     });
     return f.get();
   } else if (what == "health" || what == "mon_status") {
index ed741eeecf58d6ee1641dbd804fc9167a8c19a45..41afe079b3fa629a17778bb198f688d4378ed53f 100644 (file)
@@ -135,7 +135,7 @@ void ClusterState::update_delta_stats()
 
 void ClusterState::notify_osdmap(const OSDMap &osd_map)
 {
-  std::lock_guard l(lock);
+  assert(ceph_mutex_is_locked(lock));
 
   pending_inc.stamp = ceph_clock_now();
   pending_inc.version = pg_map.version + 1; // to make apply_incremental happy
index 478a82be2f9c3fc3371a4248b8a59ccb1ebb29a1..571bc486b8af15755095768a8c172b76a9d9dedf 100644 (file)
@@ -254,7 +254,8 @@ void Mgr::init()
   lock.Lock();
 
   // Populate PGs in ClusterState
-  objecter->with_osdmap([this](const OSDMap &osd_map) {
+  cluster_state.with_osdmap_and_pgmap([this](const OSDMap &osd_map,
+                                            const PGMap& pg_map) {
     cluster_state.notify_osdmap(osd_map);
   });
 
@@ -419,7 +420,8 @@ void Mgr::handle_osd_map()
    * see if they have changed (service restart), and if so
    * reload the metadata.
    */
-  objecter->with_osdmap([this, &names_exist](const OSDMap &osd_map) {
+  cluster_state.with_osdmap_and_pgmap([this, &names_exist](const OSDMap &osd_map,
+                                                          const PGMap &pg_map) {
     for (int osd_id = 0; osd_id < osd_map.get_max_osd(); ++osd_id) {
       if (!osd_map.exists(osd_id)) {
         continue;