From: Jason Dillaman Date: Tue, 16 Jan 2018 18:20:31 +0000 (-0500) Subject: cls/rbd: renamed image group add/remove/get operations X-Git-Tag: v13.0.2~426^2~8 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=94dc5aeb24c16a5c8beb11fd7fa752093d9d43ad;p=ceph.git cls/rbd: renamed image group add/remove/get operations 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 --- diff --git a/src/cls/rbd/cls_rbd.cc b/src/cls/rbd/cls_rbd.cc index a595a773b142..c85e0e4432b9 100644 --- a/src/cls/rbd/cls_rbd.cc +++ b/src/cls/rbd/cls_rbd.cc @@ -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); diff --git a/src/cls/rbd/cls_rbd_client.cc b/src/cls/rbd/cls_rbd_client.cc index 16b9d552152a..b84cfa003335 100644 --- a/src/cls/rbd/cls_rbd_client.cc +++ b/src/cls/rbd/cls_rbd_client.cc @@ -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, diff --git a/src/cls/rbd/cls_rbd_client.h b/src/cls/rbd/cls_rbd_client.h index 4b3fbf9874c5..ee29bb84fddc 100644 --- a/src/cls/rbd/cls_rbd_client.h +++ b/src/cls/rbd/cls_rbd_client.h @@ -422,14 +422,14 @@ namespace librbd { std::vector *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); diff --git a/src/librbd/api/Group.cc b/src/librbd/api/Group.cc index e6deec1cc1ef..71a9cd348d76 100644 --- a/src/librbd/api/Group.cc +++ b/src/librbd/api/Group.cc @@ -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::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; diff --git a/src/librbd/image/RefreshRequest.cc b/src/librbd/image/RefreshRequest.cc index cc485c405a61..0b99d1c29e8d 100644 --- a/src/librbd/image/RefreshRequest.cc +++ b/src/librbd/image/RefreshRequest.cc @@ -456,7 +456,7 @@ void RefreshRequest::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; librados::AioCompletion *comp = create_rados_callback< @@ -476,7 +476,7 @@ Context *RefreshRequest::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 diff --git a/src/librbd/image/RemoveRequest.cc b/src/librbd/image/RemoveRequest.cc index 83e3b48be70a..65cc9b72cca4 100644 --- a/src/librbd/image/RemoveRequest.cc +++ b/src/librbd/image/RemoveRequest.cc @@ -298,7 +298,7 @@ void RemoveRequest::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; librados::AioCompletion *rados_completion = create_rados_callback< @@ -317,7 +317,7 @@ void RemoveRequest::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: " diff --git a/src/test/cls_rbd/test_cls_rbd.cc b/src/test/cls_rbd/test_cls_rbd.cc index f1058a49ee35..d84ae9b31301 100644 --- a/src/test/cls_rbd/test_cls_rbd.cc +++ b/src/test/cls_rbd/test_cls_rbd.cc @@ -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 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 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); diff --git a/src/test/librbd/image/test_mock_RefreshRequest.cc b/src/test/librbd/image/test_mock_RefreshRequest.cc index 97ffa7e21573..f830e5341ea5 100644 --- a/src/test/librbd/image/test_mock_RefreshRequest.cc +++ b/src/test/librbd/image/test_mock_RefreshRequest.cc @@ -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 { diff --git a/src/test/librbd/image/test_mock_RemoveRequest.cc b/src/test/librbd/image/test_mock_RemoveRequest.cc index 8dc2945c29cf..a4cb4c76251c 100644 --- a/src/test/librbd/image/test_mock_RemoveRequest.cc +++ b/src/test/librbd/image/test_mock_RemoveRequest.cc @@ -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 {