Skip to content

Commit 0d84fdb

Browse files
authored
Merge pull request ceph#65775 from cbodley/wip-73361
rgw: RGWSI_Notify drains the finisher before deleting RGWWatchers Reviewed-by: Adam Emerson <[email protected]>
2 parents 3f62240 + dfc379c commit 0d84fdb

File tree

7 files changed

+26
-165
lines changed

7 files changed

+26
-165
lines changed

src/rgw/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ list(APPEND librgw_common_srcs
152152

153153
if(WITH_RADOSGW_RADOS)
154154
list(APPEND librgw_common_srcs
155-
services/svc_finisher.cc
156155
services/svc_bi_rados.cc
157156
services/svc_bilog_rados.cc
158157
services/svc_bucket.cc

src/rgw/driver/rados/rgw_service.cc

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
#include "rgw_service.h"
55

6-
#include "services/svc_finisher.h"
76
#include "services/svc_bi_rados.h"
87
#include "services/svc_bilog_rados.h"
98
#include "services/svc_bucket_sobj.h"
@@ -57,7 +56,6 @@ int RGWServices_Def::init(CephContext *cct,
5756
rgw::sal::ConfigStore* cfgstore,
5857
const rgw::SiteConfig* site)
5958
{
60-
finisher = std::make_unique<RGWSI_Finisher>(cct);
6159
bucket_sobj = std::make_unique<RGWSI_Bucket_SObj>(cct);
6260
bucket_sync_sobj = std::make_unique<RGWSI_Bucket_Sync_SObj>(cct);
6361
bi_rados = std::make_unique<RGWSI_BucketIndex_RADOS>(cct);
@@ -66,7 +64,9 @@ int RGWServices_Def::init(CephContext *cct,
6664
config_key_rados = std::make_unique<RGWSI_ConfigKey_RADOS>(cct);
6765
datalog_rados = std::make_unique<RGWDataChangesLog>(driver);
6866
mdlog = std::make_unique<RGWSI_MDLog>(cct, run_sync, cfgstore);
69-
notify = std::make_unique<RGWSI_Notify>(cct);
67+
if (have_cache) {
68+
notify = std::make_unique<RGWSI_Notify>(cct);
69+
}
7070
zone = std::make_unique<RGWSI_Zone>(cct, cfgstore, site);
7171
zone_utils = std::make_unique<RGWSI_ZoneUtils>(cct);
7272
quota = std::make_unique<RGWSI_Quota>(cct);
@@ -82,7 +82,6 @@ int RGWServices_Def::init(CephContext *cct,
8282
}
8383

8484
async_processor->start();
85-
finisher->init();
8685
bi_rados->init(zone.get(), driver->getRados()->get_rados_handle(),
8786
bilog_rados.get(), datalog_rados.get());
8887
bilog_rados->init(bi_rados.get());
@@ -97,8 +96,9 @@ int RGWServices_Def::init(CephContext *cct,
9796
config_key_rados->init(driver->getRados()->get_rados_handle());
9897
mdlog->init(driver->getRados()->get_rados_handle(), zone.get(), sysobj.get(),
9998
cls.get(), async_processor.get());
100-
notify->init(zone.get(), driver->getRados()->get_rados_handle(),
101-
finisher.get());
99+
if (notify) {
100+
notify->init(zone.get(), driver->getRados()->get_rados_handle());
101+
}
102102
zone->init(sysobj.get(), driver->getRados()->get_rados_handle(),
103103
sync_modules.get(), bucket_sync_sobj.get());
104104
zone_utils->init(driver->getRados()->get_rados_handle(), zone.get());
@@ -116,13 +116,9 @@ int RGWServices_Def::init(CephContext *cct,
116116

117117
can_shutdown = true;
118118

119-
int r = finisher->start(y, dpp);
120-
if (r < 0) {
121-
ldpp_dout(dpp, 0) << "ERROR: failed to start finisher service (" << cpp_strerror(-r) << dendl;
122-
return r;
123-
}
119+
int r = 0;
124120

125-
if (!raw) {
121+
if (notify) {
126122
r = notify->start(y, dpp);
127123
if (r < 0) {
128124
ldpp_dout(dpp, 0) << "ERROR: failed to start notify service (" << cpp_strerror(-r) << dendl;
@@ -240,19 +236,19 @@ void RGWServices_Def::shutdown()
240236
datalog_rados.reset();
241237
user_rados->shutdown();
242238
sync_modules->shutdown();
243-
notify->shutdown();
239+
if (notify) {
240+
notify->shutdown();
241+
}
244242
mdlog->shutdown();
245243
config_key_rados->shutdown();
246244
cls->shutdown();
247245
bilog_rados->shutdown();
248246
bi_rados->shutdown();
249247
bucket_sync_sobj->shutdown();
250248
bucket_sobj->shutdown();
251-
finisher->shutdown();
252249

253250
sysobj->shutdown();
254251
sysobj_core->shutdown();
255-
notify->shutdown();
256252
if (sysobj_cache) {
257253
sysobj_cache->shutdown();
258254
}
@@ -274,7 +270,6 @@ int RGWServices::do_init(CephContext *_cct, rgw::sal::RadosStore* driver, bool h
274270
return r;
275271
}
276272

277-
finisher = _svc.finisher.get();
278273
bi_rados = _svc.bi_rados.get();
279274
bi = bi_rados;
280275
bilog_rados = _svc.bilog_rados.get();
@@ -287,7 +282,6 @@ int RGWServices::do_init(CephContext *_cct, rgw::sal::RadosStore* driver, bool h
287282
config_key = config_key_rados;
288283
datalog_rados = _svc.datalog_rados.get();
289284
mdlog = _svc.mdlog.get();
290-
notify = _svc.notify.get();
291285
zone = _svc.zone.get();
292286
zone_utils = _svc.zone_utils.get();
293287
quota = _svc.quota.get();

src/rgw/driver/rados/rgw_service.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ class RGWServiceInstance
5353
}
5454
};
5555

56-
class RGWSI_Finisher;
5756
class RGWSI_Bucket;
5857
class RGWSI_Bucket_SObj;
5958
class RGWSI_Bucket_Sync;
@@ -84,7 +83,6 @@ struct RGWServices_Def
8483
bool can_shutdown{false};
8584
bool has_shutdown{false};
8685

87-
std::unique_ptr<RGWSI_Finisher> finisher;
8886
std::unique_ptr<RGWSI_Bucket_SObj> bucket_sobj;
8987
std::unique_ptr<RGWSI_Bucket_Sync_SObj> bucket_sync_sobj;
9088
std::unique_ptr<RGWSI_BucketIndex_RADOS> bi_rados;
@@ -122,7 +120,6 @@ struct RGWServices
122120
CephContext *cct;
123121
const rgw::SiteConfig* site{nullptr};
124122

125-
RGWSI_Finisher *finisher{nullptr};
126123
RGWSI_Bucket *bucket{nullptr};
127124
RGWSI_Bucket_SObj *bucket_sobj{nullptr};
128125
RGWSI_Bucket_Sync *bucket_sync{nullptr};
@@ -135,7 +132,6 @@ struct RGWServices
135132
RGWSI_ConfigKey *config_key{nullptr};
136133
RGWDataChangesLog *datalog_rados{nullptr};
137134
RGWSI_MDLog *mdlog{nullptr};
138-
RGWSI_Notify *notify{nullptr};
139135
RGWSI_Zone *zone{nullptr};
140136
RGWSI_ZoneUtils *zone_utils{nullptr};
141137
RGWSI_Quota *quota{nullptr};

src/rgw/services/svc_finisher.cc

Lines changed: 0 additions & 58 deletions
This file was deleted.

src/rgw/services/svc_finisher.h

Lines changed: 0 additions & 44 deletions
This file was deleted.

src/rgw/services/svc_notify.cc

Lines changed: 12 additions & 29 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];
@@ -245,8 +237,6 @@ void RGWSI_Notify::finalize_watch(boost::asio::yield_context yield)
245237
});
246238
}
247239
throttle.wait();
248-
249-
watchers.clear();
250240
}
251241

252242
int RGWSI_Notify::do_start(optional_yield y, const DoutPrefixProvider *dpp)
@@ -258,10 +248,7 @@ int RGWSI_Notify::do_start(optional_yield y, const DoutPrefixProvider *dpp)
258248

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

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

266253
inject_notify_timeout_probability =
267254
cct->_conf.get_val<double>("rgw_inject_notify_timeout_probability");
@@ -294,11 +281,6 @@ int RGWSI_Notify::do_start(optional_yield y, const DoutPrefixProvider *dpp)
294281
return ret;
295282
}
296283

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

@@ -308,10 +290,6 @@ void RGWSI_Notify::shutdown()
308290
return;
309291
}
310292

311-
if (finisher_handle) {
312-
finisher_svc->unregister_caller(*finisher_handle);
313-
}
314-
315293
// we're not running in a coroutine, so spawn one
316294
boost::asio::io_context context;
317295
boost::asio::spawn(context,
@@ -323,7 +301,12 @@ void RGWSI_Notify::shutdown()
323301
});
324302
context.run();
325303

326-
delete shutdown_cb;
304+
// wait for any racing C_ReinitWatch calls on the finisher thread
305+
// before destroying the RGWWatchers
306+
finisher.wait_for_empty();
307+
finisher.stop();
308+
309+
watchers.clear();
327310

328311
finalized = true;
329312
}
@@ -525,5 +508,5 @@ void RGWSI_Notify::register_watch_cb(CB *_cb)
525508

526509
void RGWSI_Notify::schedule_context(Context *c)
527510
{
528-
finisher_svc->schedule_context(c);
511+
finisher.queue(c);
529512
}

0 commit comments

Comments
 (0)