From: Haomai Wang Date: Fri, 19 Feb 2016 03:11:26 +0000 (+0800) Subject: Objecter: make linger_callback_flush accept context instead of blocking X-Git-Tag: v10.1.0~321^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f5d8da6247e95ad4584bbe9907924165731bf323;p=ceph.git Objecter: make linger_callback_flush accept context instead of blocking Signed-off-by: Haomai Wang --- diff --git a/src/osdc/Objecter.cc b/src/osdc/Objecter.cc index 8a6f1e659e0c..41bde027ef1b 100644 --- a/src/osdc/Objecter.cc +++ b/src/osdc/Objecter.cc @@ -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) diff --git a/src/osdc/Objecter.h b/src/osdc/Objecter.h index 8e156a00b6af..fbf0e86745d7 100644 --- a/src/osdc/Objecter.h +++ b/src/osdc/Objecter.h @@ -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 linger_ops; // we use this just to confirm a cookie is valid before dereferencing the ptr set linger_ops_set; - int num_linger_callbacks; - std::mutex linger_callback_lock; - typedef std::unique_lock unique_linger_cb_lock; - typedef std::lock_guard linger_cb_lock_guard; - std::condition_variable linger_callback_cond; map poolstat_ops; map 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)),