]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: add AsyncRequest task enqueue helper method
authorJason Dillaman <dillaman@redhat.com>
Thu, 30 Apr 2015 19:17:54 +0000 (15:17 -0400)
committerJason Dillaman <dillaman@redhat.com>
Thu, 4 Jun 2015 20:51:02 +0000 (16:51 -0400)
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 <dillaman@redhat.com>
src/librbd/AsyncRequest.cc
src/librbd/AsyncRequest.h

index 825c8c4e50a5fda4147ab4e5c4262b2faa405845..71985073c802d7ec41386109c19699be6fb4d956 100644 (file)
@@ -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);
index fd260a912c9be5592fa7de557521c63f4cf5f1f1..9f7ba244a0645b02c43c64e5a85ce3a2552e2212 100644 (file)
@@ -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;
   }