Skip to content

Commit 8389471

Browse files
committed
crimson/.../alien_store: access coll_map under coll_map_lock
Fixes: https://tracker.ceph.com/issues/66294 Signed-off-by: Samuel Just <[email protected]>
1 parent 924384f commit 8389471

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/crimson/os/alienstore/alien_store.cc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,13 @@ seastar::future<> AlienStore::stop()
128128
return seastar::now();
129129
}
130130
return tp->submit([this] {
131-
for (auto [cid, ch]: coll_map) {
132-
static_cast<AlienCollection*>(ch.get())->collection.reset();
131+
{
132+
std::lock_guard l(coll_map_lock);
133+
for (auto [cid, ch]: coll_map) {
134+
static_cast<AlienCollection*>(ch.get())->collection.reset();
135+
}
136+
coll_map.clear();
133137
}
134-
coll_map.clear();
135138
store.reset();
136139
cct.reset();
137140
g_ceph_context = nullptr;
@@ -633,6 +636,7 @@ AlienStore::read_errorator::future<std::map<uint64_t, uint64_t>> AlienStore::fie
633636
}
634637

635638
CollectionRef AlienStore::get_alien_coll_ref(ObjectStore::CollectionHandle c) {
639+
std::lock_guard l(coll_map_lock);
636640
CollectionRef ch;
637641
auto cp = coll_map.find(c->cid);
638642
if (cp == coll_map.end()) {

src/crimson/os/alienstore/alien_store.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,10 @@ class AlienStore final : public FuturizedStore,
149149
* 2. OSD shutdown needs to *guarantee* that all outstanding CollectionRefs
150150
* are released before unmounting and stopping the store.
151151
*
152-
* coll_map is accessed exclusively from alien threadpool threads.
152+
* coll_map is accessed exclusively from alien threadpool threads under the
153+
* coll_map_lock.
153154
*/
155+
std::mutex coll_map_lock;
154156
std::unordered_map<coll_t, CollectionRef> coll_map;
155157
CollectionRef get_alien_coll_ref(ObjectStore::CollectionHandle c);
156158
};

0 commit comments

Comments
 (0)