]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/osd: use cancellable timer to dispatch delayed events
authorYingxin Cheng <yingxin.cheng@intel.com>
Fri, 28 Feb 2020 04:22:54 +0000 (12:22 +0800)
committerYingxin Cheng <yingxin.cheng@intel.com>
Fri, 28 Feb 2020 04:22:54 +0000 (12:22 +0800)
Signed-off-by: Yingxin Cheng <yingxin.cheng@intel.com>
src/crimson/osd/pg.cc
src/crimson/osd/pg.h

index 991002b90b2075387a055208957b0d16fd29ddf9..37f7535d40656c8486f88a9f2aa6b6d5ddf696e2 100644 (file)
@@ -13,7 +13,6 @@
 #include <boost/range/numeric.hpp>
 #include <fmt/format.h>
 #include <fmt/ostream.h>
-#include <seastar/core/sleep.hh>
 
 #include "messages/MOSDOp.h"
 #include "messages/MOSDOpReply.h"
@@ -141,7 +140,8 @@ bool PG::try_flush_or_schedule_async() {
 void PG::queue_check_readable(epoch_t last_peering_reset, ceph::timespan delay)
 {
   // handle the peering event in the background
-  std::ignore = seastar::sleep(delay).then([last_peering_reset, this] {
+  check_readable_timer.cancel();
+  check_readable_timer.set_callback([last_peering_reset, this] {
     shard_services.start_operation<LocalPeeringEvent>(
       this,
       shard_services,
@@ -151,6 +151,8 @@ void PG::queue_check_readable(epoch_t last_peering_reset, ceph::timespan delay)
       last_peering_reset,
       PeeringState::CheckReadable{});
     });
+  check_readable_timer.arm(
+    std::chrono::duration_cast<seastar::lowres_clock::duration>(delay));
 }
 
 void PG::recheck_readable()
@@ -329,7 +331,8 @@ HeartbeatStampsRef PG::get_hb_stamps(int peer)
 void PG::schedule_renew_lease(epoch_t last_peering_reset, ceph::timespan delay)
 {
   // handle the peering event in the background
-  std::ignore = seastar::sleep(delay).then([last_peering_reset, this] {
+  renew_lease_timer.cancel();
+  renew_lease_timer.set_callback([last_peering_reset, this] {
     shard_services.start_operation<LocalPeeringEvent>(
       this,
       shard_services,
@@ -339,6 +342,8 @@ void PG::schedule_renew_lease(epoch_t last_peering_reset, ceph::timespan delay)
       last_peering_reset,
       RenewLease{});
     });
+  renew_lease_timer.arm(
+    std::chrono::duration_cast<seastar::lowres_clock::duration>(delay));
 }
 
 
index 1ced9b22e77d94568a5c790dd94ccf5a64935015..781958f3074b380aee1d1da1cbb2422ed29cdede 100644 (file)
@@ -62,6 +62,10 @@ class PG : public boost::intrusive_ref_counter<
   pg_shard_t pg_whoami;
   crimson::os::CollectionRef coll_ref;
   ghobject_t pgmeta_oid;
+
+  seastar::timer<seastar::lowres_clock> check_readable_timer;
+  seastar::timer<seastar::lowres_clock> renew_lease_timer;
+
 public:
   PG(spg_t pgid,
      pg_shard_t pg_shard,