]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: do not try to open parent journal when removing trash snapshot
authorMykola Golub <mgolub@suse.com>
Tue, 29 Oct 2019 14:39:09 +0000 (16:39 +0200)
committerMykola Golub <mgolub@suse.com>
Wed, 20 Nov 2019 08:17:47 +0000 (10:17 +0200)
Because the parent may be not promoted. Also disallow any proxied
maintenance operations before acquiring the lock.

Fixes: https://tracker.ceph.com/issues/42405
Signed-off-by: Mykola Golub <mgolub@suse.com>
(cherry picked from commit 23e300cbf99987902669baeb6486d9ad37c8c69d)

Conflicts:
src/librbd/image/DetachChildRequest.cc (headers,
                                        RWLock::RLocker vs std::shared_lock,
                                        snap_lock vs image_lock)

src/librbd/image/DetachChildRequest.cc
src/test/librbd/image/test_mock_DetachChildRequest.cc

index a573ac251e4607637f3a47e6ea98601f2c58aace..b10235b35170f96508495958809b7e1727fa49ab 100644 (file)
@@ -6,10 +6,12 @@
 #include "common/errno.h"
 #include "common/WorkQueue.h"
 #include "cls/rbd/cls_rbd_client.h"
+#include "librbd/ExclusiveLock.h"
 #include "librbd/ImageCtx.h"
 #include "librbd/ImageState.h"
 #include "librbd/Operations.h"
 #include "librbd/Utils.h"
+#include "librbd/journal/DisabledPolicy.h"
 #include <string>
 
 #define dout_subsys ceph_subsys_rbd
@@ -176,6 +178,21 @@ void DetachChildRequest<I>::handle_clone_v2_open_parent(int r) {
     return;
   }
 
+  // do not attempt to open the parent journal when removing the trash
+  // snapshot, because the parent may be not promoted
+  if (m_parent_image_ctx->test_features(RBD_FEATURE_JOURNALING)) {
+    RWLock::WLocker snap_locker(m_parent_image_ctx->snap_lock);
+    m_parent_image_ctx->set_journal_policy(new journal::DisabledPolicy());
+  }
+
+  // disallow any proxied maintenance operations
+  {
+    RWLock::RLocker owner_lock(m_parent_image_ctx->owner_lock);
+    if (m_parent_image_ctx->exclusive_lock != nullptr) {
+      m_parent_image_ctx->exclusive_lock->block_requests(0);
+    }
+  }
+
   clone_v2_remove_snapshot();
 }
 
index 4167598c85c7302171e3de8a0107c40b6103a55e..43161480295dfe8a0e4b3c2b518db3e84c28355e 100644 (file)
@@ -118,6 +118,10 @@ public:
       .WillOnce(WithArg<1>(Invoke([this, r](Context* ctx) {
                              image_ctx->op_work_queue->queue(ctx, r);
                            })));
+    if (r == 0) {
+      EXPECT_CALL(mock_image_ctx, test_features(_))
+        .WillOnce(Return(false));
+    }
   }
 
   void expect_close(MockImageCtx &mock_image_ctx, int r) {