]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/.../alien_store: factor out get_alien_coll_ref
authorSamuel Just <sjust@redhat.com>
Wed, 10 Jul 2024 22:25:15 +0000 (15:25 -0700)
committerSamuel Just <sjust@redhat.com>
Tue, 23 Jul 2024 18:01:24 +0000 (18:01 +0000)
Signed-off-by: Samuel Just <sjust@redhat.com>
src/crimson/os/alienstore/alien_store.cc
src/crimson/os/alienstore/alien_store.h

index 2fac9a89ee4ef729604a0d83b33e12698eb63c5d..b908bebe3437b1510b42556a0c0100621ce8eecb 100644 (file)
@@ -235,19 +235,8 @@ seastar::future<CollectionRef> AlienStore::create_new_collection(const coll_t& c
   return tp->submit([this, cid] {
     return store->create_new_collection(cid);
   }).then([this, cid] (ObjectStore::CollectionHandle c) {
-    CollectionRef ch;
-    auto cp = coll_map.find(c->cid);
-    if (cp == coll_map.end()) {
-      ch = new AlienCollection(c);
-      coll_map[c->cid] = ch;
-    } else {
-      ch = cp->second;
-      auto ach = static_cast<AlienCollection*>(ch.get());
-      if (ach->collection != c) {
-        ach->collection = c;
-      }
-    }
-    return seastar::make_ready_future<CollectionRef>(ch);
+    return seastar::make_ready_future<CollectionRef>(
+      get_alien_coll_ref(std::move(c)));
   });
 
 }
@@ -262,19 +251,8 @@ seastar::future<CollectionRef> AlienStore::open_collection(const coll_t& cid)
     if (!c) {
       return seastar::make_ready_future<CollectionRef>();
     }
-    CollectionRef ch;
-    auto cp = coll_map.find(c->cid);
-    if (cp == coll_map.end()){
-      ch = new AlienCollection(c);
-      coll_map[c->cid] = ch;
-    } else {
-      ch = cp->second;
-      auto ach = static_cast<AlienCollection*>(ch.get());
-      if (ach->collection != c){
-        ach->collection = c;
-      }
-    }
-    return seastar::make_ready_future<CollectionRef>(ch);
+    return seastar::make_ready_future<CollectionRef>(
+      get_alien_coll_ref(std::move(c)));
   });
 }
 
@@ -657,4 +635,20 @@ AlienStore::read_errorator::future<std::map<uint64_t, uint64_t>> AlienStore::fie
   });
 }
 
+CollectionRef AlienStore::get_alien_coll_ref(ObjectStore::CollectionHandle c) {
+  CollectionRef ch;
+  auto cp = coll_map.find(c->cid);
+  if (cp == coll_map.end()) {
+    ch = new AlienCollection(c);
+    coll_map[c->cid] = ch;
+  } else {
+    ch = cp->second;
+    auto ach = static_cast<AlienCollection*>(ch.get());
+    if (ach->collection != c) {
+      ach->collection = c;
+    }
+  }
+  return ch;
+}
+
 }
index bf44a2b1325bafca0b157da0fbb1b07e65979a95..f679c9718919e947b5226b8ddd6dbff4cf1b412c 100644 (file)
@@ -150,5 +150,6 @@ private:
    *    are released before unmounting and stopping the store.
    */
   std::unordered_map<coll_t, CollectionRef> coll_map;
+  CollectionRef get_alien_coll_ref(ObjectStore::CollectionHandle c);
 };
 }