]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/.../alien_store: access coll_map under coll_map_lock 58766/head
authorSamuel Just <sjust@redhat.com>
Wed, 10 Jul 2024 22:58:55 +0000 (22:58 +0000)
committerSamuel Just <sjust@redhat.com>
Tue, 23 Jul 2024 18:01:24 +0000 (18:01 +0000)
Fixes: https://tracker.ceph.com/issues/66294
Signed-off-by: Samuel Just <sjust@redhat.com>
src/crimson/os/alienstore/alien_store.cc
src/crimson/os/alienstore/alien_store.h

index 70adef110eb1ff998af172e91f71b9168c3342e6..03359ed80244eb61b42470fe82dcd008bc58481e 100644 (file)
@@ -128,10 +128,13 @@ seastar::future<> AlienStore::stop()
     return seastar::now();
   }
   return tp->submit([this] {
-    for (auto [cid, ch]: coll_map) {
-      static_cast<AlienCollection*>(ch.get())->collection.reset();
+    {
+      std::lock_guard l(coll_map_lock);
+      for (auto [cid, ch]: coll_map) {
+       static_cast<AlienCollection*>(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<std::map<uint64_t, uint64_t>> 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()) {
index ef464743c7e5fe160c8d0c9b6450370ae7fcfce2..734ee1609596c0507d27a2ea0e9e760a64ad5c54 100644 (file)
@@ -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_t, CollectionRef> coll_map;
   CollectionRef get_alien_coll_ref(ObjectStore::CollectionHandle c);
 };