]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/librbd/image/DetachChildRequest.cc
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / librbd / image / DetachChildRequest.cc
index 5103f49d6fa5ccba203545d4088616c0e9daab0c..86cd4a88463323cda76318bdc918192f5fe61d7f 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
@@ -182,6 +184,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();
 }