From 03a761c980a1171fe6adf7a463f3ab80ec6d4052 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 15 Nov 2018 16:27:18 -0600 Subject: [PATCH] mgr: lock pg_map too for osd_pool_stats and notify_osdmap Fixes: http://tracker.ceph.com/issues/36766 Signed-off-by: Sage Weil --- src/mgr/ActivePyModules.cc | 4 +--- src/mgr/ClusterState.cc | 2 +- src/mgr/Mgr.cc | 6 ++++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/mgr/ActivePyModules.cc b/src/mgr/ActivePyModules.cc index 81dbe30705ce5..f712ec96c55dd 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 ed741eeecf58d..41afe079b3fa6 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 478a82be2f9c3..571bc486b8af1 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; -- 2.39.5