From: Samuel Just Date: Wed, 10 Jul 2024 22:25:15 +0000 (-0700) Subject: crimson/.../alien_store: factor out get_alien_coll_ref X-Git-Tag: v20.0.0~1426^2~3 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=618bef54243cc6628bf7ea68318b6c568516d1cd;p=ceph.git crimson/.../alien_store: factor out get_alien_coll_ref Signed-off-by: Samuel Just --- diff --git a/src/crimson/os/alienstore/alien_store.cc b/src/crimson/os/alienstore/alien_store.cc index 2fac9a89ee4ef..b908bebe3437b 100644 --- a/src/crimson/os/alienstore/alien_store.cc +++ b/src/crimson/os/alienstore/alien_store.cc @@ -235,19 +235,8 @@ seastar::future 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(ch.get()); - if (ach->collection != c) { - ach->collection = c; - } - } - return seastar::make_ready_future(ch); + return seastar::make_ready_future( + get_alien_coll_ref(std::move(c))); }); } @@ -262,19 +251,8 @@ seastar::future AlienStore::open_collection(const coll_t& cid) if (!c) { return seastar::make_ready_future(); } - 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(ch.get()); - if (ach->collection != c){ - ach->collection = c; - } - } - return seastar::make_ready_future(ch); + return seastar::make_ready_future( + get_alien_coll_ref(std::move(c))); }); } @@ -657,4 +635,20 @@ AlienStore::read_errorator::future> 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(ch.get()); + if (ach->collection != c) { + ach->collection = c; + } + } + return ch; +} + } diff --git a/src/crimson/os/alienstore/alien_store.h b/src/crimson/os/alienstore/alien_store.h index bf44a2b1325ba..f679c9718919e 100644 --- a/src/crimson/os/alienstore/alien_store.h +++ b/src/crimson/os/alienstore/alien_store.h @@ -150,5 +150,6 @@ private: * are released before unmounting and stopping the store. */ std::unordered_map coll_map; + CollectionRef get_alien_coll_ref(ObjectStore::CollectionHandle c); }; }