]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
Objecter: make linger_callback_flush accept context instead of blocking
authorHaomai Wang <haomai@xsky.com>
Fri, 19 Feb 2016 03:11:26 +0000 (11:11 +0800)
committerHaomai Wang <haomai@xsky.com>
Sat, 20 Feb 2016 06:37:03 +0000 (14:37 +0800)
Signed-off-by: Haomai Wang <haomai@xsky.com>
src/osdc/Objecter.cc
src/osdc/Objecter.h

index 8a6f1e659e0c1e2a89b8c2d5d3ff7cc905db27b5..41bde027ef1b5cf0b40068fbacc7cfef30d822a1 100644 (file)
@@ -46,7 +46,6 @@
 
 #include "common/config.h"
 #include "common/perf_counters.h"
-#include "common/Finisher.h"
 #include "include/str_list.h"
 #include "common/errno.h"
 
@@ -597,7 +596,6 @@ struct C_DoWatchError : public Context {
 
     info->finished_async();
     info->put();
-    objecter->_linger_callback_finish();
   }
 };
 
@@ -622,7 +620,6 @@ void Objecter::_linger_reconnect(LingerOp *info, int r)
       info->last_error = r;
       if (info->watch_context) {
        finisher->queue(new C_DoWatchError(this, info, r));
-       _linger_callback_queue();
       }
     }
     wl.unlock();
@@ -687,7 +684,6 @@ void Objecter::_linger_ping(LingerOp *info, int r, mono_time sent,
       info->last_error = r;
       if (info->watch_context) {
        finisher->queue(new C_DoWatchError(this, info, r));
-       _linger_callback_queue();
       }
     }
   } else {
@@ -870,7 +866,6 @@ void Objecter::handle_watch_notify(MWatchNotify *m)
       info->last_error = -ENOTCONN;
       if (info->watch_context) {
        finisher->queue(new C_DoWatchError(this, info, -ENOTCONN));
-       _linger_callback_queue();
       }
     }
   } else if (!info->is_watch) {
@@ -891,7 +886,6 @@ void Objecter::handle_watch_notify(MWatchNotify *m)
     }
   } else {
     finisher->queue(new C_DoWatchNotify(this, info, m));
-    _linger_callback_queue();
   }
 }
 
@@ -925,7 +919,6 @@ void Objecter::_do_watch_notify(LingerOp *info, MWatchNotify *m)
   info->finished_async();
   info->put();
   m->put();
-  _linger_callback_finish();
 }
 
 bool Objecter::ms_dispatch(Message *m)
index 8e156a00b6af3efce2bfdfff62a0758f4ec64068..fbf0e86745d7b6ea868f64aefaa89399ce9cc376 100644 (file)
@@ -33,6 +33,7 @@
 #include "common/admin_socket.h"
 #include "common/ceph_time.h"
 #include "common/ceph_timer.h"
+#include "common/Finisher.h"
 #include "common/shunique_lock.h"
 
 #include "messages/MOSDOp.h"
@@ -1793,11 +1794,6 @@ public:
   map<uint64_t, LingerOp*> linger_ops;
   // we use this just to confirm a cookie is valid before dereferencing the ptr
   set<LingerOp*> linger_ops_set;
-  int num_linger_callbacks;
-  std::mutex linger_callback_lock;
-  typedef std::unique_lock<std::mutex> unique_linger_cb_lock;
-  typedef std::lock_guard<std::mutex> linger_cb_lock_guard;
-  std::condition_variable linger_callback_cond;
 
   map<ceph_tid_t,PoolStatOp*> poolstat_ops;
   map<ceph_tid_t,StatfsOp*> statfs_ops;
@@ -1866,23 +1862,10 @@ public:
                    uint32_t register_gen);
   int _normalize_watch_error(int r);
 
-  void _linger_callback_queue() {
-    linger_cb_lock_guard l(linger_callback_lock);
-    ++num_linger_callbacks;
-  }
-  void _linger_callback_finish() {
-    linger_cb_lock_guard l(linger_callback_lock);
-    if (--num_linger_callbacks == 0)
-      linger_callback_cond.notify_all();
-    assert(num_linger_callbacks >= 0);
-  }
   friend class C_DoWatchError;
 public:
-  void linger_callback_flush() {
-    unique_linger_cb_lock l(linger_callback_lock);
-    linger_callback_cond.wait(l, [this]() {
-       return num_linger_callbacks <= 0;
-      });
+  void linger_callback_flush(Context *ctx) {
+    finisher->queue(ctx);
   }
 
 private:
@@ -1958,7 +1941,7 @@ private:
     keep_balanced_budget(false), honor_osdmap_full(true),
     last_seen_osdmap_version(0), last_seen_pgmap_version(0),
     logger(NULL), tick_event(0), m_request_state_hook(NULL),
-    num_linger_callbacks(0), num_homeless_ops(0),
+    num_homeless_ops(0),
     homeless_session(new OSDSession(cct, -1)),
     mon_timeout(ceph::make_timespan(mon_timeout)),
     osd_timeout(ceph::make_timespan(osd_timeout)),