diff options
Diffstat (limited to 'src/rgw')
-rw-r--r-- | src/rgw/driver/rados/rgw_service.cc | 2 | ||||
-rw-r--r-- | src/rgw/driver/rados/rgw_tools.h | 33 | ||||
-rw-r--r-- | src/rgw/services/svc_notify.cc | 29 | ||||
-rw-r--r-- | src/rgw/services/svc_notify.h | 18 |
4 files changed, 50 insertions, 32 deletions
diff --git a/src/rgw/driver/rados/rgw_service.cc b/src/rgw/driver/rados/rgw_service.cc index af4043efa7a..ddd4dfdcd74 100644 --- a/src/rgw/driver/rados/rgw_service.cc +++ b/src/rgw/driver/rados/rgw_service.cc @@ -106,7 +106,7 @@ int RGWServices_Def::init(CephContext *cct, meta->init(sysobj.get(), mdlog.get(), meta_bes); meta_be_sobj->init(sysobj.get(), mdlog.get()); meta_be_otp->init(sysobj.get(), mdlog.get(), cls.get()); - notify->init(zone.get(), rados.get(), finisher.get()); + notify->init(zone.get(), radoshandle, finisher.get()); otp->init(zone.get(), meta.get(), meta_be_otp.get()); rados->init(); zone->init(sysobj.get(), rados.get(), sync_modules.get(), bucket_sync_sobj.get()); diff --git a/src/rgw/driver/rados/rgw_tools.h b/src/rgw/driver/rados/rgw_tools.h index 7fdb3ea3eff..a7639acbb24 100644 --- a/src/rgw/driver/rados/rgw_tools.h +++ b/src/rgw/driver/rados/rgw_tools.h @@ -108,34 +108,53 @@ struct rgw_rados_ref { rgw_raw_obj obj; - int operate(const DoutPrefixProvider *dpp, librados::ObjectReadOperation *op, - bufferlist *pbl, optional_yield y, int flags = 0) { + int operate(const DoutPrefixProvider* dpp, librados::ObjectReadOperation* op, + bufferlist* pbl, optional_yield y, int flags = 0) { return rgw_rados_operate(dpp, ioctx, obj.oid, op, pbl, y, flags); } - int operate(const DoutPrefixProvider *dpp, librados::ObjectWriteOperation *op, + int operate(const DoutPrefixProvider* dpp, librados::ObjectWriteOperation* op, optional_yield y, int flags = 0) { return rgw_rados_operate(dpp, ioctx, obj.oid, op, y, flags); } - int aio_operate(librados::AioCompletion *c, - librados::ObjectWriteOperation *op) { + int aio_operate(librados::AioCompletion* c, + librados::ObjectWriteOperation* op) { return ioctx.aio_operate(obj.oid, c, op); } - int aio_operate(librados::AioCompletion *c, librados::ObjectReadOperation *op, + int aio_operate(librados::AioCompletion* c, librados::ObjectReadOperation* op, bufferlist *pbl) { return ioctx.aio_operate(obj.oid, c, op, pbl); } - int notify(const DoutPrefixProvider *dpp, bufferlist& bl, uint64_t timeout_ms, + int watch(uint64_t* handle, librados::WatchCtx2* ctx) { + return ioctx.watch2(obj.oid, handle, ctx); + } + + int aio_watch(librados::AioCompletion* c, uint64_t* handle, + librados::WatchCtx2 *ctx) { + return ioctx.aio_watch(obj.oid, c, handle, ctx); + } + + int unwatch(uint64_t handle) { + return ioctx.unwatch2(handle); + } + + int notify(const DoutPrefixProvider* dpp, bufferlist& bl, uint64_t timeout_ms, bufferlist* pbl, optional_yield y) { return rgw_rados_notify(dpp, ioctx, obj.oid, bl, timeout_ms, pbl, y); } + + void notify_ack(uint64_t notify_id, uint64_t cookie, bufferlist& bl) { + ioctx.notify_ack(obj.oid, notify_id, cookie, bl); + } }; + inline std::ostream& operator <<(std::ostream& m, const rgw_rados_ref& ref) { return m << ref.obj; } + int rgw_get_rados_ref(const DoutPrefixProvider* dpp, librados::Rados* rados, rgw_raw_obj obj, rgw_rados_ref* ref); diff --git a/src/rgw/services/svc_notify.cc b/src/rgw/services/svc_notify.cc index 43f84ed0a4f..041354a376f 100644 --- a/src/rgw/services/svc_notify.cc +++ b/src/rgw/services/svc_notify.cc @@ -29,7 +29,7 @@ class RGWWatcher : public DoutPrefixProvider , public librados::WatchCtx2 { CephContext *cct; RGWSI_Notify *svc; int index; - RGWSI_RADOS::Obj obj; + rgw_rados_ref obj; uint64_t watch_handle; int register_ret{0}; bool unregister_done{false}; @@ -51,7 +51,8 @@ class RGWWatcher : public DoutPrefixProvider , public librados::WatchCtx2 { } public: - RGWWatcher(CephContext *_cct, RGWSI_Notify *s, int i, RGWSI_RADOS::Obj& 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(o), watch_handle(0) {} void handle_notify(uint64_t notify_id, uint64_t cookie, uint64_t notifier_id, @@ -174,7 +175,7 @@ string RGWSI_Notify::get_control_oid(int i) } // do not call pick_obj_control before init_watch -RGWSI_RADOS::Obj RGWSI_Notify::pick_control_obj(const string& key) +rgw_rados_ref RGWSI_Notify::pick_control_obj(const string& key) { uint32_t r = ceph_str_hash_linux(key.c_str(), key.size()); @@ -206,17 +207,17 @@ int RGWSI_Notify::init_watch(const DoutPrefixProvider *dpp, optional_yield y) notify_oid = notify_oid_prefix; } - notify_objs[i] = rados_svc->handle().obj({control_pool, notify_oid}); - auto& notify_obj = notify_objs[i]; - - int r = notify_obj.open(dpp); + int r = rgw_get_rados_ref(dpp, rados, { control_pool, notify_oid }, + ¬ify_objs[i]); 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); + r = notify_obj.operate(dpp, &op, y); if (r < 0 && r != -EEXIST) { ldpp_dout(dpp, 0) << "ERROR: notify_obj.operate() returned r=" << r << dendl; @@ -270,10 +271,6 @@ int RGWSI_Notify::do_start(optional_yield y, const DoutPrefixProvider *dpp) assert(zone_svc->is_started()); /* otherwise there's an ordering problem */ - r = rados_svc->start(y, dpp); - if (r < 0) { - return r; - } r = finisher_svc->start(y, dpp); if (r < 0) { return r; @@ -315,14 +312,14 @@ void RGWSI_Notify::shutdown() finalized = true; } -int RGWSI_Notify::unwatch(RGWSI_RADOS::Obj& obj, uint64_t watch_handle) +int RGWSI_Notify::unwatch(rgw_rados_ref& obj, uint64_t watch_handle) { int r = obj.unwatch(watch_handle); if (r < 0) { ldout(cct, 0) << "ERROR: rados->unwatch2() returned r=" << r << dendl; return r; } - r = rados_svc->handle().watch_flush(); + r = rados->watch_flush(); if (r < 0) { ldout(cct, 0) << "ERROR: rados->watch_flush() returned r=" << r << dendl; return r; @@ -392,9 +389,9 @@ int RGWSI_Notify::distribute(const DoutPrefixProvider *dpp, const string& key, which will lead to division by 0 in pick_obj_control (num_watchers is 0). */ if (num_watchers > 0) { - RGWSI_RADOS::Obj notify_obj = pick_control_obj(key); + auto notify_obj = pick_control_obj(key); - ldpp_dout(dpp, 10) << "distributing notification oid=" << notify_obj.get_ref().obj + ldpp_dout(dpp, 10) << "distributing notification oid=" << notify_obj.obj << " cni=" << cni << dendl; return robust_notify(dpp, notify_obj, cni, y); } @@ -443,7 +440,7 @@ static timeout_vector decode_timeouts(const bufferlist& bl) } int RGWSI_Notify::robust_notify(const DoutPrefixProvider *dpp, - RGWSI_RADOS::Obj& notify_obj, + rgw_rados_ref& notify_obj, const RGWCacheNotifyInfo& cni, optional_yield y) { diff --git a/src/rgw/services/svc_notify.h b/src/rgw/services/svc_notify.h index f7329136ece..618853d02c6 100644 --- a/src/rgw/services/svc_notify.h +++ b/src/rgw/services/svc_notify.h @@ -7,6 +7,8 @@ #include "svc_rados.h" +#include "rgw_tools.h" + class Context; @@ -21,14 +23,14 @@ class RGWSI_Notify : public RGWServiceInstance { friend class RGWWatcher; friend class RGWSI_Notify_ShutdownCB; - friend class RGWServices_Def; + friend struct RGWServices_Def; public: class CB; private: RGWSI_Zone *zone_svc{nullptr}; - RGWSI_RADOS *rados_svc{nullptr}; + librados::Rados *rados{nullptr}; RGWSI_Finisher *finisher_svc{nullptr}; ceph::shared_mutex watchers_lock = ceph::make_shared_mutex("watchers_lock"); @@ -37,7 +39,7 @@ private: int num_watchers{0}; RGWWatcher **watchers{nullptr}; std::set<int> watchers_set; - std::vector<RGWSI_RADOS::Obj> notify_objs; + std::vector<rgw_rados_ref> notify_objs; bool enabled{false}; @@ -45,7 +47,7 @@ private: uint64_t max_notify_retries = 10; std::string get_control_oid(int i); - RGWSI_RADOS::Obj pick_control_obj(const std::string& key); + rgw_rados_ref pick_control_obj(const std::string& key); CB *cb{nullptr}; @@ -58,16 +60,16 @@ private: void finalize_watch(); void init(RGWSI_Zone *_zone_svc, - RGWSI_RADOS *_rados_svc, + librados::Rados* rados_, RGWSI_Finisher *_finisher_svc) { zone_svc = _zone_svc; - rados_svc = _rados_svc; + rados = rados_; finisher_svc = _finisher_svc; } int do_start(optional_yield, const DoutPrefixProvider *dpp) override; void shutdown() override; - int unwatch(RGWSI_RADOS::Obj& obj, uint64_t watch_handle); + int unwatch(rgw_rados_ref& obj, uint64_t watch_handle); void add_watcher(int i); void remove_watcher(int i); @@ -79,7 +81,7 @@ private: void _set_enabled(bool status); void set_enabled(bool status); - int robust_notify(const DoutPrefixProvider *dpp, RGWSI_RADOS::Obj& notify_obj, + int robust_notify(const DoutPrefixProvider *dpp, rgw_rados_ref& notify_obj, const RGWCacheNotifyInfo& bl, optional_yield y); void schedule_context(Context *c); |