From: Yehuda Sadeh Date: Mon, 19 Aug 2013 15:40:16 +0000 (-0700) Subject: rgw: change cache / watch-notify init sequence X-Git-Tag: v0.68~24 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d26ba3ab0374e77847c742dd00cb3bc9301214c2;p=ceph.git rgw: change cache / watch-notify init sequence 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 Reviewed-by: Sage Weil --- diff --git a/src/rgw/rgw_cache.h b/src/rgw/rgw_cache.h index b6c4e15eede4..601fcdfc9632 100644 --- a/src/rgw/rgw_cache.h +++ b/src/rgw/rgw_cache.h @@ -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: diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 222b79a7d2ec..0bbbf177b7a3 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -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::iterator ziter; for (ziter = region.zones.begin(); ziter != region.zones.end(); ++ziter) { const string& name = ziter->first; diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index d01f76ec2240..e6ab244afa90 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -1254,6 +1254,7 @@ public: virtual int update_containers_stats(map& 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);