From 99ea3f65f3c1b40c1b1c295f7f213943326cbb55 Mon Sep 17 00:00:00 2001 From: Samuel Just Date: Wed, 10 Jul 2024 22:58:55 +0000 Subject: [PATCH] crimson/.../alien_store: access coll_map under coll_map_lock Fixes: https://tracker.ceph.com/issues/66294 Signed-off-by: Samuel Just (cherry picked from commit 8389471b3a9a4f3ff78a787c952bd6afd125bacf) --- src/crimson/os/alienstore/alien_store.cc | 10 +++++++--- src/crimson/os/alienstore/alien_store.h | 4 +++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/crimson/os/alienstore/alien_store.cc b/src/crimson/os/alienstore/alien_store.cc index 70adef110eb..03359ed8024 100644 --- a/src/crimson/os/alienstore/alien_store.cc +++ b/src/crimson/os/alienstore/alien_store.cc @@ -128,10 +128,13 @@ seastar::future<> AlienStore::stop() return seastar::now(); } return tp->submit([this] { - for (auto [cid, ch]: coll_map) { - static_cast(ch.get())->collection.reset(); + { + std::lock_guard l(coll_map_lock); + for (auto [cid, ch]: coll_map) { + static_cast(ch.get())->collection.reset(); + } + coll_map.clear(); } - coll_map.clear(); store.reset(); cct.reset(); g_ceph_context = nullptr; @@ -633,6 +636,7 @@ AlienStore::read_errorator::future> AlienStore::fie } CollectionRef AlienStore::get_alien_coll_ref(ObjectStore::CollectionHandle c) { + std::lock_guard l(coll_map_lock); CollectionRef ch; auto cp = coll_map.find(c->cid); if (cp == coll_map.end()) { diff --git a/src/crimson/os/alienstore/alien_store.h b/src/crimson/os/alienstore/alien_store.h index ef464743c7e..734ee160959 100644 --- a/src/crimson/os/alienstore/alien_store.h +++ b/src/crimson/os/alienstore/alien_store.h @@ -149,8 +149,10 @@ private: * 2. OSD shutdown needs to *guarantee* that all outstanding CollectionRefs * are released before unmounting and stopping the store. * - * coll_map is accessed exclusively from alien threadpool threads. + * coll_map is accessed exclusively from alien threadpool threads under the + * coll_map_lock. */ + std::mutex coll_map_lock; std::unordered_map coll_map; CollectionRef get_alien_coll_ref(ObjectStore::CollectionHandle c); }; -- 2.39.5