From 2bebee6b37f9d6f3361999b6164bf15492bc675b Mon Sep 17 00:00:00 2001 From: Radoslaw Zarzynski Date: Tue, 30 Nov 2021 13:49:04 +0000 Subject: [PATCH] crimson/os: fix FTBFS on recent versions of Seastar. Seastar since c4516f564197da409c1e5a012bd24c35457a9a40 provides two variants of `seastar::with_lock`: - generic, friendly towards throwing move constructors of the passed callable, - specialized for `noexcept`. Unfortunately, the former has a limitation: the return value of callable must be compatible with `current_exception_as_future()` which boils down to returning `seastar::future`. Therefore we need to use the latter. The obstacle is `boost::intrusive_ptr` we use for `CollectionRef` as it has the move constructor defined without `noexcept`: ```cpp emplate class intrusive_ptr { // BOOST_CONSTEXPR intrusive_ptr() BOOST_SP_NOEXCEPT : px( 0 ) { } // ... template intrusive_ptr( intrusive_ptr const & rhs, typename boost::detail::sp_enable_if_convertible::type = boost::detail::sp_empty() ) intrusive_ptr( intrusive_ptr const & rhs ) : px( rhs.get() ) { if( px != 0 ) intrusive_ptr_add_ref( px ); } // ... intrusive_ptr(intrusive_ptr && rhs) BOOST_SP_NOEXCEPT : px( rhs.px ) { rhs.px = 0; } intrusive_ptr & operator=(intrusive_ptr && rhs) BOOST_SP_NOEXCEPT { this_type( static_cast< intrusive_ptr && >( rhs ) ).swap(*this); return *this; } ``` Signed-off-by: Radoslaw Zarzynski --- src/crimson/os/alienstore/alien_collection.h | 7 +++++++ src/crimson/os/alienstore/alien_store.cc | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/crimson/os/alienstore/alien_collection.h b/src/crimson/os/alienstore/alien_collection.h index 538db3dae66..17a930e77a9 100644 --- a/src/crimson/os/alienstore/alien_collection.h +++ b/src/crimson/os/alienstore/alien_collection.h @@ -21,6 +21,13 @@ public: template > seastar::futurize_t with_lock(Func&& func) { + // newer versions of Seastar provide two variants of `with_lock` + // - generic, friendly towards throwing move constructors of Func, + // - specialized for `noexcept`. + // unfortunately, the former has a limitation: the return value + // of `Func` must be compatible with `current_exception_as_future()` + // which boils down to returning `seastar::future`. + static_assert(std::is_nothrow_move_constructible_v); return seastar::with_lock(mutex, std::forward(func)); } diff --git a/src/crimson/os/alienstore/alien_store.cc b/src/crimson/os/alienstore/alien_store.cc index 43ff8d35415..c9c3116f81e 100644 --- a/src/crimson/os/alienstore/alien_store.cc +++ b/src/crimson/os/alienstore/alien_store.cc @@ -429,7 +429,8 @@ seastar::future<> AlienStore::do_transaction(CollectionRef ch, [this, ch, id] (auto &txn, auto &done) { return seastar::with_gate(transaction_gate, [this, ch, id, &txn, &done] { AlienCollection* alien_coll = static_cast(ch.get()); - return alien_coll->with_lock([this, ch, id, &txn, &done] { + // moving the `ch` is crucial for buildability on newer S* versions. + return alien_coll->with_lock([this, ch=std::move(ch), id, &txn, &done] { Context *crimson_wrapper = ceph::os::Transaction::collect_all_contexts(txn); assert(tp); -- 2.39.5