From: Jason Dillaman Date: Thu, 30 Apr 2015 19:17:54 +0000 (-0400) Subject: librbd: add AsyncRequest task enqueue helper method X-Git-Tag: v0.94.4~77^2~17 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=571220d6f4642dd3cd78988882645fdf647c150e;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 (cherry picked from commit 218bc2d0f8d90c9c64408cb22e26680e88138844) --- diff --git a/src/librbd/AsyncRequest.cc b/src/librbd/AsyncRequest.cc index 825c8c4e50a..543e723bca7 100644 --- a/src/librbd/AsyncRequest.cc +++ b/src/librbd/AsyncRequest.cc @@ -1,6 +1,7 @@ // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- // vim: ts=8 sw=2 smarttab #include "librbd/AsyncRequest.h" +#include "common/WorkQueue.h" #include "librbd/ImageCtx.h" #include "librbd/internal.h" #include @@ -21,6 +22,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 fd260a912c9..9f7ba244a06 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; }