]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cls/rbd: add get_all_features on client side
authorMykola Golub <mgolub@mirantis.com>
Sat, 5 Nov 2016 20:44:33 +0000 (22:44 +0200)
committerjdillaman <jdillaman@centos-7.dillaman-rh>
Wed, 23 Aug 2017 00:12:04 +0000 (20:12 -0400)
Signed-off-by: Mykola Golub <mgolub@mirantis.com>
(cherry picked from commit 84f6d5c109911923c25414de639308921983e438)

Conflicts:
src/cls/rbd/cls_rbd_client.h: trivial resolution

src/cls/rbd/cls_rbd_client.cc
src/cls/rbd/cls_rbd_client.h
src/test/cls_rbd/test_cls_rbd.cc

index 6ff245100eefd21c7f186b3bb31bcec1ca790d4c..68a6585c420623b0f65f55b966d365f42b490fa6 100644 (file)
@@ -616,6 +616,36 @@ namespace librbd {
       return old_snapshot_list_finish(&it, names, sizes, snapc);
     }
 
+    void get_all_features_start(librados::ObjectReadOperation *op) {
+      bufferlist in;
+      op->exec("rbd", "get_all_features", in);
+    }
+
+    int get_all_features_finish(bufferlist::iterator *it,
+                                uint64_t *all_features) {
+      try {
+       ::decode(*all_features, *it);
+      } catch (const buffer::error &err) {
+       return -EBADMSG;
+      }
+      return 0;
+    }
+
+    int get_all_features(librados::IoCtx *ioctx, const std::string &oid,
+                         uint64_t *all_features) {
+      librados::ObjectReadOperation op;
+      get_all_features_start(&op);
+
+      bufferlist out_bl;
+      int r = ioctx->operate(oid, &op, &out_bl);
+      if (r < 0) {
+        return r;
+      }
+
+      bufferlist::iterator it = out_bl.begin();
+      return get_all_features_finish(&it, all_features);
+    }
+
     int copyup(librados::IoCtx *ioctx, const std::string &oid,
               bufferlist data) {
       bufferlist out;
index 1ccbf76685cf44f93979951aed6419f33259f50a..6f1ac73d0f9541280dcaff7622d50a3efdc91307 100644 (file)
@@ -116,6 +116,12 @@ namespace librbd {
                      std::vector<parent_info> *parents,
                      std::vector<uint8_t> *protection_statuses);
 
+    void get_all_features_start(librados::ObjectReadOperation *op);
+    int get_all_features_finish(bufferlist::iterator *it,
+                                uint64_t *all_features);
+    int get_all_features(librados::IoCtx *ioctx, const std::string &oid,
+                         uint64_t *all_features);
+
     int copyup(librados::IoCtx *ioctx, const std::string &oid,
               bufferlist data);
     int get_protection_status(librados::IoCtx *ioctx, const std::string &oid,
index b6989658f765daa3284368b6afa515927a2db03a..f003882b66bdaf011a7225430759798459418ed1 100644 (file)
@@ -88,6 +88,21 @@ std::string TestClsRbd::_pool_name;
 librados::Rados TestClsRbd::_rados;
 uint64_t TestClsRbd::_image_number = 0;
 
+TEST_F(TestClsRbd, get_all_features)
+{
+  librados::IoCtx ioctx;
+  ASSERT_EQ(0, _rados.ioctx_create(_pool_name.c_str(), ioctx));
+
+  string oid = get_temp_image_name();
+  ASSERT_EQ(0, ioctx.create(oid, false));
+
+  uint64_t all_features = 0;
+  ASSERT_EQ(0, get_all_features(&ioctx, oid, &all_features));
+  ASSERT_EQ(RBD_FEATURES_ALL, all_features);
+
+  ioctx.close();
+}
+
 TEST_F(TestClsRbd, copyup)
 {
   librados::IoCtx ioctx;