]> 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)
committerMykola Golub <mgolub@mirantis.com>
Mon, 7 Nov 2016 18:12:59 +0000 (20:12 +0200)
Signed-off-by: Mykola Golub <mgolub@mirantis.com>
src/cls/rbd/cls_rbd_client.cc
src/cls/rbd/cls_rbd_client.h
src/test/cls_rbd/test_cls_rbd.cc

index 9cbbef31f0820c6e1bc0f046b8a7e58bc782a92e..c0f3da77858290157314399168fe3323bc88d18e 100644 (file)
@@ -712,6 +712,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 0b74a25394f3f844f40d7c4799c2a7d24c05bc55..52f259d25c6fea01661d1c3938517b5f37f07a3f 100644 (file)
@@ -135,6 +135,12 @@ namespace librbd {
                            const std::vector<snapid_t> &ids,
                            std::vector<cls::rbd::SnapshotNamespace> *namespaces);
 
+    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 01a4d7a50395f9c53bc41b11976920453b8a08c6..30f51202bda571d9e78c4670aaf159181c1def25 100644 (file)
@@ -89,6 +89,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;