]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: change cache / watch-notify init sequence
authorYehuda Sadeh <yehuda@inktank.com>
Mon, 19 Aug 2013 15:40:16 +0000 (08:40 -0700)
committerSage Weil <sage@inktank.com>
Wed, 21 Aug 2013 18:13:09 +0000 (11:13 -0700)
Fixes: #6046
We were initializing the watch-notify (through the cache
init) before reading the zone info which was much too
early, as we didn't have the control pool name yet. Now
simplifying init/cleanup a bit, cache doesn't call watch/notify
init and cleanup directly, but rather states its need
through a virtual callback.

Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
src/rgw/rgw_cache.h
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h

index b6c4e15eede49441a03602836b3a8784f79abadb..601fcdfc9632757aa6bf4f0ac7ede044dd0eaafe 100644 (file)
@@ -177,14 +177,13 @@ class RGWCache  : public T
     if (ret < 0)
       return ret;
 
-    ret = T::init_watch();
-    return ret;
+    return 0;
   }
 
-  void finalize() {
-    T::finalize_watch();
-    T::finalize();
+  bool need_watch_notify() {
+    return true;
   }
+
   int distribute_cache(const string& normal_name, rgw_obj& obj, ObjectCacheInfo& obj_info, int op);
   int watch_cb(int opcode, uint64_t ver, bufferlist& bl);
 public:
index 222b79a7d2ecfdabaee717d1efaf199ee02ab6c1..0bbbf177b7a3ca13e4763fd6db610f51101aa71c 100644 (file)
@@ -817,6 +817,9 @@ void RGWRadosCtx::set_prefetch_data(rgw_obj& obj) {
 
 void RGWRados::finalize()
 {
+  if (need_watch_notify()) {
+    finalize_watch();
+  }
   delete meta_mgr;
   delete data_log;
   if (use_gc_thread) {
@@ -909,6 +912,14 @@ int RGWRados::init_complete()
     }
   }
 
+  if (need_watch_notify()) {
+    ret = init_watch();
+    if (ret < 0) {
+      lderr(cct) << "ERROR: failed to initialize watch" << dendl;
+      return ret;
+    }
+  }
+
   map<string, RGWZone>::iterator ziter;
   for (ziter = region.zones.begin(); ziter != region.zones.end(); ++ziter) {
     const string& name = ziter->first;
index d01f76ec2240719a93ad6555e014230810240fc8..e6ab244afa905c431270c218bb055196488ea168 100644 (file)
@@ -1254,6 +1254,7 @@ public:
   virtual int update_containers_stats(map<string, RGWBucketEnt>& m);
   virtual int append_async(rgw_obj& obj, size_t size, bufferlist& bl);
 
+  virtual bool need_watch_notify() { return false; }
   virtual int init_watch();
   virtual void finalize_watch();
   virtual int distribute(const string& key, bufferlist& bl);