Merge pull request #41708 from tchaikov/wip-seastore-open-coll

crimson/os/seastore: open_collection() returns nullptr if DNE

Reviewed-by: Samuel Just <sjust@redhat.com>
This commit is contained in:
Kefu Chai 2021-06-06 09:45:16 +08:00 committed by GitHub
commit 76d882bd6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 8 deletions

View File

@ -48,13 +48,9 @@ CollectionNode::list()
{
read_to_local();
logger().debug("CollectionNode:{}, {}", __func__, *this);
std::vector<std::pair<coll_t, coll_info_t>> list_result;
for (auto &&it : decoded) {
list_result.emplace_back(
std::make_pair(
static_cast<coll_t>(it.first),
coll_info_t{ it.second }
));
CollectionManager::list_ret_bare list_result;
for (auto &[coll, bits] : decoded) {
list_result.emplace_back(coll, bits);
}
return list_ret(
list_ertr::ready_future_marker{},

View File

@ -155,7 +155,14 @@ seastar::future<CollectionRef> SeaStore::open_collection(const coll_t& cid)
{
LOG_PREFIX(SeaStore::open_collection);
DEBUG("{}", cid);
return seastar::make_ready_future<CollectionRef>(_get_collection(cid));
return list_collections().then([cid, this] (auto colls) {
if (auto found = std::find(colls.begin(), colls.end(), cid);
found != colls.end()) {
return seastar::make_ready_future<CollectionRef>(_get_collection(cid));
} else {
return seastar::make_ready_future<CollectionRef>();
}
});
}
seastar::future<std::vector<coll_t>> SeaStore::list_collections()