From: Sage Weil Date: Thu, 15 Nov 2018 22:27:18 +0000 (-0600) Subject: mgr: lock pg_map too for osd_pool_stats and notify_osdmap X-Git-Tag: v12.2.13~169^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8de7c28f933af9aeb02e0953c7ba124c8455c23f;p=ceph.git mgr: lock pg_map too for osd_pool_stats and notify_osdmap Fixes: http://tracker.ceph.com/issues/36766 Signed-off-by: Sage Weil (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) --- diff --git a/src/mgr/ClusterState.cc b/src/mgr/ClusterState.cc index b727ac1867e9..f1d6065b7c88 100644 --- a/src/mgr/ClusterState.cc +++ b/src/mgr/ClusterState.cc @@ -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 diff --git a/src/mgr/Mgr.cc b/src/mgr/Mgr.cc index 1d36225acbf1..ced45ed11622 100644 --- a/src/mgr/Mgr.cc +++ b/src/mgr/Mgr.cc @@ -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;