Skip to content

Commit 4aa6ed8

Browse files
committed
rgw: RGWSI_Notify uses Finisher instead of RGWSI_Finisher
RGWSI_Notify is the only user of RGWSI_Finisher, but doesn't "own" it. this means RGWSI_Notify can't drain/stop the Finisher on shutdown to guarantee the lifetime of contexts like C_ReinitWatch that it schedules there replace the use of RGWSI_Finisher with direct ownership of Finisher, and drain/stop it at the end of RGWSI_Notify::shutdown() Signed-off-by: Casey Bodley <[email protected]>
1 parent aea1dd8 commit 4aa6ed8

File tree

3 files changed

+12
-41
lines changed

3 files changed

+12
-41
lines changed

src/rgw/driver/rados/rgw_service.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,7 @@ int RGWServices_Def::init(CephContext *cct,
9797
config_key_rados->init(driver->getRados()->get_rados_handle());
9898
mdlog->init(driver->getRados()->get_rados_handle(), zone.get(), sysobj.get(),
9999
cls.get(), async_processor.get());
100-
notify->init(zone.get(), driver->getRados()->get_rados_handle(),
101-
finisher.get());
100+
notify->init(zone.get(), driver->getRados()->get_rados_handle());
102101
zone->init(sysobj.get(), driver->getRados()->get_rados_handle(),
103102
sync_modules.get(), bucket_sync_sobj.get());
104103
zone_utils->init(driver->getRados()->get_rados_handle(), zone.get());

src/rgw/services/svc_notify.cc

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
#include "rgw_cache.h"
1111
#include "svc_notify.h"
12-
#include "svc_finisher.h"
1312
#include "svc_zone.h"
1413

1514
#include "rgw_zone.h"
@@ -134,22 +133,15 @@ class RGWWatcher : public DoutPrefixProvider , public librados::WatchCtx2 {
134133
}
135134
};
136135

137-
RGWSI_Notify::RGWSI_Notify(CephContext *cct) : RGWServiceInstance(cct) {}
136+
RGWSI_Notify::RGWSI_Notify(CephContext *cct)
137+
: RGWServiceInstance(cct), finisher(cct)
138+
{
139+
}
138140
RGWSI_Notify::~RGWSI_Notify()
139141
{
140142
shutdown();
141143
}
142144

143-
class RGWSI_Notify_ShutdownCB : public RGWSI_Finisher::ShutdownCB
144-
{
145-
RGWSI_Notify *svc;
146-
public:
147-
RGWSI_Notify_ShutdownCB(RGWSI_Notify *_svc) : svc(_svc) {}
148-
void call() override {
149-
svc->shutdown();
150-
}
151-
};
152-
153145
string RGWSI_Notify::get_control_oid(int i)
154146
{
155147
char buf[notify_oid_prefix.size() + 16];
@@ -258,10 +250,7 @@ int RGWSI_Notify::do_start(optional_yield y, const DoutPrefixProvider *dpp)
258250

259251
assert(zone_svc->is_started()); /* otherwise there's an ordering problem */
260252

261-
r = finisher_svc->start(y, dpp);
262-
if (r < 0) {
263-
return r;
264-
}
253+
finisher.start();
265254

266255
inject_notify_timeout_probability =
267256
cct->_conf.get_val<double>("rgw_inject_notify_timeout_probability");
@@ -294,11 +283,6 @@ int RGWSI_Notify::do_start(optional_yield y, const DoutPrefixProvider *dpp)
294283
return ret;
295284
}
296285

297-
shutdown_cb = new RGWSI_Notify_ShutdownCB(this);
298-
int handle;
299-
finisher_svc->register_caller(shutdown_cb, &handle);
300-
finisher_handle = handle;
301-
302286
return 0;
303287
}
304288

@@ -308,10 +292,6 @@ void RGWSI_Notify::shutdown()
308292
return;
309293
}
310294

311-
if (finisher_handle) {
312-
finisher_svc->unregister_caller(*finisher_handle);
313-
}
314-
315295
// we're not running in a coroutine, so spawn one
316296
boost::asio::io_context context;
317297
boost::asio::spawn(context,
@@ -323,7 +303,8 @@ void RGWSI_Notify::shutdown()
323303
});
324304
context.run();
325305

326-
delete shutdown_cb;
306+
finisher.wait_for_empty();
307+
finisher.stop();
327308

328309
finalized = true;
329310
}
@@ -525,5 +506,5 @@ void RGWSI_Notify::register_watch_cb(CB *_cb)
525506

526507
void RGWSI_Notify::schedule_context(Context *c)
527508
{
528-
finisher_svc->schedule_context(c);
509+
finisher.queue(c);
529510
}

src/rgw/services/svc_notify.h

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,20 @@
33

44
#pragma once
55

6+
#include "common/Finisher.h"
67
#include "rgw_service.h"
78

89
#include "rgw_tools.h"
910

1011

11-
class Context;
12-
1312
class RGWSI_Zone;
14-
class RGWSI_Finisher;
1513

1614
class RGWWatcher;
17-
class RGWSI_Notify_ShutdownCB;
1815
struct RGWCacheNotifyInfo;
1916

2017
class RGWSI_Notify : public RGWServiceInstance
2118
{
2219
friend class RGWWatcher;
23-
friend class RGWSI_Notify_ShutdownCB;
2420
friend struct RGWServices_Def;
2521

2622
public:
@@ -29,7 +25,7 @@ class RGWSI_Notify : public RGWServiceInstance
2925
private:
3026
RGWSI_Zone *zone_svc{nullptr};
3127
librados::Rados *rados{nullptr};
32-
RGWSI_Finisher *finisher_svc{nullptr};
28+
Finisher finisher;
3329

3430
ceph::shared_mutex watchers_lock = ceph::make_shared_mutex("watchers_lock");
3531
rgw_pool control_pool;
@@ -48,21 +44,16 @@ class RGWSI_Notify : public RGWServiceInstance
4844

4945
CB *cb{nullptr};
5046

51-
std::optional<int> finisher_handle;
52-
RGWSI_Notify_ShutdownCB *shutdown_cb{nullptr};
53-
5447
bool finalized{false};
5548

5649
int init_watch(const DoutPrefixProvider *dpp,
5750
boost::asio::yield_context yield);
5851
void finalize_watch(boost::asio::yield_context yield);
5952

6053
void init(RGWSI_Zone *_zone_svc,
61-
librados::Rados* rados_,
62-
RGWSI_Finisher *_finisher_svc) {
54+
librados::Rados* rados_) {
6355
zone_svc = _zone_svc;
6456
rados = rados_;
65-
finisher_svc = _finisher_svc;
6657
}
6758
int do_start(optional_yield, const DoutPrefixProvider *dpp) override;
6859
void shutdown() override;

0 commit comments

Comments
 (0)