]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/osd: implement CEPH_OSD_OP_LIST_WATCHERS. 42917/head
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Wed, 25 Aug 2021 10:36:00 +0000 (10:36 +0000)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Wed, 25 Aug 2021 10:36:11 +0000 (10:36 +0000)
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
src/crimson/osd/ops_executer.cc
src/crimson/osd/ops_executer.h

index c0d2e7f3e9669d26e356a58f52756cc89a2a0ca1..56db254911451e1bba12ab592df6392af8d9df9c 100644 (file)
@@ -364,6 +364,25 @@ OpsExecuter::watch_ierrorator::future<> OpsExecuter::do_op_notify(
   });
 }
 
+OpsExecuter::watch_ierrorator::future<> OpsExecuter::do_op_list_watchers(
+  OSDOp& osd_op,
+  const ObjectState& os)
+{
+  logger().debug("{}", __func__);
+
+  obj_list_watch_response_t response;
+  for (const auto& [key, info] : os.oi.watchers) {
+    logger().debug("{}: key cookie={}, entity={}",
+                   __func__, key.first, key.second);
+    assert(key.first == info.cookie);
+    assert(key.second.is_client());
+    response.entries.emplace_back(watch_item_t{
+      key.second, info.cookie, info.timeout_seconds, info.addr});
+    response.encode(osd_op.outdata, get_message().get_features());
+  }
+  return watch_ierrorator::now();
+}
+
 OpsExecuter::watch_ierrorator::future<> OpsExecuter::do_op_notify_ack(
   OSDOp& osd_op,
   const ObjectState& os)
@@ -576,6 +595,10 @@ OpsExecuter::execute_op(OSDOp& osd_op)
     return do_write_op([this, &osd_op] (auto& backend, auto& os, auto& txn) {
       return do_op_watch(osd_op, os, txn);
     }, false);
+  case CEPH_OSD_OP_LIST_WATCHERS:
+    return do_read_op([this, &osd_op] (auto&, const auto& os) {
+      return do_op_list_watchers(osd_op, os);
+    });
   case CEPH_OSD_OP_NOTIFY:
     return do_read_op([this, &osd_op] (auto&, const auto& os) {
       return do_op_notify(osd_op, os);
index c84b9b87965299a6e1014b519d169b56b22027bd..bc97e1daee5f35b45583eb87e518304222b60130 100644 (file)
@@ -196,6 +196,9 @@ private:
     OSDOp& osd_op,
     ObjectState& os,
     ceph::os::Transaction& txn);
+  watch_ierrorator::future<> do_op_list_watchers(
+    OSDOp& osd_op,
+    const ObjectState& os);
   watch_ierrorator::future<> do_op_notify(
     OSDOp& osd_op,
     const ObjectState& os);