]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: skip mirror image verification when pruning rbd-mirror watchers
authorJason Dillaman <dillaman@redhat.com>
Fri, 15 Feb 2019 14:11:36 +0000 (09:11 -0500)
committerJason Dillaman <dillaman@redhat.com>
Wed, 20 Feb 2019 21:47:07 +0000 (16:47 -0500)
When an image is moved to the trash, mirroring is disabled which will remove
the image id from the mirroring directory. If you then quickly attempt to
remove the image from the trash, it might fail if the rbd-mirror daemon hasn't
closed the image since it fails to filter out rbd-mirror daemon watchers
against images with mirroring disabled.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/librbd/image/ListWatchersRequest.cc
src/librbd/image/ListWatchersRequest.h
src/test/librbd/image/test_mock_ListWatchersRequest.cc

index c6251f49253bead44b1ff0b471b113ff0b617f3d..ad3a20caf0ba1243141c0282ff2db2acb545c7aa 100644 (file)
@@ -69,12 +69,11 @@ void ListWatchersRequest<I>::handle_list_image_watchers(int r) {
     return;
   }
 
-  get_mirror_image();
+  list_mirror_watchers();
 }
 
 template<typename I>
-void ListWatchersRequest<I>::get_mirror_image() {
-  ldout(m_cct, 20) << dendl;
+void ListWatchersRequest<I>::list_mirror_watchers() {
   if ((m_object_watchers.empty()) ||
       (m_flags & LIST_WATCHERS_FILTER_OUT_MIRROR_INSTANCES) == 0 ||
       (m_image_ctx.features & RBD_FEATURE_JOURNALING) == 0) {
@@ -82,35 +81,6 @@ void ListWatchersRequest<I>::get_mirror_image() {
     return;
   }
 
-  librados::ObjectReadOperation op;
-  cls_client::mirror_image_get_start(&op, m_image_ctx.id);
-
-  using klass = ListWatchersRequest<I>;
-  librados::AioCompletion *comp =
-    create_rados_callback<klass, &klass::handle_get_mirror_image>(this);
-  m_out_bl.clear();
-  int r = m_image_ctx.md_ctx.aio_operate(RBD_MIRRORING, comp, &op, &m_out_bl);
-  ceph_assert(r == 0);
-  comp->release();
-}
-
-template<typename I>
-void ListWatchersRequest<I>::handle_get_mirror_image(int r) {
-  ldout(m_cct, 20) << "r=" << r << dendl;
-
-  if (r == -ENOENT) {
-    finish(0);
-    return;
-  } else if (r < 0) {
-    ldout(m_cct, 1) << "error retrieving mirror image: " << cpp_strerror(r)
-                    << dendl;
-  }
-
-  list_mirror_watchers();
-}
-
-template<typename I>
-void ListWatchersRequest<I>::list_mirror_watchers() {
   ldout(m_cct, 20) << dendl;
 
   librados::ObjectReadOperation op;
index 660098183bcca0754093211d49e81ecc16460b95..941bf728ad6fb9fd6530c1e29559973736ad4112 100644 (file)
@@ -42,9 +42,6 @@ private:
    * LIST_IMAGE_WATCHERS
    *    |
    *    v
-   * GET_MIRROR_IMAGE (skip if not needed)
-   *    |
-   *    v
    * LIST_MIRROR_WATCHERS (skip if not needed)
    *    |
    *    v
@@ -70,9 +67,6 @@ private:
   void list_image_watchers();
   void handle_list_image_watchers(int r);
 
-  void get_mirror_image();
-  void handle_get_mirror_image(int r);
-
   void list_mirror_watchers();
   void handle_list_mirror_watchers(int r);
 
index f2915925a72be494e02cd58a4b54cfb66b29d4a4..d90fc4ab0bc6be2aa9632efc064cb09d87558995 100644 (file)
@@ -78,13 +78,6 @@ public:
     expect_list_watchers(mock_image_ctx, RBD_MIRRORING, watchers, r);
   }
 
-  void expect_mirror_image_get(MockImageCtx &mock_image_ctx, int r) {
-    EXPECT_CALL(get_mock_io_ctx(mock_image_ctx.md_ctx),
-                exec(RBD_MIRRORING, _, StrEq("rbd"), StrEq("mirror_image_get"),
-                     _, _, _))
-      .WillOnce(Return(r));
-  }
-
   void expect_get_watch_handle(MockImageWatcher &mock_watcher,
                                uint64_t watch_handle) {
     EXPECT_CALL(mock_watcher, get_watch_handle())
@@ -198,7 +191,6 @@ TEST_F(TestMockListWatchersRequest, FilterOutMirrorInstance) {
   InSequence seq;
   expect_list_image_watchers(mock_image_ctx,
                              {watcher("a", 123), watcher("b", 456)}, 0);
-  expect_mirror_image_get(mock_image_ctx, 0);
   expect_list_mirror_watchers(mock_image_ctx, {watcher("b", 789)}, 0);
   expect_get_watch_handle(*mock_image_ctx.image_watcher, 123);