From 14d046fd66acf5a6aba0a2725d2117ceb4f881de Mon Sep 17 00:00:00 2001 From: Xuehan Xu Date: Thu, 25 Feb 2021 16:57:23 +0800 Subject: [PATCH] crimson/os/alienstore: improve alienstore's write parallelism replace the grand per store tp_mutex with a finer grained per-collection lock for better concurrency Signed-off-by: Xuehan Xu --- src/crimson/os/alienstore/alien_collection.h | 6 ++++++ src/crimson/os/alienstore/alien_store.cc | 4 ++-- src/crimson/os/alienstore/alien_store.h | 1 - 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/crimson/os/alienstore/alien_collection.h b/src/crimson/os/alienstore/alien_collection.h index 98b8fdef44dde..538db3dae669d 100644 --- a/src/crimson/os/alienstore/alien_collection.h +++ b/src/crimson/os/alienstore/alien_collection.h @@ -19,8 +19,14 @@ public: ~AlienCollection() {} + template > + seastar::futurize_t with_lock(Func&& func) { + return seastar::with_lock(mutex, std::forward(func)); + } + private: ObjectStore::CollectionHandle collection; + seastar::shared_mutex mutex; friend AlienStore; }; } diff --git a/src/crimson/os/alienstore/alien_store.cc b/src/crimson/os/alienstore/alien_store.cc index 8b4e666b3f68d..31b29d29acba7 100644 --- a/src/crimson/os/alienstore/alien_store.cc +++ b/src/crimson/os/alienstore/alien_store.cc @@ -363,7 +363,8 @@ seastar::future<> AlienStore::do_transaction(CollectionRef ch, std::move(done), [this, ch, id] (auto &txn, auto &done) { return seastar::with_gate(transaction_gate, [this, ch, id, &txn, &done] { - return tp_mutex.lock().then ([this, ch, id, &txn, &done] { + AlienCollection* alien_coll = static_cast(ch.get()); + return alien_coll->with_lock([this, ch, id, &txn, &done] { Context *crimson_wrapper = ceph::os::Transaction::collect_all_contexts(txn); return tp->submit([this, ch, id, crimson_wrapper, &txn, &done] { @@ -373,7 +374,6 @@ seastar::future<> AlienStore::do_transaction(CollectionRef ch, }); }).then([this, &done] (int r) { assert(r == 0); - tp_mutex.unlock(); return done.get_future(); }); }); diff --git a/src/crimson/os/alienstore/alien_store.h b/src/crimson/os/alienstore/alien_store.h index 92739340e782c..8e67d08f24ecf 100644 --- a/src/crimson/os/alienstore/alien_store.h +++ b/src/crimson/os/alienstore/alien_store.h @@ -120,6 +120,5 @@ private: std::unique_ptr cct; seastar::gate transaction_gate; std::unordered_map coll_map; - seastar::shared_mutex tp_mutex; }; } -- 2.39.5