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: v14.1.0~902^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=03a761c980a1171fe6adf7a463f3ab80ec6d4052;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 --- diff --git a/src/mgr/ActivePyModules.cc b/src/mgr/ActivePyModules.cc index 81dbe30705ce..f712ec96c55d 100644 --- a/src/mgr/ActivePyModules.cc +++ b/src/mgr/ActivePyModules.cc @@ -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") { diff --git a/src/mgr/ClusterState.cc b/src/mgr/ClusterState.cc index ed741eeecf58..41afe079b3fa 100644 --- a/src/mgr/ClusterState.cc +++ b/src/mgr/ClusterState.cc @@ -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 diff --git a/src/mgr/Mgr.cc b/src/mgr/Mgr.cc index 478a82be2f9c..571bc486b8af 100644 --- a/src/mgr/Mgr.cc +++ b/src/mgr/Mgr.cc @@ -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;