Skip to content

Commit eb3d949

Browse files
authored
Merge pull request ceph#62736 from adamemerson/wip-unbreak-d4n
rgw: Unbreak D4N Reviewed-by: Pritha Srivastava <[email protected]> Reviewed-by: Samarah Uriarte <[email protected]>
2 parents 57e5aef + 222965b commit eb3d949

File tree

3 files changed

+35
-25
lines changed

3 files changed

+35
-25
lines changed

src/rgw/driver/d4n/rgw_sal_d4n.cc

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,36 +36,28 @@ static inline Object* nextObject(Object* t)
3636
D4NFilterDriver::D4NFilterDriver(Driver* _next, boost::asio::io_context& io_context) : FilterDriver(_next),
3737
io_context(io_context)
3838
{
39-
conn = std::make_shared<connection>(boost::asio::make_strand(io_context));
40-
4139
rgw::cache::Partition partition_info;
4240
partition_info.location = g_conf()->rgw_d4n_l1_datacache_persistent_path;
4341
partition_info.name = "d4n";
4442
partition_info.type = "read-cache";
4543
partition_info.size = g_conf()->rgw_d4n_l1_datacache_size;
46-
47-
cacheDriver = new rgw::cache::SSDDriver(partition_info);
48-
objDir = new rgw::d4n::ObjectDirectory(conn);
49-
blockDir = new rgw::d4n::BlockDirectory(conn);
50-
policyDriver = new rgw::d4n::PolicyDriver(conn, cacheDriver, "lfuda");
44+
cacheDriver = std::make_unique<rgw::cache::SSDDriver>(partition_info);
5145
}
5246

53-
D4NFilterDriver::~D4NFilterDriver()
54-
{
55-
// call cancel() on the connection's executor
56-
boost::asio::dispatch(conn->get_executor(), [c = conn] { c->cancel(); });
57-
58-
delete cacheDriver;
59-
delete objDir;
60-
delete blockDir;
61-
delete policyDriver;
62-
}
47+
D4NFilterDriver::~D4NFilterDriver() = default;
6348

6449
int D4NFilterDriver::initialize(CephContext *cct, const DoutPrefixProvider *dpp)
6550
{
6651
namespace net = boost::asio;
6752
using boost::redis::config;
6853

54+
conn = std::make_shared<connection>(boost::asio::make_strand(io_context));
55+
objDir = std::make_unique<rgw::d4n::ObjectDirectory>(conn);
56+
blockDir = std::make_unique<rgw::d4n::BlockDirectory>(conn);
57+
policyDriver = std::make_unique<rgw::d4n::PolicyDriver>(conn,
58+
cacheDriver.get(),
59+
"lfuda");
60+
6961
std::string address = cct->_conf->rgw_d4n_address;
7062
config cfg;
7163
cfg.addr.host = address.substr(0, address.find(":"));
@@ -260,6 +252,19 @@ std::unique_ptr<Writer> D4NFilterDriver::get_atomic_writer(const DoutPrefixProvi
260252
return std::make_unique<D4NFilterWriter>(std::move(writer), this, obj, dpp, true, y);
261253
}
262254

255+
void D4NFilterDriver::shutdown()
256+
{
257+
// call cancel() on the connection's executor
258+
boost::asio::dispatch(conn->get_executor(), [c = conn] { c->cancel(); });
259+
260+
cacheDriver.reset();
261+
objDir.reset();
262+
blockDir.reset();
263+
policyDriver.reset();
264+
265+
next->shutdown();
266+
}
267+
263268
std::unique_ptr<Object::ReadOp> D4NFilterObject::get_read_op()
264269
{
265270
std::unique_ptr<ReadOp> r = next->get_read_op();

src/rgw/driver/d4n/rgw_sal_d4n.h

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ using boost::redis::connection;
4242
class D4NFilterDriver : public FilterDriver {
4343
private:
4444
std::shared_ptr<connection> conn;
45-
rgw::cache::CacheDriver* cacheDriver;
46-
rgw::d4n::ObjectDirectory* objDir;
47-
rgw::d4n::BlockDirectory* blockDir;
48-
rgw::d4n::PolicyDriver* policyDriver;
45+
std::unique_ptr<rgw::cache::CacheDriver> cacheDriver;
46+
std::unique_ptr<rgw::d4n::ObjectDirectory> objDir;
47+
std::unique_ptr<rgw::d4n::BlockDirectory> blockDir;
48+
std::unique_ptr<rgw::d4n::PolicyDriver> policyDriver;
4949
boost::asio::io_context& io_context;
5050

5151
public:
@@ -64,10 +64,13 @@ class D4NFilterDriver : public FilterDriver {
6464
const rgw_placement_rule *ptail_placement_rule,
6565
uint64_t olh_epoch,
6666
const std::string& unique_tag) override;
67-
rgw::cache::CacheDriver* get_cache_driver() { return cacheDriver; }
68-
rgw::d4n::ObjectDirectory* get_obj_dir() { return objDir; }
69-
rgw::d4n::BlockDirectory* get_block_dir() { return blockDir; }
70-
rgw::d4n::PolicyDriver* get_policy_driver() { return policyDriver; }
67+
rgw::cache::CacheDriver* get_cache_driver() { return cacheDriver.get(); }
68+
69+
70+
rgw::d4n::ObjectDirectory* get_obj_dir() { return objDir.get(); }
71+
rgw::d4n::BlockDirectory* get_block_dir() { return blockDir.get(); }
72+
rgw::d4n::PolicyDriver* get_policy_driver() { return policyDriver.get(); }
73+
void shutdown() override;
7174
};
7275

7376
class D4NFilterUser : public FilterUser {

src/rgw/rgw_sal_filter.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,8 @@ class FilterDriver : public Driver {
488488
virtual const std::string& get_compression_type(const rgw_placement_rule& rule) override;
489489
virtual bool valid_placement(const rgw_placement_rule& rule) override;
490490

491+
virtual void shutdown(void) override { next->shutdown(); };
492+
491493
virtual void finalize(void) override;
492494

493495
virtual CephContext* ctx(void) override;

0 commit comments

Comments
 (0)