From 88b71c530a11b26b87c579cb99e178626845b388 Mon Sep 17 00:00:00 2001 From: Radoslaw Zarzynski Date: Tue, 16 Aug 2022 14:34:23 +0000 Subject: [PATCH] crimson/osd: implement watcher blocklisting Signed-off-by: Radoslaw Zarzynski (cherry picked from commit 24098bf9bbf66c64f48cb56187143102ffe13230) --- src/crimson/osd/pg.cc | 18 ++++++++++++++++++ src/crimson/osd/pg.h | 4 +--- src/crimson/osd/watch.cc | 2 +- src/crimson/osd/watch.h | 21 ++++++++++++++++----- 4 files changed, 36 insertions(+), 9 deletions(-) diff --git a/src/crimson/osd/pg.cc b/src/crimson/osd/pg.cc index 9400f1a260028..e0ef06c767337 100644 --- a/src/crimson/osd/pg.cc +++ b/src/crimson/osd/pg.cc @@ -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( diff --git a/src/crimson/osd/pg.h b/src/crimson/osd/pg.h index 6d26f58748ffc..6a0b198972fec 100644 --- a/src/crimson/osd/pg.h +++ b/src/crimson/osd/pg.h @@ -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 } diff --git a/src/crimson/osd/watch.cc b/src/crimson/osd/watch.cc index 9a899d6eccf6e..ffdb17827063b 100644 --- a/src/crimson/osd/watch.cc +++ b/src/crimson/osd/watch.cc @@ -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) +void Watch::do_watch_timeout() { assert(pg); auto [op, fut] = pg->get_shard_services().start_operation( diff --git a/src/crimson/osd/watch.h b/src/crimson/osd/watch.h index e69fb4ca14e54..a37703569c7ef 100644 --- a/src/crimson/osd/watch.h +++ b/src/crimson/osd/watch.h @@ -39,13 +39,13 @@ class Watch : public seastar::enable_shared_from_this { watch_info_t winfo; entity_name_t entity_name; + Ref pg; seastar::timer timeout_timer; seastar::future<> start_notify(NotifyRef); seastar::future<> send_notify_msg(NotifyRef); seastar::future<> send_disconnect_msg(); - void do_watch_timeout(Ref 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; -- 2.39.5