From: Jason Dillaman Date: Wed, 20 Feb 2019 21:46:33 +0000 (-0500) Subject: librbd: drop extra check for image watchers from trash move API X-Git-Tag: v14.1.0~1^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c05d2d208be1e52f237c1274e6183a1d084aba90;p=ceph.git librbd: drop extra check for image watchers from trash move API Signed-off-by: Jason Dillaman --- diff --git a/src/librbd/api/Image.cc b/src/librbd/api/Image.cc index b657bc4fedf0..a999ed744b24 100644 --- a/src/librbd/api/Image.cc +++ b/src/librbd/api/Image.cc @@ -735,17 +735,15 @@ int Image::remove(IoCtx& io_ctx, const std::string &image_name, rbd_trash_image_source_t trash_image_source = RBD_TRASH_IMAGE_SOURCE_REMOVING; uint64_t expire_seconds = 0; - bool check_watchers = true; if (config.get_val("rbd_move_to_trash_on_remove")) { // keep the image in the trash upon remove requests trash_image_source = RBD_TRASH_IMAGE_SOURCE_USER; expire_seconds = config.get_val( "rbd_move_to_trash_on_remove_expire_seconds"); - check_watchers = false; } r = Trash::move(io_ctx, trash_image_source, image_name, image_id, - expire_seconds, check_watchers); + expire_seconds); if (r >= 0) { if (trash_image_source == RBD_TRASH_IMAGE_SOURCE_REMOVING) { // proceed with attempting to immediately remove the image diff --git a/src/librbd/api/Migration.cc b/src/librbd/api/Migration.cc index b21b8d454b88..0c56959d76ec 100644 --- a/src/librbd/api/Migration.cc +++ b/src/librbd/api/Migration.cc @@ -1138,7 +1138,7 @@ int Migration::v2_unlink_src_image() { } int r = Trash::move(m_src_io_ctx, RBD_TRASH_IMAGE_SOURCE_MIGRATION, - m_src_image_ctx->name, 0, false); + m_src_image_ctx->name, 0); if (r < 0) { lderr(m_cct) << "failed moving image to trash: " << cpp_strerror(r) << dendl; diff --git a/src/librbd/api/Trash.cc b/src/librbd/api/Trash.cc index 8acbe34edd0d..b4bbb05054c7 100644 --- a/src/librbd/api/Trash.cc +++ b/src/librbd/api/Trash.cc @@ -120,7 +120,7 @@ int enable_mirroring(IoCtx &io_ctx, const std::string &image_id) { template int Trash::move(librados::IoCtx &io_ctx, rbd_trash_image_source_t source, const std::string &image_name, const std::string &image_id, - uint64_t delay, bool check_for_watchers) { + uint64_t delay) { ceph_assert(!image_name.empty() && !image_id.empty()); CephContext *cct((CephContext *)io_ctx.cct()); ldout(cct, 20) << &io_ctx << " name=" << image_name << ", id=" << image_id @@ -163,27 +163,6 @@ int Trash::move(librados::IoCtx &io_ctx, rbd_trash_image_source_t source, } ictx->snap_lock.put_read(); - if (check_for_watchers) { - std::list t_watchers; - int flags = librbd::image::LIST_WATCHERS_FILTER_OUT_MY_INSTANCE | - librbd::image::LIST_WATCHERS_FILTER_OUT_MIRROR_INSTANCES; - C_SaferCond t_on_list_watchers; - auto list_req = librbd::image::ListWatchersRequest::create( - *ictx, flags, &t_watchers, &t_on_list_watchers); - list_req->send(); - r = t_on_list_watchers.wait(); - if (r < 0) { - lderr(cct) << "failed listing watchers:" << cpp_strerror(r) << dendl; - ictx->state->close(); - return r; - } - if (!t_watchers.empty()) { - lderr(cct) << "image has watchers - not moving" << dendl; - ictx->state->close(); - return -EBUSY; - } - } - r = disable_mirroring(ictx); if (r < 0) { ictx->state->close(); @@ -234,8 +213,7 @@ int Trash::move(librados::IoCtx &io_ctx, rbd_trash_image_source_t source, template int Trash::move(librados::IoCtx &io_ctx, rbd_trash_image_source_t source, - const std::string &image_name, uint64_t delay, - bool check_for_watchers) { + const std::string &image_name, uint64_t delay) { CephContext *cct((CephContext *)io_ctx.cct()); ldout(cct, 20) << &io_ctx << " name=" << image_name << dendl; @@ -260,8 +238,7 @@ int Trash::move(librados::IoCtx &io_ctx, rbd_trash_image_source_t source, } ceph_assert(!image_name.empty() && !image_id.empty()); - return Trash::move(io_ctx, source, image_name, image_id, delay, - check_for_watchers); + return Trash::move(io_ctx, source, image_name, image_id, delay); } template diff --git a/src/librbd/api/Trash.h b/src/librbd/api/Trash.h index c671e2c0fcbc..86a4fbf26be5 100644 --- a/src/librbd/api/Trash.h +++ b/src/librbd/api/Trash.h @@ -22,11 +22,10 @@ template struct Trash { static int move(librados::IoCtx &io_ctx, rbd_trash_image_source_t source, - const std::string &image_name, uint64_t delay, - bool check_for_watchers); + const std::string &image_name, uint64_t delay); static int move(librados::IoCtx &io_ctx, rbd_trash_image_source_t source, const std::string &image_name, const std::string &image_id, - uint64_t delay, bool check_for_watchers); + uint64_t delay); static int get(librados::IoCtx &io_ctx, const std::string &id, trash_image_info_t *info); static int list(librados::IoCtx &io_ctx, diff --git a/src/librbd/librbd.cc b/src/librbd/librbd.cc index 039e4eb28f40..3fa1bea1eef3 100644 --- a/src/librbd/librbd.cc +++ b/src/librbd/librbd.cc @@ -594,7 +594,7 @@ namespace librbd { tracepoint(librbd, trash_move_enter, io_ctx.get_pool_name().c_str(), io_ctx.get_id(), name); int r = librbd::api::Trash<>::move(io_ctx, RBD_TRASH_IMAGE_SOURCE_USER, - name, delay, false); + name, delay); tracepoint(librbd, trash_move_exit, r); return r; } @@ -3171,7 +3171,7 @@ extern "C" int rbd_trash_move(rados_ioctx_t p, const char *name, tracepoint(librbd, trash_move_enter, io_ctx.get_pool_name().c_str(), io_ctx.get_id(), name); int r = librbd::api::Trash<>::move(io_ctx, RBD_TRASH_IMAGE_SOURCE_USER, name, - delay, false); + delay); tracepoint(librbd, trash_move_exit, r); return r; } diff --git a/src/test/librbd/test_Trash.cc b/src/test/librbd/test_Trash.cc index e7a1e7f87334..0202ed278b94 100644 --- a/src/test/librbd/test_Trash.cc +++ b/src/test/librbd/test_Trash.cc @@ -63,9 +63,9 @@ TEST_F(TestTrash, UserRemovingSource) { ASSERT_EQ(0, image.close()); ASSERT_EQ(0, api::Trash<>::move(m_ioctx, RBD_TRASH_IMAGE_SOURCE_USER, - image_name1, image_id1, 0, false)); + image_name1, image_id1, 0)); ASSERT_EQ(0, api::Trash<>::move(m_ioctx, RBD_TRASH_IMAGE_SOURCE_REMOVING, - image_name2, image_id2, 0, true)); + image_name2, image_id2, 0)); TrashEntries trash_entries{compare_lambda}; TrashEntries expected_trash_entries{compare_lambda};