From 0b48b40c2323f3ec7937cbb2e08b874db8a16a09 Mon Sep 17 00:00:00 2001 From: "Adam C. Emerson" Date: Tue, 8 Apr 2025 13:29:46 -0400 Subject: [PATCH] rgw/d4n: Shutdown Redis connection in `shutdown()` Since we changed the shutdown logic to let Asio tasks finish, make sure we finish. Fixes: https://tracker.ceph.com/issues/70771 Signed-off-by: Adam C. Emerson --- src/rgw/driver/d4n/rgw_sal_d4n.cc | 35 +++++++++++++++++-------------- src/rgw/driver/d4n/rgw_sal_d4n.h | 1 + 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/rgw/driver/d4n/rgw_sal_d4n.cc b/src/rgw/driver/d4n/rgw_sal_d4n.cc index 65145fb833bfb..3b9ee0581b3dc 100644 --- a/src/rgw/driver/d4n/rgw_sal_d4n.cc +++ b/src/rgw/driver/d4n/rgw_sal_d4n.cc @@ -36,36 +36,26 @@ static inline Object* nextObject(Object* t) D4NFilterDriver::D4NFilterDriver(Driver* _next, boost::asio::io_context& io_context) : FilterDriver(_next), io_context(io_context) { - conn = std::make_shared(boost::asio::make_strand(io_context)); - rgw::cache::Partition partition_info; partition_info.location = g_conf()->rgw_d4n_l1_datacache_persistent_path; partition_info.name = "d4n"; partition_info.type = "read-cache"; partition_info.size = g_conf()->rgw_d4n_l1_datacache_size; - cacheDriver = new rgw::cache::SSDDriver(partition_info); - objDir = new rgw::d4n::ObjectDirectory(conn); - blockDir = new rgw::d4n::BlockDirectory(conn); - policyDriver = new rgw::d4n::PolicyDriver(conn, cacheDriver, "lfuda"); } -D4NFilterDriver::~D4NFilterDriver() -{ - // call cancel() on the connection's executor - boost::asio::dispatch(conn->get_executor(), [c = conn] { c->cancel(); }); - - delete cacheDriver; - delete objDir; - delete blockDir; - delete policyDriver; -} +D4NFilterDriver::~D4NFilterDriver() = default; int D4NFilterDriver::initialize(CephContext *cct, const DoutPrefixProvider *dpp) { namespace net = boost::asio; using boost::redis::config; + conn = std::make_shared(boost::asio::make_strand(io_context)); + objDir = new rgw::d4n::ObjectDirectory(conn); + blockDir = new rgw::d4n::BlockDirectory(conn); + policyDriver = new rgw::d4n::PolicyDriver(conn, cacheDriver, "lfuda"); + std::string address = cct->_conf->rgw_d4n_address; config cfg; cfg.addr.host = address.substr(0, address.find(":")); @@ -260,6 +250,19 @@ std::unique_ptr D4NFilterDriver::get_atomic_writer(const DoutPrefixProvi return std::make_unique(std::move(writer), this, obj, dpp, true, y); } +void D4NFilterDriver::shutdown() +{ + // call cancel() on the connection's executor + boost::asio::dispatch(conn->get_executor(), [c = conn] { c->cancel(); }); + + delete cacheDriver; + delete objDir; + delete blockDir; + delete policyDriver; + + next->shutdown(); +} + std::unique_ptr D4NFilterObject::get_read_op() { std::unique_ptr r = next->get_read_op(); diff --git a/src/rgw/driver/d4n/rgw_sal_d4n.h b/src/rgw/driver/d4n/rgw_sal_d4n.h index 2d852b33ecc37..d6c1c85b8e8d6 100644 --- a/src/rgw/driver/d4n/rgw_sal_d4n.h +++ b/src/rgw/driver/d4n/rgw_sal_d4n.h @@ -68,6 +68,7 @@ class D4NFilterDriver : public FilterDriver { rgw::d4n::ObjectDirectory* get_obj_dir() { return objDir; } rgw::d4n::BlockDirectory* get_block_dir() { return blockDir; } rgw::d4n::PolicyDriver* get_policy_driver() { return policyDriver; } + void shutdown() override; }; class D4NFilterUser : public FilterUser { -- 2.47.3