From: Yehuda Sadeh Date: Thu, 12 Feb 2015 17:56:44 +0000 (-0800) Subject: rgw: move watch reinit into a finisher X-Git-Tag: v0.94~50^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=387e4f85873df8761d8021e53604eef3bef59793;p=ceph.git rgw: move watch reinit into a finisher Signed-off-by: Yehuda Sadeh --- diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 55d14168a82e..7851e28d1152 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -11,6 +11,7 @@ #include "common/errno.h" #include "common/Formatter.h" #include "common/Throttle.h" +#include "common/Finisher.h" #include "rgw_rados.h" #include "rgw_cache.h" @@ -1212,6 +1213,15 @@ int RGWPutObjProcessor_Atomic::do_complete(string& etag, time_t *mtime, time_t s class RGWWatcher : public librados::WatchCtx2 { RGWRados *rados; string oid; + + class C_ReinitWatch : public Context { + RGWWatcher *watcher; + public: + C_ReinitWatch(RGWWatcher *_watcher) : watcher(_watcher) {} + void finish(int r) { + watcher->reinit(); + } + }; public: RGWWatcher(RGWRados *r, const string& o) : rados(r), oid(o) {} void handle_notify(uint64_t notify_id, @@ -1232,6 +1242,10 @@ public: lderr(rados->ctx()) << "RGWWatcher::handle_error cookie " << cookie << " err " << cpp_strerror(err) << dendl; rados->set_cache_enabled(false); + rados->schedule_context(new C_ReinitWatch(this)); + } + + void reinit() { rados->finalize_watch(); int ret = rados->init_watch(); if (ret < 0) { @@ -1313,6 +1327,8 @@ int RGWRados::get_max_chunk_size(rgw_bucket& bucket, uint64_t *max_chunk_size) void RGWRados::finalize() { + finisher->stop(); + delete finisher; if (need_watch_notify()) { finalize_watch(); } @@ -1428,6 +1444,9 @@ int RGWRados::init_complete() } } + finisher = new Finisher(cct); + finisher->start(); + if (need_watch_notify()) { ret = init_watch(); if (ret < 0) { @@ -1515,6 +1534,10 @@ void RGWRados::finalize_watch() delete[] watchers; } +void RGWRados::schedule_context(Context *c) { + finisher->queue(c); +} + int RGWRados::list_raw_prefixed_objs(string pool_name, const string& prefix, list& result) { rgw_bucket pool(pool_name.c_str()); diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index 23707a8a3f15..76f8019946ff 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -1156,6 +1156,8 @@ struct RGWObjectCtx { void invalidate(rgw_obj& obj); }; +class Finisher; + class RGWRados { friend class RGWGC; @@ -1243,6 +1245,8 @@ protected: RGWQuotaHandler *quota_handler; + Finisher *finisher; + public: RGWRados() : lock("rados_timer_lock"), timer(NULL), gc(NULL), use_gc_thread(false), quota_threads(false), @@ -1254,6 +1258,7 @@ public: cct(NULL), rados(NULL), pools_initialized(false), quota_handler(NULL), + finisher(NULL), rest_master_conn(NULL), meta_mgr(NULL), data_log(NULL) {} @@ -1315,6 +1320,8 @@ public: virtual int initialize(); virtual void finalize(); + void schedule_context(Context *c); + /** set up a bucket listing. handle is filled in. */ virtual int list_buckets_init(RGWAccessHandle *handle); /**