From 6bab931f053c028d56df12b9a09372b589a68ba1 Mon Sep 17 00:00:00 2001 From: "Adam C. Emerson" Date: Wed, 7 Jul 2021 18:47:00 -0400 Subject: [PATCH] rgw: distribute() takes RGWCacheNotifyInfo 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 (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 --- src/rgw/rgw_cache.h | 5 +++++ src/rgw/services/svc_notify.cc | 16 ++++++++++------ src/rgw/services/svc_notify.h | 8 +++++--- src/rgw/services/svc_sys_obj_cache.cc | 4 +--- 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/rgw/rgw_cache.h b/src/rgw/rgw_cache.h index 659b5518128e8..43f4db4cbcea0 100644 --- a/src/rgw/rgw_cache.h +++ b/src/rgw/rgw_cache.h @@ -125,6 +125,11 @@ struct RGWCacheNotifyInfo { static void generate_test_instances(list& 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: diff --git a/src/rgw/services/svc_notify.cc b/src/rgw/services/svc_notify.cc index 8e911e577d5ac..90ef19479c797 100644 --- a/src/rgw/services/svc_notify.cc +++ b/src/rgw/services/svc_notify.cc @@ -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> 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); diff --git a/src/rgw/services/svc_notify.h b/src/rgw/services/svc_notify.h index 031c53120c06d..8a7010114a934 100644 --- a/src/rgw/services/svc_notify.h +++ b/src/rgw/services/svc_notify.h @@ -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); }; diff --git a/src/rgw/services/svc_sys_obj_cache.cc b/src/rgw/services/svc_sys_obj_cache.cc index 5854d76547c44..e699386f2a309 100644 --- a/src/rgw/services/svc_sys_obj_cache.cc +++ b/src/rgw/services/svc_sys_obj_cache.cc @@ -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, -- 2.39.5