]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
cls_rbd: asynchronous helper method to set parent
authorJason Dillaman <dillaman@redhat.com>
Thu, 26 May 2016 16:01:15 +0000 (12:01 -0400)
committerJason Dillaman <dillaman@redhat.com>
Tue, 31 May 2016 20:39:42 +0000 (16:39 -0400)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/cls/rbd/cls_rbd_client.cc
src/cls/rbd/cls_rbd_client.h

index b20c57de95dbcea5cbf6a338bb295191a1e533b8..6ff245100eefd21c7f186b3bb31bcec1ca790d4c 100644 (file)
@@ -275,13 +275,20 @@ namespace librbd {
     int set_parent(librados::IoCtx *ioctx, const std::string &oid,
                   parent_spec pspec, uint64_t parent_overlap)
     {
-      bufferlist inbl, outbl;
-      ::encode(pspec.pool_id, inbl);
-      ::encode(pspec.image_id, inbl);
-      ::encode(pspec.snap_id, inbl);
-      ::encode(parent_overlap, inbl);
+      librados::ObjectWriteOperation op;
+      set_parent(&op, pspec, parent_overlap);
+      return ioctx->operate(oid, &op);
+    }
+
+    void set_parent(librados::ObjectWriteOperation *op,
+                    parent_spec pspec, uint64_t parent_overlap) {
+      bufferlist in_bl;
+      ::encode(pspec.pool_id, in_bl);
+      ::encode(pspec.image_id, in_bl);
+      ::encode(pspec.snap_id, in_bl);
+      ::encode(parent_overlap, in_bl);
 
-      return ioctx->exec(oid, "rbd", "set_parent", inbl, outbl);
+      op->exec("rbd", "set_parent", in_bl);
     }
 
     void get_flags_start(librados::ObjectReadOperation *op,
index c3a33ad2b73f990a311618bd30af76c7cd240756..1ccbf76685cf44f93979951aed6419f33259f50a 100644 (file)
@@ -66,6 +66,8 @@ namespace librbd {
                   uint64_t *parent_overlap);
     int set_parent(librados::IoCtx *ioctx, const std::string &oid,
                   parent_spec pspec, uint64_t parent_overlap);
+    void set_parent(librados::ObjectWriteOperation *op,
+                    parent_spec pspec, uint64_t parent_overlap);
     void get_flags_start(librados::ObjectReadOperation *op,
                          const std::vector<snapid_t> &snap_ids);
     int get_flags_finish(bufferlist::iterator *it, uint64_t *flags,