]> git.apps.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)
committerMatan Breizman <mbreizma@redhat.com>
Mon, 22 May 2023 15:50:43 +0000 (15:50 +0000)
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
(cherry picked from commit 24098bf9bbf66c64f48cb56187143102ffe13230)

src/crimson/osd/pg.cc
src/crimson/osd/pg.h
src/crimson/osd/watch.cc
src/crimson/osd/watch.h

index 9400f1a260028d7140d885e4bfb106d6d7f021cf..e0ef06c767337387bd35cbe932b6ffaddc7b0ea9 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 6d26f58748ffc2d53f723e6e315afdc9ae8a7fd2..6a0b198972fec30e69c3ec01d4e2d44c5f5d86d0 100644 (file)
@@ -310,9 +310,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 9a899d6eccf6ec0040085a8b3f84064ba49913a5..ffdb17827063b9891a7906c6a3d80f09d4eefe19 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 e69fb4ca14e54c5984f9128e205bed656c9e5937..a37703569c7ef2c86c57810285493f7ab5a7b1b1 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>;