Skip to content

Commit

Permalink
crimson/os/seastore: open_collection() returns nullptr if DNE
Browse files Browse the repository at this point in the history
we check for the existence of meta collection by trying to open it,
if it exists, we continue check for the superblock stored in it, if
the superblock does not exist or corrupted, we consider it as a failure.

before this change, open_collection() always return a valud Collection
even if the store does not have the collection with specified cid. this
behavior could be misleading in the use case above.

after this change, open_collection() looks up the collections stored in
root collection node for the specfied cid, and return nullptr if it does
not exist.

Signed-off-by: Kefu Chai <kchai@redhat.com>
  • Loading branch information
tchaikov committed Jun 5, 2021
1 parent ca48d1c commit 9fbd601
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/crimson/os/seastore/seastore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 9fbd601

Please sign in to comment.