]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/osd: keep ClientRequest alive during `seastar::repeat()` 39743/head
authorKefu Chai <kchai@redhat.com>
Sun, 28 Feb 2021 05:23:29 +0000 (13:23 +0800)
committerKefu Chai <kchai@redhat.com>
Sun, 28 Feb 2021 06:06:05 +0000 (14:06 +0800)
before this change, `this` is wrapped by a smart pointer which is
in turn captured by multiple continuations. the continuation with the
longest life cycle is the one passed to `seastar::repeat()`. where
the underlying `repeater` captures the continuation as its member variable.
and `repeater` is not destroyed before `seastar::repeat()` returns.

so, we only need to capture `opref` in the continuation passed to
`seastar::repeat()`.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/crimson/osd/osd_operations/client_request.cc

index 1f59a907080ff01a83ead2204e4a5fde8b991a31..7b7493e4f1c15272443b15056105a5b800eb112b 100644 (file)
@@ -65,24 +65,23 @@ seastar::future<> ClientRequest::start()
 {
   logger().debug("{}: start", *this);
 
-  IRef opref = this;
   return crimson::common::handle_system_shutdown(
-    [this, opref=std::move(opref)]() mutable {
-    return seastar::repeat([this, opref]() mutable {
+    [this, opref=IRef{this}]() mutable {
+    return seastar::repeat([this, opref=std::move(opref)]() mutable {
       logger().debug("{}: in repeat", *this);
       return with_blocking_future(handle.enter(cp().await_map))
-      .then([this]() {
+      .then([this] {
        return with_blocking_future(osd.osdmap_gate.wait_for_map(m->get_min_epoch()));
       }).then([this](epoch_t epoch) {
        return with_blocking_future(handle.enter(cp().get_pg));
       }).then([this] {
        return with_blocking_future(osd.wait_for_pg(m->get_spg()));
-      }).then([this, opref](Ref<PG> pgref) mutable {
+      }).then([this](Ref<PG> pgref) mutable {
        epoch_t same_interval_since = pgref->get_interval_start_epoch();
        logger().debug("{} same_interval_since: {}", *this, same_interval_since);
        return sequencer.start_op(
-         handle, prev_op_id, opref->get_id(),
-         [this, opref, pgref] {
+         handle, prev_op_id, get_id(),
+         [this, pgref] {
          PG &pg = *pgref;
          if (pg.can_discard_op(*m)) {
            logger().debug("{} op discarded, {}, same_primary_since: {}",