]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: support updated async cls_rbd API
authorJason Dillaman <dillaman@redhat.com>
Fri, 4 Dec 2015 20:23:32 +0000 (15:23 -0500)
committerJason Dillaman <dillaman@redhat.com>
Tue, 15 Dec 2015 01:30:51 +0000 (20:30 -0500)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/librbd/object_map/SnapshotRemoveRequest.cc
src/librbd/object_map/SnapshotRemoveRequest.h
src/librbd/operation/SnapshotUnprotectRequest.cc

index b3b145e1a8682dd1266adbc4b8beb0eff003d798..6cc8987ed1b0b5cbccb44931665b805379968eec 100644 (file)
@@ -72,6 +72,10 @@ bool SnapshotRemoveRequest::should_complete(int r) {
   bool finished = false;
   switch (m_state) {
   case STATE_LOAD_MAP:
+    if (r == 0) {
+      bufferlist::iterator it = m_out_bl.begin();
+      r = cls_client::object_map_load_finish(&it, &m_snap_object_map);
+    }
     if (r < 0) {
       RWLock::WLocker snap_locker(m_image_ctx.snap_lock);
       send_invalidate_next_map();
@@ -108,8 +112,14 @@ void SnapshotRemoveRequest::send_load_map() {
                 << dendl;
   m_state = STATE_LOAD_MAP;
 
-  cls_client::object_map_load(&m_image_ctx.md_ctx, snap_oid,
-                              &m_snap_object_map, create_callback_context());
+  librados::ObjectReadOperation op;
+  cls_client::object_map_load_start(&op);
+
+  librados::AioCompletion *rados_completion = create_callback_completion();
+  int r = m_image_ctx.md_ctx.aio_operate(snap_oid, rados_completion, &op,
+                                         &m_out_bl);
+  assert(r == 0);
+  rados_completion->release();
 }
 
 void SnapshotRemoveRequest::send_remove_snapshot() {
index 24950faef9e65bc977b31f46a6a10287455954cc..75fbdc8839fdfcb7a0fa56e0929b34471c20d7ff 100644 (file)
@@ -5,6 +5,7 @@
 #define CEPH_LIBRBD_OBJECT_MAP_SNAPSHOT_REMOVE_REQUEST_H
 
 #include "include/int_types.h"
+#include "include/buffer.h"
 #include "common/bit_vector.hpp"
 #include "librbd/AsyncRequest.h"
 
@@ -73,6 +74,7 @@ private:
   uint64_t m_next_snap_id;
 
   ceph::BitVector<2> m_snap_object_map;
+  bufferlist m_out_bl;
 
   void send_load_map();
   void send_remove_snapshot();
index c9c8f54224c46866537aebfabd79713b17ed65bb..65b71670dd83f901de8f8e7540d588c88de6fa0f 100644 (file)
@@ -10,6 +10,7 @@
 #include "librbd/ImageCtx.h"
 #include "librbd/internal.h"
 #include "librbd/parent_types.h"
+#include "librbd/Utils.h"
 #include <list>
 #include <set>
 #include <vector>
@@ -97,8 +98,15 @@ public:
       return r;
     }
 
-    cls_client::get_children(&m_pool_ioctx, RBD_CHILDREN, m_pspec, &m_children,
-                             this);
+    librados::ObjectReadOperation op;
+    cls_client::get_children_start(&op, m_pspec);
+
+    librados::AioCompletion *rados_completion =
+      util::create_rados_ack_callback(this);
+    r = m_pool_ioctx.aio_operate(RBD_CHILDREN, rados_completion, &op,
+                                 &m_children_bl);
+    assert(r == 0);
+    rados_completion->release();
     return 0;
   }
 
@@ -106,8 +114,13 @@ protected:
   virtual void finish(int r) {
     I &image_ctx = this->m_image_ctx;
     CephContext *cct = image_ctx.cct;
-    ldout(cct, 10) << this << " retrieved children: r=" << r << dendl;
 
+    if (r == 0) {
+      bufferlist::iterator it = m_children_bl.begin();
+      r= cls_client::get_children_finish(&it, &m_children);
+    }
+
+    ldout(cct, 10) << this << " retrieved children: r=" << r << dendl;
     if (r == -ENOENT) {
       // no children -- proceed with unprotect
       r = 0;