]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: move watch reinit into a finisher
authorYehuda Sadeh <yehuda@redhat.com>
Thu, 12 Feb 2015 17:56:44 +0000 (09:56 -0800)
committerYehuda Sadeh <yehuda@redhat.com>
Thu, 5 Mar 2015 20:29:24 +0000 (12:29 -0800)
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h

index 55d14168a82ec97cce7b300aa638c7fb72bbe9df..7851e28d11520af9179cf7e9952115c938577739 100644 (file)
@@ -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<string>& result)
 {
   rgw_bucket pool(pool_name.c_str());
index 23707a8a3f15eced0d19d984faeb10b284cc29f0..76f8019946fff634489683f8bd02571bb099bd14 100644 (file)
@@ -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);
   /**