]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson: implement CEPH_OSD_WATCH_OP_RECONNECT.
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Wed, 27 Nov 2019 15:34:25 +0000 (16:34 +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 f26b65847c4e8fb1866c085f1942283bf00fd370..1824764718dfa68cc65bc0fce1e6abd77ee3ec6d 100644 (file)
@@ -851,6 +851,7 @@ namespace ct_error {
   using permission_denied = ct_error_code<std::errc::permission_denied>;
   using operation_not_supported =
     ct_error_code<std::errc::operation_not_supported>;
+  using not_connected = ct_error_code<std::errc::not_connected>;
 }
 
 using stateful_errc = stateful_error_t<std::errc>;
index b69583d4826c447a3a91bad6f69b136edc65d827..8c2ddc9ca70ec87a558e230b1c1f99804680a1c0 100644 (file)
@@ -163,6 +163,21 @@ OpsExecuter::watch_errorator::future<> OpsExecuter::do_op_watch_subop_watch(
     });
 }
 
+OpsExecuter::watch_errorator::future<> OpsExecuter::do_op_watch_subop_reconnect(
+  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;
+  if (!os.oi.watchers.count(std::make_pair(cookie, entity))) {
+    return crimson::ct_error::not_connected::make();
+  } else {
+    logger().info("found existing watch by {}", entity);
+    return do_op_watch_subop_watch(osd_op, os, txn);
+  }
+}
+
 OpsExecuter::watch_errorator::future<> OpsExecuter::do_op_watch_subop_unwatch(
   OSDOp& osd_op,
   ObjectState& os,
@@ -211,8 +226,7 @@ OpsExecuter::watch_errorator::future<> OpsExecuter::do_op_watch(
     case CEPH_OSD_WATCH_OP_WATCH:
       return do_op_watch_subop_watch(osd_op, os, txn);
     case CEPH_OSD_WATCH_OP_RECONNECT:
-      // TODO: implement reconnect
-      break;
+      return do_op_watch_subop_reconnect(osd_op, os, txn);
     case CEPH_OSD_WATCH_OP_PING:
       // TODO: implement ping
       break;
index d371fc6319bf7696efd6a719b5c611c23b8384f3..82385ff30480366b5a4d0fda3ec0ad7a890b163b 100644 (file)
@@ -48,7 +48,8 @@ class OpsExecuter {
   using get_attr_errorator = PGBackend::get_attr_errorator;
   using watch_errorator = crimson::errorator<
     crimson::ct_error::enoent,
-    crimson::ct_error::invarg>;
+    crimson::ct_error::invarg,
+    crimson::ct_error::not_connected>;
 
 public:
   // because OpsExecuter is pretty heavy-weight object we want to ensure
@@ -106,6 +107,10 @@ private:
     class OSDOp& osd_op,
     class ObjectState& os,
     ceph::os::Transaction& txn);
+  watch_errorator::future<> do_op_watch_subop_reconnect(
+    class OSDOp& osd_op,
+    class ObjectState& os,
+    ceph::os::Transaction& txn);
   watch_errorator::future<> do_op_watch_subop_unwatch(
     class OSDOp& osd_op,
     class ObjectState& os,