From: Yehuda Sadeh Date: Mon, 10 Sep 2018 13:36:45 +0000 (-0700) Subject: rgw: svc: fixes X-Git-Tag: v14.1.0~965^2~28 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=66f9c146fff37b9bd03b68c09db857992490efdf;p=ceph-ci.git rgw: svc: fixes Signed-off-by: Yehuda Sadeh --- diff --git a/src/rgw/rgw_service.cc b/src/rgw/rgw_service.cc index 7a0260a8ebd..2e3690b2a95 100644 --- a/src/rgw/rgw_service.cc +++ b/src/rgw/rgw_service.cc @@ -70,6 +70,7 @@ int RGWServiceRegistry::do_get_instance(RGWServiceRef& svc, ldout(cct, 0) << "ERROR: failed to create instance for service " << svc->type() << " conf=" << conf << " (r=" << r << ")" << dendl; return r; } + svc->svc_registry = shared_from_this(); instance_ref->svc = svc; instance_ref->svc_id = ++max_registry_id; @@ -97,7 +98,9 @@ int RGWServiceRegistry::do_get_instance(RGWServiceRef& svc, dep_refs[dep_id] = dep_ref; } + ldout(cct, 10) << "svc: load service: " << instance_ref->get_svc()->type() << dendl; r = instance_ref->load(conf, dep_refs); + ldout(cct, 10) << "svc: done load service: " << instance_ref->get_svc()->type() << dendl; if (r < 0) { ldout(cct, 0) << "ERROR: service instance load return error: service=" << svc->type() << " r=" << r << dendl; return r; @@ -128,7 +131,9 @@ int RGWServiceRegistry::get_instance(RGWServiceRef& svc, } for (auto& instance_ref : new_instances) { + ldout(cct, 10) << "svc: init service: " << instance_ref->get_svc()->type() << dendl; r = instance_ref->init(); + ldout(cct, 10) << "svc: done init service: " << instance_ref->get_svc()->type() << dendl; if (r < 0) { ldout(cct, 0) << "ERROR: service instance init return error: service=" << instance_ref->get_svc()->type() << " r=" << r << dendl; return r; diff --git a/src/rgw/rgw_service.h b/src/rgw/rgw_service.h index b9f70c7a7a4..e1baa616c29 100644 --- a/src/rgw/rgw_service.h +++ b/src/rgw/rgw_service.h @@ -81,7 +81,7 @@ public: } }; -class RGWServiceRegistry { +class RGWServiceRegistry : public std::enable_shared_from_this { CephContext *cct; map services; diff --git a/src/rgw/services/svc_notify.cc b/src/rgw/services/svc_notify.cc index 03a73bae1dc..47f9bfbdb79 100644 --- a/src/rgw/services/svc_notify.cc +++ b/src/rgw/services/svc_notify.cc @@ -211,10 +211,17 @@ int RGWSI_Notify::init_watch() notify_objs[i] = rados_svc->handle(0).obj({control_pool, notify_oid}); auto& notify_obj = notify_objs[i]; + int r = notify_obj.open(); + if (r < 0) { + ldout(cct, 0) << "ERROR: notify_obj.open() returned r=" << r << dendl; + return r; + } + librados::ObjectWriteOperation op; op.create(false); - int r = notify_obj.operate(&op); + r = notify_obj.operate(&op); if (r < 0 && r != -EEXIST) { + ldout(cct, 0) << "ERROR: notify_obj.operate() returned r=" << r << dendl; return r; } @@ -312,7 +319,7 @@ void RGWSI_Notify::add_watcher(int i) watchers_set.insert(i); if (watchers_set.size() == (size_t)num_watchers) { ldout(cct, 2) << "all " << num_watchers << " watchers are set, enabling cache" << dendl; - set_enabled(true); + _set_enabled(true); } } @@ -325,7 +332,7 @@ void RGWSI_Notify::remove_watcher(int i) if (orig_size == (size_t)num_watchers && watchers_set.size() < orig_size) { /* actually removed */ ldout(cct, 2) << "removed watcher, disabling cache" << dendl; - set_enabled(false); + _set_enabled(false); } } @@ -344,6 +351,11 @@ int RGWSI_Notify::watch_cb(uint64_t notify_id, void RGWSI_Notify::set_enabled(bool status) { RWLock::RLocker l(watchers_lock); + _set_enabled(status); +} + +void RGWSI_Notify::_set_enabled(bool status) +{ if (cb) { cb->set_enabled(status); } diff --git a/src/rgw/services/svc_notify.h b/src/rgw/services/svc_notify.h index bcd96a8f4d9..75f716fe779 100644 --- a/src/rgw/services/svc_notify.h +++ b/src/rgw/services/svc_notify.h @@ -73,6 +73,7 @@ private: uint64_t cookie, uint64_t notifier_id, bufferlist& bl); + void _set_enabled(bool status); void set_enabled(bool status); int robust_notify(RGWSI_RADOS::Obj& notify_obj, bufferlist& bl); diff --git a/src/rgw/services/svc_rados.cc b/src/rgw/services/svc_rados.cc index 270fcaed973..5fea6f0c8e0 100644 --- a/src/rgw/services/svc_rados.cc +++ b/src/rgw/services/svc_rados.cc @@ -61,6 +61,7 @@ int RGWSI_RADOS::load(const string& conf, map& de return ret; } } + std::swap(handles, rados); return 0; } @@ -151,6 +152,7 @@ int RGWSI_RADOS::Obj::open() return r; } + ref.has_ioctx = true; ref.ioctx.locator_set_key(ref.key); return 0; diff --git a/src/rgw/services/svc_rados.h b/src/rgw/services/svc_rados.h index ed56dd04c55..73eaa284172 100644 --- a/src/rgw/services/svc_rados.h +++ b/src/rgw/services/svc_rados.h @@ -34,7 +34,51 @@ struct rgw_rados_ref { rgw_pool pool; string oid; string key; + bool has_ioctx{false}; librados::IoCtx ioctx; + + rgw_rados_ref() {} + ~rgw_rados_ref() {} + + rgw_rados_ref(const rgw_rados_ref& r) : pool(r.pool), + oid(r.oid), + key(r.key), + has_ioctx(r.has_ioctx) { + if (r.has_ioctx) { + ioctx = r.ioctx; + } + } + + rgw_rados_ref(const rgw_rados_ref&& r) : pool(std::move(r.pool)), + oid(std::move(r.oid)), + key(std::move(r.key)), + has_ioctx(r.has_ioctx) { + if (r.has_ioctx) { + ioctx = r.ioctx; + } + } + + rgw_rados_ref& operator=(rgw_rados_ref&& r) { + pool = std::move(r.pool); + oid = std::move(r.oid); + key = std::move(r.key); + has_ioctx = r.has_ioctx; + if (has_ioctx) { + ioctx = r.ioctx; + } + return *this; + } + + rgw_rados_ref& operator=(rgw_rados_ref& r) { + pool = r.pool; + oid = r.oid; + key = r.key; + has_ioctx = r.has_ioctx; + if (has_ioctx) { + ioctx = r.ioctx; + } + return *this; + } }; class RGWSI_RADOS : public RGWServiceInstance diff --git a/src/rgw/services/svc_sys_obj.h b/src/rgw/services/svc_sys_obj.h index 13d4e34c37c..869fcda441e 100644 --- a/src/rgw/services/svc_sys_obj.h +++ b/src/rgw/services/svc_sys_obj.h @@ -102,7 +102,7 @@ public: RGWObjVersionTracker *objv_tracker{nullptr}; map attrs; ceph::real_time mtime; - ceph::real_time *pmtime; + ceph::real_time *pmtime{nullptr}; bool exclusive{false}; WOp& set_attrs(map&& _attrs) {