]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/osd: implement watcher blocklisting
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Tue, 16 Aug 2022 14:34:23 +0000 (14:34 +0000)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Thu, 27 Apr 2023 15:37:01 +0000 (15:37 +0000)
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
src/crimson/osd/pg.cc
src/crimson/osd/pg.h
src/crimson/osd/watch.cc
src/crimson/osd/watch.h

index 4bf9b1ba525d742eeed1b0982b62ecc737a22bb1..13e87652671b40e69ffe3c9c30fab7fa3d777ea7 100644 (file)
@@ -164,6 +164,24 @@ PG::PG(
 
 PG::~PG() {}
 
+void PG::check_blocklisted_watchers()
+{
+  logger().debug("{}", __func__);
+  obc_registry.for_each([this](ObjectContextRef obc) {
+    assert(obc);
+    for (const auto& [key, watch] : obc->watchers) {
+      assert(watch->get_pg() == this);
+      const auto& ea = watch->get_peer_addr();
+      logger().debug("watch: Found {} cookie {}. Checking entity_add_t {}",
+                     watch->get_entity(), watch->get_cookie(), ea);
+      if (get_osdmap()->is_blocklisted(ea)) {
+        logger().info("watch: Found blocklisted watcher for {}", ea);
+        watch->do_watch_timeout();
+      }
+    }
+  });
+}
+
 bool PG::try_flush_or_schedule_async() {
   logger().debug("PG::try_flush_or_schedule_async: flush ...");
   (void)shard_services.get_store().flush(
index 54e16348f1735e43861277dc3a5d2a9ab8848fd6..3a749df512c9a5494ea1883babe4156d0a009076 100644 (file)
@@ -298,9 +298,7 @@ public:
   void check_recovery_sources(const OSDMapRef& newmap) final {
     // Not needed yet
   }
-  void check_blocklisted_watchers() final {
-    // Not needed yet
-  }
+  void check_blocklisted_watchers() final;
   void clear_primary_state() final {
     // Not needed yet
   }
index 271ca9dc5b641ba46acffaabb997aae7ecb37626..f71d915bb9d7ab6b3e14352b7ba42a0f5430bca7 100644 (file)
@@ -188,7 +188,7 @@ void Watch::cancel_notify(const uint64_t notify_id)
   in_progress_notifies.erase(it);
 }
 
-void Watch::do_watch_timeout(Ref<PG> pg)
+void Watch::do_watch_timeout()
 {
   assert(pg);
   auto [op, fut] = pg->get_shard_services().start_operation<WatchTimeoutRequest>(
index b1a22dbef29ef8cd9f323f766e0d82c3043041b8..0f7c9df544ac6bee8eb3eb1a6961a350cbcf1667 100644 (file)
@@ -39,13 +39,13 @@ class Watch : public seastar::enable_shared_from_this<Watch> {
 
   watch_info_t winfo;
   entity_name_t entity_name;
+  Ref<PG> pg;
 
   seastar::timer<seastar::lowres_clock> timeout_timer;
 
   seastar::future<> start_notify(NotifyRef);
   seastar::future<> send_notify_msg(NotifyRef);
   seastar::future<> send_disconnect_msg();
-  void do_watch_timeout(Ref<PG> pg);
 
   friend Notify;
   friend class WatchTimeoutRequest;
@@ -59,10 +59,11 @@ public:
     : obc(std::move(obc)),
       winfo(winfo),
       entity_name(entity_name),
-      timeout_timer([this, pg=std::move(pg)] {
-        assert(pg);
-        return do_watch_timeout(pg);
+      pg(std::move(pg)),
+      timeout_timer([this] {
+        return do_watch_timeout();
       }) {
+    assert(this->pg);
   }
   ~Watch();
 
@@ -94,10 +95,20 @@ public:
   uint64_t get_watcher_gid() const {
     return entity_name.num();
   }
-  uint64_t get_cookie() const {
+  auto get_pg() const {
+    return pg;
+  }
+  auto& get_entity() const {
+    return entity_name;
+  }
+  auto& get_cookie() const {
     return winfo.cookie;
   }
+  auto& get_peer_addr() const {
+    return winfo.addr;
+  }
   void cancel_notify(const uint64_t notify_id);
+  void do_watch_timeout();
 };
 
 using WatchRef = seastar::shared_ptr<Watch>;