]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cls/rbd: renamed image group add/remove/get operations
authorJason Dillaman <dillaman@redhat.com>
Tue, 16 Jan 2018 18:20:31 +0000 (13:20 -0500)
committerJason Dillaman <dillaman@redhat.com>
Fri, 26 Jan 2018 15:32:40 +0000 (10:32 -0500)
The methods are used by the luminous release of librbd but are essentially
no-ops since group support was removed from the API. However, we need to
prevent odd interactions once a new client creates a group and uses an
older client to manipulate the image.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/cls/rbd/cls_rbd.cc
src/cls/rbd/cls_rbd_client.cc
src/cls/rbd/cls_rbd_client.h
src/librbd/api/Group.cc
src/librbd/image/RefreshRequest.cc
src/librbd/image/RemoveRequest.cc
src/test/cls_rbd/test_cls_rbd.cc
src/test/librbd/image/test_mock_RefreshRequest.cc
src/test/librbd/image/test_mock_RemoveRequest.cc

index a595a773b142befed76740cb6916c65f747d650b..c85e0e4432b987ffb0ceda8f2c216310c0958c22 100644 (file)
@@ -5046,10 +5046,10 @@ int group_image_list(cls_method_context_t hctx,
  * Output:
  * @return 0 on success, negative error code on failure
  */
-int image_add_group(cls_method_context_t hctx,
+int image_group_add(cls_method_context_t hctx,
                    bufferlist *in, bufferlist *out)
 {
-  CLS_LOG(20, "image_add_group");
+  CLS_LOG(20, "image_group_add");
   cls::rbd::GroupSpec new_group;
   try {
     bufferlist::iterator iter = in->begin();
@@ -5104,11 +5104,11 @@ int image_add_group(cls_method_context_t hctx,
  * Output:
  * @return 0 on success, negative error code on failure
  */
-int image_remove_group(cls_method_context_t hctx,
+int image_group_remove(cls_method_context_t hctx,
                       bufferlist *in,
                       bufferlist *out)
 {
-  CLS_LOG(20, "image_remove_group");
+  CLS_LOG(20, "image_group_remove");
   cls::rbd::GroupSpec spec;
   try {
     bufferlist::iterator iter = in->begin();
@@ -5153,10 +5153,10 @@ int image_remove_group(cls_method_context_t hctx,
  * @param GroupSpec
  * @return 0 on success, negative error code on failure
  */
-int image_get_group(cls_method_context_t hctx,
+int image_group_get(cls_method_context_t hctx,
                    bufferlist *in, bufferlist *out)
 {
-  CLS_LOG(20, "image_get_group");
+  CLS_LOG(20, "image_group_get");
   bufferlist refbl;
   int r = cls_cxx_map_get_val(hctx, RBD_GROUP_REF, &refbl);
   if (r < 0 && r != -ENOENT) {
@@ -5720,9 +5720,9 @@ CLS_INIT(rbd)
   cls_method_handle_t h_group_image_remove;
   cls_method_handle_t h_group_image_list;
   cls_method_handle_t h_group_image_set;
-  cls_method_handle_t h_image_add_group;
-  cls_method_handle_t h_image_remove_group;
-  cls_method_handle_t h_image_get_group;
+  cls_method_handle_t h_image_group_add;
+  cls_method_handle_t h_image_group_remove;
+  cls_method_handle_t h_image_group_get;
   cls_method_handle_t h_group_snap_set;
   cls_method_handle_t h_group_snap_remove;
   cls_method_handle_t h_group_snap_get_by_id;
@@ -6002,15 +6002,15 @@ CLS_INIT(rbd)
   cls_register_cxx_method(h_class, "group_image_set",
                          CLS_METHOD_RD | CLS_METHOD_WR,
                          group_image_set, &h_group_image_set);
-  cls_register_cxx_method(h_class, "image_add_group",
+  cls_register_cxx_method(h_class, "image_group_add",
                          CLS_METHOD_RD | CLS_METHOD_WR,
-                         image_add_group, &h_image_add_group);
-  cls_register_cxx_method(h_class, "image_remove_group",
+                         image_group_add, &h_image_group_add);
+  cls_register_cxx_method(h_class, "image_group_remove",
                          CLS_METHOD_RD | CLS_METHOD_WR,
-                         image_remove_group, &h_image_remove_group);
-  cls_register_cxx_method(h_class, "image_get_group",
+                         image_group_remove, &h_image_group_remove);
+  cls_register_cxx_method(h_class, "image_group_get",
                          CLS_METHOD_RD,
-                         image_get_group, &h_image_get_group);
+                         image_group_get, &h_image_group_get);
   cls_register_cxx_method(h_class, "group_snap_set",
                          CLS_METHOD_RD | CLS_METHOD_WR,
                          group_snap_set, &h_group_snap_set);
index 16b9d552152aef39b4b555a8f80a599b84783f05..b84cfa0033353ff55b6a9fad0e0672bd7d9a547d 100644 (file)
@@ -2063,31 +2063,31 @@ namespace librbd {
       return ioctx->exec(oid, "rbd", "group_image_set", bl, bl2);
     }
 
-    int image_add_group(librados::IoCtx *ioctx, const std::string &oid,
+    int image_group_add(librados::IoCtx *ioctx, const std::string &oid,
                        const cls::rbd::GroupSpec &group_spec)
     {
       bufferlist bl, bl2;
       encode(group_spec, bl);
 
-      return ioctx->exec(oid, "rbd", "image_add_group", bl, bl2);
+      return ioctx->exec(oid, "rbd", "image_group_add", bl, bl2);
     }
 
-    int image_remove_group(librados::IoCtx *ioctx, const std::string &oid,
+    int image_group_remove(librados::IoCtx *ioctx, const std::string &oid,
                           const cls::rbd::GroupSpec &group_spec)
     {
       bufferlist bl, bl2;
       encode(group_spec, bl);
 
-      return ioctx->exec(oid, "rbd", "image_remove_group", bl, bl2);
+      return ioctx->exec(oid, "rbd", "image_group_remove", bl, bl2);
     }
 
-    void image_get_group_start(librados::ObjectReadOperation *op)
+    void image_group_get_start(librados::ObjectReadOperation *op)
     {
       bufferlist in_bl;
-      op->exec("rbd", "image_get_group", in_bl);
+      op->exec("rbd", "image_group_get", in_bl);
     }
 
-    int image_get_group_finish(bufferlist::iterator *iter,
+    int image_group_get_finish(bufferlist::iterator *iter,
                                cls::rbd::GroupSpec *group_spec)
     {
       try {
@@ -2098,11 +2098,11 @@ namespace librbd {
       return 0;
     }
 
-    int image_get_group(librados::IoCtx *ioctx, const std::string &oid,
+    int image_group_get(librados::IoCtx *ioctx, const std::string &oid,
                        cls::rbd::GroupSpec *group_spec)
     {
       librados::ObjectReadOperation op;
-      image_get_group_start(&op);
+      image_group_get_start(&op);
 
       bufferlist out_bl;
       int r = ioctx->operate(oid, &op, &out_bl);
@@ -2111,7 +2111,7 @@ namespace librbd {
       }
 
       bufferlist::iterator iter = out_bl.begin();
-      return image_get_group_finish(&iter, group_spec);
+      return image_group_get_finish(&iter, group_spec);
     }
 
     int group_snap_set(librados::IoCtx *ioctx, const std::string &oid,
index 4b3fbf9874c56cff586e2c4ff1346a3d2f71c256..ee29bb84fddc4f21aabc4ecbacf63eb67962417e 100644 (file)
@@ -422,14 +422,14 @@ namespace librbd {
                         std::vector<cls::rbd::GroupImageStatus> *images);
     int group_image_set(librados::IoCtx *ioctx, const std::string &oid,
                        const cls::rbd::GroupImageStatus &st);
-    int image_add_group(librados::IoCtx *ioctx, const std::string &oid,
+    int image_group_add(librados::IoCtx *ioctx, const std::string &oid,
                        const cls::rbd::GroupSpec &group_spec);
-    int image_remove_group(librados::IoCtx *ioctx, const std::string &oid,
+    int image_group_remove(librados::IoCtx *ioctx, const std::string &oid,
                           const cls::rbd::GroupSpec &group_spec);
-    void image_get_group_start(librados::ObjectReadOperation *op);
-    int image_get_group_finish(bufferlist::iterator *iter,
+    void image_group_get_start(librados::ObjectReadOperation *op);
+    int image_group_get_finish(bufferlist::iterator *iter,
                                cls::rbd::GroupSpec *group_spec);
-    int image_get_group(librados::IoCtx *ioctx, const std::string &oid,
+    int image_group_get(librados::IoCtx *ioctx, const std::string &oid,
                        cls::rbd::GroupSpec *group_spec);
     int group_snap_set(librados::IoCtx *ioctx, const std::string &oid,
                       const cls::rbd::GroupSnapshot &snapshot);
index e6deec1cc1ef55a99d39dc2f868162da49bdf6fd..71a9cd348d7661550f53b1bde2ffb3b00d0658ee 100644 (file)
@@ -185,7 +185,7 @@ int group_image_remove(librados::IoCtx& group_ioctx, string group_id,
     return r;
   }
 
-  r = cls_client::image_remove_group(&image_ioctx, image_header_oid,
+  r = cls_client::image_group_remove(&image_ioctx, image_header_oid,
                                     group_spec);
   if ((r < 0) && (r != -ENOENT)) {
     lderr(cct) << "couldn't remove group reference from image"
@@ -542,7 +542,7 @@ int Group<I>::image_add(librados::IoCtx& group_ioctx, const char *group_name,
     return r;
   }
 
-  r = cls_client::image_add_group(&image_ioctx, image_header_oid, group_spec);
+  r = cls_client::image_group_add(&image_ioctx, image_header_oid, group_spec);
   if (r < 0) {
     lderr(cct) << "error adding group reference to image: "
               << cpp_strerror(-r) << dendl;
index cc485c405a615d96a6b2b08711ea87ea2c9c8dbd..0b99d1c29e8d3a95bf4baa379a1f08366cb7fdbd 100644 (file)
@@ -456,7 +456,7 @@ void RefreshRequest<I>::send_v2_get_group() {
   ldout(cct, 10) << this << " " << __func__ << dendl;
 
   librados::ObjectReadOperation op;
-  cls_client::image_get_group_start(&op);
+  cls_client::image_group_get_start(&op);
 
   using klass = RefreshRequest<I>;
   librados::AioCompletion *comp = create_rados_callback<
@@ -476,7 +476,7 @@ Context *RefreshRequest<I>::handle_v2_get_group(int *result) {
 
   if (*result == 0) {
     bufferlist::iterator it = m_out_bl.begin();
-    cls_client::image_get_group_finish(&it, &m_group_spec);
+    cls_client::image_group_get_finish(&it, &m_group_spec);
   }
   if (*result == -EOPNOTSUPP) {
     // Older OSD doesn't support RBD groups
index 83e3b48be70a368f378d34a991e1ca577f026569..65cc9b72cca4e79c63510a598c0fe1574a0d1575 100644 (file)
@@ -298,7 +298,7 @@ void RemoveRequest<I>::check_group() {
   ldout(m_cct, 20) << dendl;
 
   librados::ObjectReadOperation op;
-  librbd::cls_client::image_get_group_start(&op);
+  librbd::cls_client::image_group_get_start(&op);
 
   using klass = RemoveRequest<I>;
   librados::AioCompletion *rados_completion = create_rados_callback<
@@ -317,7 +317,7 @@ void RemoveRequest<I>::handle_check_group(int r) {
   cls::rbd::GroupSpec s;
   if (r == 0) {
     bufferlist::iterator it = m_out_bl.begin();
-    r = librbd::cls_client::image_get_group_finish(&it, &s);
+    r = librbd::cls_client::image_group_get_finish(&it, &s);
   }
   if (r < 0 && r != -EOPNOTSUPP) {
     lderr(m_cct) << "error fetching group for image: "
index f1058a49ee35d46e4f3b5bc102c5e9548572ee4a..d84ae9b3130156bf8492a23ad330ad9a513a9bf6 100644 (file)
@@ -2154,7 +2154,7 @@ TEST_F(TestClsRbd, group_image_clean) {
   ASSERT_EQ(cls::rbd::GROUP_IMAGE_LINK_STATE_ATTACHED, ref_state);
 }
 
-TEST_F(TestClsRbd, image_add_group) {
+TEST_F(TestClsRbd, image_group_add) {
   librados::IoCtx ioctx;
   ASSERT_EQ(0, _rados.ioctx_create(_pool_name.c_str(), ioctx));
 
@@ -2167,7 +2167,7 @@ TEST_F(TestClsRbd, image_add_group) {
   string group_id = "group_id";
 
   cls::rbd::GroupSpec spec(group_id, pool_id);
-  ASSERT_EQ(0, image_add_group(&ioctx, image_id, spec));
+  ASSERT_EQ(0, image_group_add(&ioctx, image_id, spec));
 
   map<string, bufferlist> vals;
   ASSERT_EQ(0, ioctx.omap_get_vals(image_id, "", RBD_GROUP_REF, 10, &vals));
@@ -2180,7 +2180,7 @@ TEST_F(TestClsRbd, image_add_group) {
   ASSERT_EQ(pool_id, val_spec.pool_id);
 }
 
-TEST_F(TestClsRbd, image_remove_group) {
+TEST_F(TestClsRbd, image_group_remove) {
   librados::IoCtx ioctx;
   ASSERT_EQ(0, _rados.ioctx_create(_pool_name.c_str(), ioctx));
 
@@ -2193,10 +2193,10 @@ TEST_F(TestClsRbd, image_remove_group) {
   string group_id = "group_id";
 
   cls::rbd::GroupSpec spec(group_id, pool_id);
-  ASSERT_EQ(0, image_add_group(&ioctx, image_id, spec));
-  // Add reference in order to make sure that image_remove_group actually
+  ASSERT_EQ(0, image_group_add(&ioctx, image_id, spec));
+  // Add reference in order to make sure that image_group_remove actually
   // does something.
-  ASSERT_EQ(0, image_remove_group(&ioctx, image_id, spec));
+  ASSERT_EQ(0, image_group_remove(&ioctx, image_id, spec));
 
   map<string, bufferlist> vals;
   ASSERT_EQ(0, ioctx.omap_get_vals(image_id, "", RBD_GROUP_REF, 10, &vals));
@@ -2204,7 +2204,7 @@ TEST_F(TestClsRbd, image_remove_group) {
   ASSERT_EQ(0U, vals.size());
 }
 
-TEST_F(TestClsRbd, image_get_group) {
+TEST_F(TestClsRbd, image_group_get) {
   librados::IoCtx ioctx;
   ASSERT_EQ(0, _rados.ioctx_create(_pool_name.c_str(), ioctx));
 
@@ -2217,10 +2217,10 @@ TEST_F(TestClsRbd, image_get_group) {
   string group_id = "group_id_get_group_spec";
 
   cls::rbd::GroupSpec spec_add(group_id, pool_id);
-  ASSERT_EQ(0, image_add_group(&ioctx, image_id, spec_add));
+  ASSERT_EQ(0, image_group_add(&ioctx, image_id, spec_add));
 
   cls::rbd::GroupSpec spec;
-  ASSERT_EQ(0, image_get_group(&ioctx, image_id, &spec));
+  ASSERT_EQ(0, image_group_get(&ioctx, image_id, &spec));
 
   ASSERT_EQ(group_id, spec.group_id);
   ASSERT_EQ(pool_id, spec.pool_id);
index 97ffa7e215739d5065085b4896462a52c52741ab..f830e5341ea558c88e3113b4965af12cef352029 100644 (file)
@@ -202,7 +202,7 @@ public:
   void expect_get_group(MockRefreshImageCtx &mock_image_ctx, int r) {
     auto &expect = EXPECT_CALL(get_mock_io_ctx(mock_image_ctx.md_ctx),
                                exec(mock_image_ctx.header_oid, _, StrEq("rbd"),
-                                    StrEq("image_get_group"), _, _, _));
+                                    StrEq("image_group_get"), _, _, _));
     if (r < 0) {
       expect.WillOnce(Return(r));
     } else {
index 8dc2945c29cfc2b4e4097981704135949fc7d6c7..a4cb4c76251c3507b7b87b287cd1775637f7c35a 100644 (file)
@@ -177,7 +177,7 @@ public:
   void expect_get_group(MockImageCtx &mock_image_ctx, int r) {
     auto &expect = EXPECT_CALL(get_mock_io_ctx(mock_image_ctx.md_ctx),
                                exec(mock_image_ctx.header_oid, _, StrEq("rbd"),
-                                    StrEq("image_get_group"), _, _, _));
+                                    StrEq("image_group_get"), _, _, _));
     if (r < 0) {
       expect.WillOnce(Return(r));
     } else {