From: Jason Dillaman Date: Thu, 30 Apr 2015 19:17:54 +0000 (-0400) Subject: librbd: add AsyncRequest task enqueue helper method X-Git-Tag: v9.0.2~46^2~9 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=218bc2d0f8d90c9c64408cb22e26680e88138844;p=ceph.git librbd: add AsyncRequest task enqueue helper method In order to support the invariant that all state machine callbacks occur without holding locks, transitions that don't always involve a librados call should queue their callback. Signed-off-by: Jason Dillaman --- diff --git a/src/librbd/AsyncRequest.cc b/src/librbd/AsyncRequest.cc index 825c8c4e50a5f..71985073c802d 100644 --- a/src/librbd/AsyncRequest.cc +++ b/src/librbd/AsyncRequest.cc @@ -21,6 +21,10 @@ AsyncRequest::~AsyncRequest() { m_image_ctx.async_requests_cond.Signal(); } +void AsyncRequest::async_complete(int r) { + m_image_ctx.op_work_queue->queue(create_callback_context(), r); +} + librados::AioCompletion *AsyncRequest::create_callback_completion() { return librados::Rados::aio_create_completion(create_callback_context(), NULL, rados_ctx_cb); diff --git a/src/librbd/AsyncRequest.h b/src/librbd/AsyncRequest.h index fd260a912c9be..9f7ba244a0645 100644 --- a/src/librbd/AsyncRequest.h +++ b/src/librbd/AsyncRequest.h @@ -44,6 +44,8 @@ protected: librados::AioCompletion *create_callback_completion(); Context *create_callback_context(); + void async_complete(int r); + virtual bool safely_cancel(int r) { return true; }