]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: notify svc doesn't duplicate notify_objs
authorCasey Bodley <cbodley@redhat.com>
Wed, 26 Mar 2025 22:26:30 +0000 (18:26 -0400)
committerCasey Bodley <cbodley@redhat.com>
Thu, 27 Mar 2025 13:53:31 +0000 (09:53 -0400)
each RGWWatcher already stores a rgw_rados_ref, we don't need a
separate notify_objs vector

Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/services/svc_notify.cc
src/rgw/services/svc_notify.h

index ae49199d99714ed21e705f61670511409df5dfd0..4474e80c4bf97c3c0c438a48bfbfabe91e6de01f 100644 (file)
@@ -54,8 +54,11 @@ class RGWWatcher : public DoutPrefixProvider , public librados::WatchCtx2 {
   }
 
 public:
-  RGWWatcher(CephContext *_cct, RGWSI_Notify *s, int i, rgw_rados_ref& o)
-    : cct(_cct), svc(s), index(i), obj(o), watch_handle(0) {}
+  RGWWatcher(CephContext *_cct, RGWSI_Notify *s, int i, rgw_rados_ref o)
+    : cct(_cct), svc(s), index(i), obj(std::move(o)), watch_handle(0) {}
+
+  rgw_rados_ref& get_obj() { return obj; }
+
   void handle_notify(uint64_t notify_id,
                     uint64_t cookie,
                     uint64_t notifier_id,
@@ -196,7 +199,7 @@ rgw_rados_ref RGWSI_Notify::pick_control_obj(const string& key)
   uint32_t r = ceph_str_hash_linux(key.c_str(), key.size());
 
   int i = r % num_watchers;
-  return notify_objs[i];
+  return watchers[i].get_obj();
 }
 
 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)
 
   int error = 0;
 
-  notify_objs.resize(num_watchers);
-
   watchers.reserve(num_watchers);
 
   for (int i=0; i < num_watchers; i++) {
@@ -223,13 +224,13 @@ int RGWSI_Notify::init_watch(const DoutPrefixProvider *dpp, optional_yield y)
       notify_oid = notify_oid_prefix;
     }
 
+    rgw_rados_ref notify_obj;
     int r = rgw_get_rados_ref(dpp, rados, { control_pool, notify_oid },
-                             &notify_objs[i]);
+                             &notify_obj);
     if (r < 0) {
       ldpp_dout(dpp, 0) << "ERROR: notify_obj.open() returned r=" << r << dendl;
       return r;
     }
-    auto& notify_obj = notify_objs[i];
 
     librados::ObjectWriteOperation op;
     op.create(false);
@@ -240,7 +241,7 @@ int RGWSI_Notify::init_watch(const DoutPrefixProvider *dpp, optional_yield y)
       return r;
     }
 
-    auto& watcher = watchers.emplace_back(cct, this, i, notify_obj);
+    auto& watcher = watchers.emplace_back(cct, this, i, std::move(notify_obj));
 
     r = watcher.register_watch_async();
     if (r < 0) {
index 905200caaf3adc4de3d9c55d1aab1ed5be0e7217..eb271dc47da13e50ed8b3a096e7192ee0194f5df 100644 (file)
@@ -37,7 +37,6 @@ private:
   int num_watchers{0};
   std::vector<RGWWatcher> watchers;
   std::set<int> watchers_set;
-  std::vector<rgw_rados_ref> notify_objs;
 
   bool enabled{false};