]> git.apps.os.sepia.ceph.com Git - ceph-ci.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 16:44:11 +0000 (12:44 -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>
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 852780cc6644664c941b34452b3ae0929e512ec3..c00d1a36c8f51c4a01a93bdf2c032a48a33f2c04 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 6a048f61b55d8ae2c4340873a7ba4ba48679bec1..15b405877b22a0d41597bcfa7ad89615331ae06c 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"
@@ -34,9 +35,11 @@ class RGWWatcher : public DoutPrefixProvider , public librados::WatchCtx2 {
       }
   };
 
-  CephContext *get_cct() const { return cct; }
-  unsigned get_subsys() const { return dout_subsys; }
-  std::ostream& gen_prefix(std::ostream& out) const { return out << "rgw watcher librados: "; }
+  CephContext *get_cct() const override { return cct; }
+  unsigned get_subsys() const override { return dout_subsys; }
+  std::ostream& gen_prefix(std::ostream& out) const override {
+    return out << "rgw watcher librados: ";
+  }
 
 public:
   RGWWatcher(CephContext *_cct, RGWSI_Notify *s, int i, RGWSI_RADOS::Obj& o) : cct(_cct), svc(s), index(i), obj(o), watch_handle(0) {}
@@ -364,7 +367,8 @@ void RGWSI_Notify::_set_enabled(bool status)
   }
 }
 
-int RGWSI_Notify::distribute(const DoutPrefixProvider *dpp, const string& key, bufferlist& bl,
+int RGWSI_Notify::distribute(const DoutPrefixProvider *dpp, const string& key,
+                            const RGWCacheNotifyInfo& cni,
                              optional_yield y)
 {
   /* The RGW uses the control pool to store the watch notify objects.
@@ -377,19 +381,21 @@ int RGWSI_Notify::distribute(const DoutPrefixProvider *dpp, const string& key, b
     RGWSI_RADOS::Obj notify_obj = pick_control_obj(key);
 
     ldpp_dout(dpp, 10) << "distributing notification oid=" << notify_obj.get_ref().obj
-        << " bl.length()=" << bl.length() << dendl;
-    return robust_notify(dpp, notify_obj, bl, y);
+                      << " cni=" << cni << dendl;
+    return robust_notify(dpp, notify_obj, cni, y);
   }
   return 0;
 }
 
-int RGWSI_Notify::robust_notify(const DoutPrefixProvider *dpp, 
-                                RGWSI_RADOS::Obj& notify_obj, bufferlist& bl,
+int RGWSI_Notify::robust_notify(const DoutPrefixProvider *dpp,
+                                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(dpp, bl, 0, &rbl, y);
@@ -397,7 +403,7 @@ int RGWSI_Notify::robust_notify(const DoutPrefixProvider *dpp,
   // If that doesn't work, get serious.
   if (r < 0) {
     ldpp_dout(dpp, 1) << "robust_notify: If at first you don't succeed: "
-                 << cpp_strerror(-r) << dendl;
+                     << cpp_strerror(-r) << dendl;
 
 
     auto p = rbl.cbegin();
@@ -469,7 +475,7 @@ int RGWSI_Notify::robust_notify(const DoutPrefixProvider *dpp,
          }
        } catch (const buffer::error& e) {
          ldpp_dout(dpp, 0) << "robust_notify: notify response parse failed: "
-                       << e.what() << dendl;
+                           << e.what() << dendl;
          continue;
        }
        // If we got a good parse and timeouts is empty, that means
index 5b01d77b7bfc05c477fcfb5589ab3188a720bfc7..e269677a361f9d97b955107df1f2af8ff6fd30d7 100644 (file)
@@ -15,6 +15,7 @@ class RGWSI_Finisher;
 
 class RGWWatcher;
 class RGWSI_Notify_ShutdownCB;
+struct RGWCacheNotifyInfo;
 
 class RGWSI_Notify : public RGWServiceInstance
 {
@@ -78,9 +79,8 @@ private:
   void _set_enabled(bool status);
   void set_enabled(bool status);
 
-  int robust_notify(const DoutPrefixProvider *dpp, 
-                    RGWSI_RADOS::Obj& notify_obj, bufferlist& bl,
-                    optional_yield y);
+  int robust_notify(const DoutPrefixProvider *dpp, RGWSI_RADOS::Obj& notify_obj,
+                   const RGWCacheNotifyInfo& bl, optional_yield y);
 
   void schedule_context(Context *c);
 public:
@@ -98,7 +98,8 @@ public:
       virtual void set_enabled(bool status) = 0;
   };
 
-  int distribute(const DoutPrefixProvider *dpp, const string& key, bufferlist& bl, optional_yield y);
+  int distribute(const DoutPrefixProvider *dpp, const string& key, const RGWCacheNotifyInfo& bl,
+                optional_yield y);
 
   void register_watch_cb(CB *cb);
 };
index b890e8757f40c899a98b3faa50819cb5ab9b563e..a914067ca75653a04a15b128cace7aef01096a33 100644 (file)
@@ -430,9 +430,7 @@ int RGWSI_SysObj_Cache::distribute_cache(const DoutPrefixProvider *dpp,
   info.op = op;
   info.obj_info = obj_info;
   info.obj = obj;
-  bufferlist bl;
-  encode(info, bl);
-  return notify_svc->distribute(dpp, normal_name, bl, y);
+  return notify_svc->distribute(dpp, normal_name, info, y);
 }
 
 int RGWSI_SysObj_Cache::watch_cb(const DoutPrefixProvider *dpp,