]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: distribute() takes RGWCacheNotifyInfo
authorAdam C. Emerson <aemerson@redhat.com>
Wed, 7 Jul 2021 22:47:00 +0000 (18:47 -0400)
committerAdam C. Emerson <aemerson@redhat.com>
Wed, 14 Jul 2021 22:20:54 +0000 (18:20 -0400)
So we don't have to parse the bufferlist back out to find what object
to throw out of the cache.

Fixes: https://tracker.ceph.com/issues/51674
Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
(cherry picked from commit 7f952ad80114096322f202ba58279aaa4a002313)

Conflicts:
src/rgw/services/svc_notify.cc
src/rgw/services/svc_notify.h
src/rgw/services/svc_sys_obj_cache.cc
 - The original version is post-DPP, this is pre-DPP

Backport: https://tracker.ceph.com/issues/51678
Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
src/rgw/rgw_cache.h
src/rgw/services/svc_notify.cc
src/rgw/services/svc_notify.h
src/rgw/services/svc_sys_obj_cache.cc

index 659b5518128e8d5c1ca2a80ee78457be88a78958..43f4db4cbcea0e59472699a14577f4a9071c0642 100644 (file)
@@ -125,6 +125,11 @@ struct RGWCacheNotifyInfo {
   static void generate_test_instances(list<RGWCacheNotifyInfo*>& o);
 };
 WRITE_CLASS_ENCODER(RGWCacheNotifyInfo)
+inline std::ostream& operator <<(std::ostream& m, const RGWCacheNotifyInfo& cni) {
+  return m << "[op: " << cni.op << ", obj: " << cni.obj
+          << ", ofs" << cni.ofs << ", ns" << cni.ns << "]";
+}
+
 
 class RGWChainedCache {
 public:
index 8e911e577d5acd85cc4fa2818728b4a59298c57e..90ef19479c7972eeb04e4577d4dac14bb3ecb1c8 100644 (file)
@@ -5,6 +5,7 @@
 #include "include/Context.h"
 #include "common/errno.h"
 
+#include "rgw/rgw_cache.h"
 #include "svc_notify.h"
 #include "svc_finisher.h"
 #include "svc_zone.h"
@@ -33,6 +34,7 @@ class RGWWatcher : public librados::WatchCtx2 {
         watcher->reinit();
       }
   };
+
 public:
   RGWWatcher(CephContext *_cct, RGWSI_Notify *s, int i, RGWSI_RADOS::Obj& o) : cct(_cct), svc(s), index(i), obj(o), watch_handle(0) {}
   void handle_notify(uint64_t notify_id,
@@ -358,8 +360,8 @@ void RGWSI_Notify::_set_enabled(bool status)
   }
 }
 
-int RGWSI_Notify::distribute(const string& key, bufferlist& bl,
-                             optional_yield y)
+int RGWSI_Notify::distribute(const string& key, const RGWCacheNotifyInfo& cni,
+                            optional_yield y)
 {
   /* The RGW uses the control pool to store the watch notify objects.
     The precedence in RGWSI_Notify::do_start is to call to zone_svc->start and later to init_watch().
@@ -371,18 +373,20 @@ int RGWSI_Notify::distribute(const string& key, bufferlist& bl,
     RGWSI_RADOS::Obj notify_obj = pick_control_obj(key);
 
     ldout(cct, 10) << "distributing notification oid=" << notify_obj.get_ref().obj
-        << " bl.length()=" << bl.length() << dendl;
-    return robust_notify(notify_obj, bl, y);
+                      << " cni=" << cni << dendl;
+    return robust_notify(notify_obj, cni, y);
   }
   return 0;
 }
 
-int RGWSI_Notify::robust_notify(RGWSI_RADOS::Obj& notify_obj, bufferlist& bl,
+int RGWSI_Notify::robust_notify(RGWSI_RADOS::Obj& notify_obj,
+                               const RGWCacheNotifyInfo& cni,
                                 optional_yield y)
 {
   // The reply of every machine that acks goes in here.
   boost::container::flat_set<std::pair<uint64_t, uint64_t>> acks;
-  bufferlist rbl;
+  bufferlist bl, rbl;
+  encode(cni, bl);
 
   // First, try to send, without being fancy about it.
   auto r = notify_obj.notify(bl, 0, &rbl, y);
index 031c53120c06d336203c0767f6962c66ca88a529..8a7010114a9342a602afc23673c7715171ef14ea 100644 (file)
@@ -15,6 +15,7 @@ class RGWSI_Finisher;
 
 class RGWWatcher;
 class RGWSI_Notify_ShutdownCB;
+struct RGWCacheNotifyInfo;
 
 class RGWSI_Notify : public RGWServiceInstance
 {
@@ -77,8 +78,8 @@ private:
   void _set_enabled(bool status);
   void set_enabled(bool status);
 
-  int robust_notify(RGWSI_RADOS::Obj& notify_obj, bufferlist& bl,
-                    optional_yield y);
+  int robust_notify(RGWSI_RADOS::Obj& notify_obj,
+                   const RGWCacheNotifyInfo& bl, optional_yield y);
 
   void schedule_context(Context *c);
 public:
@@ -95,7 +96,8 @@ public:
       virtual void set_enabled(bool status) = 0;
   };
 
-  int distribute(const string& key, bufferlist& bl, optional_yield y);
+  int distribute(const string& key, const RGWCacheNotifyInfo& bl,
+                optional_yield y);
 
   void register_watch_cb(CB *cb);
 };
index 5854d76547c44c70109f9474e017b9329b91361a..e699386f2a309b454b202f96f3c1acb86a082bf9 100644 (file)
@@ -422,9 +422,7 @@ int RGWSI_SysObj_Cache::distribute_cache(const string& normal_name,
   info.op = op;
   info.obj_info = obj_info;
   info.obj = obj;
-  bufferlist bl;
-  encode(info, bl);
-  return notify_svc->distribute(normal_name, bl, y);
+  return notify_svc->distribute(normal_name, info, y);
 }
 
 int RGWSI_SysObj_Cache::watch_cb(uint64_t notify_id,