]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os: fix FTBFS on recent versions of Seastar.
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Tue, 30 Nov 2021 13:49:04 +0000 (13:49 +0000)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Tue, 30 Nov 2021 14:27:30 +0000 (14:27 +0000)
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<void>`. 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 T> class intrusive_ptr
{
    //
    BOOST_CONSTEXPR intrusive_ptr() BOOST_SP_NOEXCEPT : px( 0 )
    {
    }

    // ...

    template<class U>

    intrusive_ptr( intrusive_ptr<U> const & rhs, typename boost::detail::sp_enable_if_convertible<U,T>::type = boost::detail::sp_empty() )

    intrusive_ptr( intrusive_ptr<U> 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 <rzarzyns@redhat.com>
src/crimson/os/alienstore/alien_collection.h
src/crimson/os/alienstore/alien_store.cc

index 538db3dae669d29c63092ca5668e88b009b05338..17a930e77a944c774d3b8cbe4e341ae516e27971 100644 (file)
@@ -21,6 +21,13 @@ public:
 
   template <typename Func, typename Result = std::invoke_result_t<Func>>
   seastar::futurize_t<Result> 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<void>`.
+    static_assert(std::is_nothrow_move_constructible_v<Func>);
     return seastar::with_lock(mutex, std::forward<Func>(func));
   }
 
index 43ff8d354154edb6a65249714189472c38256b74..c9c3116f81e02028c741cb7dca6b7a585f0eb481 100644 (file)
@@ -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<AlienCollection*>(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);