]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.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)
committerxie xingguo <xie.xingguo@zte.com.cn>
Sun, 28 Apr 2019 10:14:50 +0000 (18:14 +0800)
Fixes: http://tracker.ceph.com/issues/36766
Signed-off-by: Sage Weil <sage@redhat.com>
(cherry picked from commit 03a761c980a1171fe6adf7a463f3ab80ec6d4052)

Conflicts:
src/mgr/ActivePyModules.cc: migrate 'osd pool stats' command from mon to mgr (007eae7dd)
src/mgr/ClusterState.cc: Mutex::Locker -> std::lock_guard(948635a8)
src/mgr/Mgr.cc: silence warning from -Wsign-compare(a38ad971)

src/mgr/ClusterState.cc
src/mgr/Mgr.cc

index b727ac1867e96ebd1279eadc66900b3652e2a623..f1d6065b7c88e9efba651379e4f54c60ccbf516b 100644 (file)
@@ -126,7 +126,7 @@ void ClusterState::update_delta_stats()
 
 void ClusterState::notify_osdmap(const OSDMap &osd_map)
 {
-  Mutex::Locker l(lock);
+  assert(lock.is_locked_by_me());
 
   pending_inc.stamp = ceph_clock_now();
   pending_inc.version = pg_map.version + 1; // to make apply_incremental happy
index 1d36225acbf1c9f639ba01075173600165939aa5..ced45ed11622c2f526f90f27ab8853b158f4eb99 100644 (file)
@@ -195,7 +195,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);
   });
 
@@ -387,7 +388,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 (unsigned int osd_id = 0; osd_id < osd_map.get_max_osd(); ++osd_id) {
       if (!osd_map.exists(osd_id)) {
         continue;