Skip to content

Commit 618bef5

Browse files
committed
crimson/.../alien_store: factor out get_alien_coll_ref
Signed-off-by: Samuel Just <[email protected]>
1 parent 443040b commit 618bef5

File tree

2 files changed

+21
-26
lines changed

2 files changed

+21
-26
lines changed

src/crimson/os/alienstore/alien_store.cc

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -235,19 +235,8 @@ seastar::future<CollectionRef> AlienStore::create_new_collection(const coll_t& c
235235
return tp->submit([this, cid] {
236236
return store->create_new_collection(cid);
237237
}).then([this, cid] (ObjectStore::CollectionHandle c) {
238-
CollectionRef ch;
239-
auto cp = coll_map.find(c->cid);
240-
if (cp == coll_map.end()) {
241-
ch = new AlienCollection(c);
242-
coll_map[c->cid] = ch;
243-
} else {
244-
ch = cp->second;
245-
auto ach = static_cast<AlienCollection*>(ch.get());
246-
if (ach->collection != c) {
247-
ach->collection = c;
248-
}
249-
}
250-
return seastar::make_ready_future<CollectionRef>(ch);
238+
return seastar::make_ready_future<CollectionRef>(
239+
get_alien_coll_ref(std::move(c)));
251240
});
252241

253242
}
@@ -262,19 +251,8 @@ seastar::future<CollectionRef> AlienStore::open_collection(const coll_t& cid)
262251
if (!c) {
263252
return seastar::make_ready_future<CollectionRef>();
264253
}
265-
CollectionRef ch;
266-
auto cp = coll_map.find(c->cid);
267-
if (cp == coll_map.end()){
268-
ch = new AlienCollection(c);
269-
coll_map[c->cid] = ch;
270-
} else {
271-
ch = cp->second;
272-
auto ach = static_cast<AlienCollection*>(ch.get());
273-
if (ach->collection != c){
274-
ach->collection = c;
275-
}
276-
}
277-
return seastar::make_ready_future<CollectionRef>(ch);
254+
return seastar::make_ready_future<CollectionRef>(
255+
get_alien_coll_ref(std::move(c)));
278256
});
279257
}
280258

@@ -657,4 +635,20 @@ AlienStore::read_errorator::future<std::map<uint64_t, uint64_t>> AlienStore::fie
657635
});
658636
}
659637

638+
CollectionRef AlienStore::get_alien_coll_ref(ObjectStore::CollectionHandle c) {
639+
CollectionRef ch;
640+
auto cp = coll_map.find(c->cid);
641+
if (cp == coll_map.end()) {
642+
ch = new AlienCollection(c);
643+
coll_map[c->cid] = ch;
644+
} else {
645+
ch = cp->second;
646+
auto ach = static_cast<AlienCollection*>(ch.get());
647+
if (ach->collection != c) {
648+
ach->collection = c;
649+
}
650+
}
651+
return ch;
652+
}
653+
660654
}

src/crimson/os/alienstore/alien_store.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,5 +150,6 @@ class AlienStore final : public FuturizedStore,
150150
* are released before unmounting and stopping the store.
151151
*/
152152
std::unordered_map<coll_t, CollectionRef> coll_map;
153+
CollectionRef get_alien_coll_ref(ObjectStore::CollectionHandle c);
153154
};
154155
}

0 commit comments

Comments
 (0)