]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: shortcut to skip v2 probing when opening v1 image
authorMykola Golub <to.my.trociny@gmail.com>
Wed, 22 Nov 2017 13:48:20 +0000 (15:48 +0200)
committerJason Dillaman <dillaman@redhat.com>
Tue, 14 Aug 2018 22:29:44 +0000 (18:29 -0400)
Signed-off-by: Mykola Golub <mgolub@suse.com>
src/librbd/ImageCtx.cc
src/librbd/Types.h
src/librbd/image/OpenRequest.cc
src/librbd/image/RefreshParentRequest.cc

index 48f98b12331506d09b4118377f1a2295886642d2..0370981819de36751adc46d8a437cf3248113361 100644 (file)
@@ -113,7 +113,7 @@ public:
       copyup_list_lock(util::unique_lock_name("librbd::ImageCtx::copyup_list_lock", this)),
       completed_reqs_lock(util::unique_lock_name("librbd::ImageCtx::completed_reqs_lock", this)),
       extra_read_flags(0),
-      old_format(true),
+      old_format(false),
       order(0), size(0), features(0),
       format_string(NULL),
       id(image_id), parent(NULL),
index 9597b71880b67a290c8c99c374a938fc1f47a207..afcb848f98a1500aab19d7c424c3e6a99ab44288 100644 (file)
@@ -116,6 +116,7 @@ struct SnapInfo {
 
 enum {
   OPEN_FLAG_SKIP_OPEN_PARENT = 1 << 0,
+  OPEN_FLAG_OLD_FORMAT = 1 << 1,
 };
 
 } // namespace librbd
index 33fa0335768a21842ae40bae1189c1f8ba05da31..4032f4f2577ccd49ff3923d5408e97900c8ae78f 100644 (file)
@@ -30,11 +30,18 @@ OpenRequest<I>::OpenRequest(I *image_ctx, uint64_t flags,
   : m_image_ctx(image_ctx),
     m_skip_open_parent_image(flags & OPEN_FLAG_SKIP_OPEN_PARENT),
     m_on_finish(on_finish), m_error_result(0) {
+  if ((flags & OPEN_FLAG_OLD_FORMAT) != 0) {
+    m_image_ctx->old_format = true;
+  }
 }
 
 template <typename I>
 void OpenRequest<I>::send() {
-  send_v2_detect_header();
+  if (m_image_ctx->old_format) {
+    send_v1_detect_header();
+  } else {
+    send_v2_detect_header();
+  }
 }
 
 template <typename I>
index 37bfc3c10177d0d36c86ed6db621239a6e7ee62b..57d0c17655f065281287d3daf0301e2b8547da95 100644 (file)
@@ -121,11 +121,15 @@ void RefreshParentRequest<I>::send_open_parent() {
     m_parent_image_ctx->set_read_flag(librados::OPERATION_LOCALIZE_READS);
   }
 
+  uint64_t flags = 0;
+  if (m_parent_md.spec.image_id.empty()) {
+    flags |= OPEN_FLAG_OLD_FORMAT;
+  }
   using klass = RefreshParentRequest<I>;
   Context *ctx = create_async_context_callback(
     m_child_image_ctx, create_context_callback<
       klass, &klass::handle_open_parent, false>(this));
-  OpenRequest<I> *req = OpenRequest<I>::create(m_parent_image_ctx, 0, ctx);
+  OpenRequest<I> *req = OpenRequest<I>::create(m_parent_image_ctx, flags, ctx);
   req->send();
 }