]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: svc: fixes
authorYehuda Sadeh <yehuda@redhat.com>
Mon, 10 Sep 2018 13:36:45 +0000 (06:36 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Thu, 8 Nov 2018 17:19:29 +0000 (09:19 -0800)
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_service.cc
src/rgw/rgw_service.h
src/rgw/services/svc_notify.cc
src/rgw/services/svc_notify.h
src/rgw/services/svc_rados.cc
src/rgw/services/svc_rados.h
src/rgw/services/svc_sys_obj.h

index 7a0260a8ebd9a23484b7d49a9f6870111316a5e9..2e3690b2a956dcf3f5ca5f6138bcf7fb998e7f52 100644 (file)
@@ -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;
index b9f70c7a7a4b434c4288a0f172f5c756d3533650..e1baa616c29c5f0c567f5871631ebf1d584c8e91 100644 (file)
@@ -81,7 +81,7 @@ public:
   }
 };
 
-class RGWServiceRegistry {
+class RGWServiceRegistry : public std::enable_shared_from_this<RGWServiceRegistry> {
   CephContext *cct;
 
   map<string, RGWServiceRef> services;
index 03a73bae1dc22cdd1e59e62510ef229fee2f4920..47f9bfbdb794bdeba3b710bbb00e3d0e4c0a090b 100644 (file)
@@ -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);
   }
index bcd96a8f4d951f9c7e25c2da19e422988b30af38..75f716fe779f22acf40d9ece16744fab48463d82 100644 (file)
@@ -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);
index 270fcaed9734caa56c887b114a46daba01efc417..5fea6f0c8e0aa81fc1c0147aadf792740a7c7fb5 100644 (file)
@@ -61,6 +61,7 @@ int RGWSI_RADOS::load(const string& conf, map<string, RGWServiceInstanceRef>& 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;
index ed56dd04c55bc892f4c6ddbb435999c48d96ba28..73eaa284172ace47cf4a0ad2a23fd191b46a6f25 100644 (file)
@@ -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
index 13d4e34c37c6b161bb9ea99596b312c6644ddd94..869fcda441e5ac2a355732070d3fbc8d27e5d19f 100644 (file)
@@ -102,7 +102,7 @@ public:
       RGWObjVersionTracker *objv_tracker{nullptr};
       map<string, bufferlist> attrs;
       ceph::real_time mtime;
-      ceph::real_time *pmtime;
+      ceph::real_time *pmtime{nullptr};
       bool exclusive{false};
 
       WOp& set_attrs(map<string, bufferlist>&& _attrs) {