Skip to content

Commit 4e455f0

Browse files
committed
rgw: notify svc doesn't duplicate notify_objs
each RGWWatcher already stores a rgw_rados_ref, we don't need a separate notify_objs vector Signed-off-by: Casey Bodley <[email protected]>
1 parent 0afbd09 commit 4e455f0

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/rgw/services/svc_notify.cc

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,11 @@ class RGWWatcher : public DoutPrefixProvider , public librados::WatchCtx2 {
5454
}
5555

5656
public:
57-
RGWWatcher(CephContext *_cct, RGWSI_Notify *s, int i, rgw_rados_ref& o)
58-
: cct(_cct), svc(s), index(i), obj(o), watch_handle(0) {}
57+
RGWWatcher(CephContext *_cct, RGWSI_Notify *s, int i, rgw_rados_ref o)
58+
: cct(_cct), svc(s), index(i), obj(std::move(o)), watch_handle(0) {}
59+
60+
rgw_rados_ref& get_obj() { return obj; }
61+
5962
void handle_notify(uint64_t notify_id,
6063
uint64_t cookie,
6164
uint64_t notifier_id,
@@ -196,7 +199,7 @@ rgw_rados_ref RGWSI_Notify::pick_control_obj(const string& key)
196199
uint32_t r = ceph_str_hash_linux(key.c_str(), key.size());
197200

198201
int i = r % num_watchers;
199-
return notify_objs[i];
202+
return watchers[i].get_obj();
200203
}
201204

202205
int RGWSI_Notify::init_watch(const DoutPrefixProvider *dpp, optional_yield y)
@@ -210,8 +213,6 @@ int RGWSI_Notify::init_watch(const DoutPrefixProvider *dpp, optional_yield y)
210213

211214
int error = 0;
212215

213-
notify_objs.resize(num_watchers);
214-
215216
watchers.reserve(num_watchers);
216217

217218
for (int i=0; i < num_watchers; i++) {
@@ -223,13 +224,13 @@ int RGWSI_Notify::init_watch(const DoutPrefixProvider *dpp, optional_yield y)
223224
notify_oid = notify_oid_prefix;
224225
}
225226

227+
rgw_rados_ref notify_obj;
226228
int r = rgw_get_rados_ref(dpp, rados, { control_pool, notify_oid },
227-
&notify_objs[i]);
229+
&notify_obj);
228230
if (r < 0) {
229231
ldpp_dout(dpp, 0) << "ERROR: notify_obj.open() returned r=" << r << dendl;
230232
return r;
231233
}
232-
auto& notify_obj = notify_objs[i];
233234

234235
librados::ObjectWriteOperation op;
235236
op.create(false);
@@ -240,7 +241,7 @@ int RGWSI_Notify::init_watch(const DoutPrefixProvider *dpp, optional_yield y)
240241
return r;
241242
}
242243

243-
auto& watcher = watchers.emplace_back(cct, this, i, notify_obj);
244+
auto& watcher = watchers.emplace_back(cct, this, i, std::move(notify_obj));
244245

245246
r = watcher.register_watch_async();
246247
if (r < 0) {

src/rgw/services/svc_notify.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ class RGWSI_Notify : public RGWServiceInstance
3737
int num_watchers{0};
3838
std::vector<RGWWatcher> watchers;
3939
std::set<int> watchers_set;
40-
std::vector<rgw_rados_ref> notify_objs;
4140

4241
bool enabled{false};
4342

0 commit comments

Comments
 (0)