]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson: implement CEPH_OSD_WATCH_OP_PING.
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Wed, 27 Nov 2019 16:22:53 +0000 (17:22 +0100)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Thu, 13 Feb 2020 23:11:38 +0000 (00:11 +0100)
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
src/crimson/common/errorator.h
src/crimson/osd/ops_executer.cc
src/crimson/osd/ops_executer.h

index 1824764718dfa68cc65bc0fce1e6abd77ee3ec6d..e8a8ab689798ff072edefd1a090fa65cb50a3fbd 100644 (file)
@@ -852,6 +852,7 @@ namespace ct_error {
   using operation_not_supported =
     ct_error_code<std::errc::operation_not_supported>;
   using not_connected = ct_error_code<std::errc::not_connected>;
+  using timed_out = ct_error_code<std::errc::timed_out>;
 }
 
 using stateful_errc = stateful_error_t<std::errc>;
index 8c2ddc9ca70ec87a558e230b1c1f99804680a1c0..7d7cc400453ee1a480e6b0856bdf853e78bd5dc3 100644 (file)
@@ -214,6 +214,30 @@ OpsExecuter::watch_errorator::future<> OpsExecuter::do_op_watch_subop_unwatch(
     });
 }
 
+OpsExecuter::watch_errorator::future<> OpsExecuter::do_op_watch_subop_ping(
+  OSDOp& osd_op,
+  ObjectState& os,
+  ceph::os::Transaction& txn)
+{
+  const entity_name_t& entity = get_message().get_reqid().name;
+  const auto& cookie = osd_op.op.watch.cookie;
+  const auto key = std::make_pair(cookie, entity);
+
+  // Note: WATCH with PING doesn't cause may_write() to return true,
+  // so if there is nothing else in the transaction, this is going
+  // to run do_osd_op_effects, but not write out a log entry */
+  if (!os.oi.watchers.count(key)) {
+    return crimson::ct_error::not_connected::make();
+  }
+  auto it = obc->watchers.find(key);
+  if (it == std::end(obc->watchers) || !it->second->is_connected()) {
+    return crimson::ct_error::timed_out::make();
+  }
+  logger().info("found existing watch by {}", entity);
+  it->second->got_ping(ceph_clock_now());
+  return seastar::now();
+}
+
 OpsExecuter::watch_errorator::future<> OpsExecuter::do_op_watch(
   OSDOp& osd_op,
   ObjectState& os,
@@ -228,8 +252,7 @@ OpsExecuter::watch_errorator::future<> OpsExecuter::do_op_watch(
     case CEPH_OSD_WATCH_OP_RECONNECT:
       return do_op_watch_subop_reconnect(osd_op, os, txn);
     case CEPH_OSD_WATCH_OP_PING:
-      // TODO: implement ping
-      break;
+      return do_op_watch_subop_ping(osd_op, os, txn);
     case CEPH_OSD_WATCH_OP_UNWATCH:
       return do_op_watch_subop_unwatch(osd_op, os, txn);
     case CEPH_OSD_WATCH_OP_LEGACY_WATCH:
index 82385ff30480366b5a4d0fda3ec0ad7a890b163b..8f286262550fad80683b4771ef092633c2d4861d 100644 (file)
@@ -49,7 +49,8 @@ class OpsExecuter {
   using watch_errorator = crimson::errorator<
     crimson::ct_error::enoent,
     crimson::ct_error::invarg,
-    crimson::ct_error::not_connected>;
+    crimson::ct_error::not_connected,
+    crimson::ct_error::timed_out>;
 
 public:
   // because OpsExecuter is pretty heavy-weight object we want to ensure
@@ -115,6 +116,10 @@ private:
     class OSDOp& osd_op,
     class ObjectState& os,
     ceph::os::Transaction& txn);
+  watch_errorator::future<> do_op_watch_subop_ping(
+    class OSDOp& osd_op,
+    class ObjectState& os,
+    ceph::os::Transaction& txn);
 
   hobject_t &get_target() const {
     return obc->obs.oi.soid;