]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: drop extra check for image watchers from trash move API
authorJason Dillaman <dillaman@redhat.com>
Wed, 20 Feb 2019 21:46:33 +0000 (16:46 -0500)
committerJason Dillaman <dillaman@redhat.com>
Wed, 20 Feb 2019 21:47:07 +0000 (16:47 -0500)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/librbd/api/Image.cc
src/librbd/api/Migration.cc
src/librbd/api/Trash.cc
src/librbd/api/Trash.h
src/librbd/librbd.cc
src/test/librbd/test_Trash.cc

index b657bc4fedf061849d7ed06822d0d3ea7f3c6640..a999ed744b242d5a26aae582898476a04b430e4a 100644 (file)
@@ -735,17 +735,15 @@ int Image<I>::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<bool>("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<uint64_t>(
         "rbd_move_to_trash_on_remove_expire_seconds");
-      check_watchers = false;
     }
 
     r = Trash<I>::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
index b21b8d454b8812ccc0f75c97d3636ae4e396c90b..0c56959d76ececb0be40712cab4fad5d271a4e00 100644 (file)
@@ -1138,7 +1138,7 @@ int Migration<I>::v2_unlink_src_image() {
   }
 
   int r = Trash<I>::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;
index 8acbe34edd0db1152475668e61432657e8b35d13..b4bbb05054c7bcfd9a4eeadedf3b7df3990e638f 100644 (file)
@@ -120,7 +120,7 @@ int enable_mirroring(IoCtx &io_ctx, const std::string &image_id) {
 template <typename I>
 int Trash<I>::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<I>::move(librados::IoCtx &io_ctx, rbd_trash_image_source_t source,
     }
     ictx->snap_lock.put_read();
 
-    if (check_for_watchers) {
-      std::list<obj_watch_t> 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<I>::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<I>(ictx);
     if (r < 0) {
       ictx->state->close();
@@ -234,8 +213,7 @@ int Trash<I>::move(librados::IoCtx &io_ctx, rbd_trash_image_source_t source,
 
 template <typename I>
 int Trash<I>::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<I>::move(librados::IoCtx &io_ctx, rbd_trash_image_source_t source,
   }
 
   ceph_assert(!image_name.empty() && !image_id.empty());
-  return Trash<I>::move(io_ctx, source, image_name, image_id, delay,
-                        check_for_watchers);
+  return Trash<I>::move(io_ctx, source, image_name, image_id, delay);
 }
 
 template <typename I>
index c671e2c0fcbcf896e0cbbf09c701705dc8b6259a..86a4fbf26be5ff39cf51ee1d012fcb22a0e1fbc1 100644 (file)
@@ -22,11 +22,10 @@ template <typename ImageCtxT = librbd::ImageCtx>
 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,
index 039e4eb28f40a9c27244e11fc6c32123d75878b7..3fa1bea1eef39ae3bdbc3868f4092abf66437ea3 100644 (file)
@@ -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;
 }
index e7a1e7f873347fda9182d4d69abbceea0de27ccb..0202ed278b9445d4c1d941537ec9729765966818 100644 (file)
@@ -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};