From: Mykola Golub Date: Wed, 22 Nov 2017 13:48:20 +0000 (+0200) Subject: librbd: shortcut to skip v2 probing when opening v1 image X-Git-Tag: v14.0.1~590^2~29 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=91bb4775d6fbf3117367e9ec484c929f51ee23fc;p=ceph.git librbd: shortcut to skip v2 probing when opening v1 image Signed-off-by: Mykola Golub --- diff --git a/src/librbd/ImageCtx.cc b/src/librbd/ImageCtx.cc index 48f98b12331..0370981819d 100644 --- a/src/librbd/ImageCtx.cc +++ b/src/librbd/ImageCtx.cc @@ -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), diff --git a/src/librbd/Types.h b/src/librbd/Types.h index 9597b71880b..afcb848f98a 100644 --- a/src/librbd/Types.h +++ b/src/librbd/Types.h @@ -116,6 +116,7 @@ struct SnapInfo { enum { OPEN_FLAG_SKIP_OPEN_PARENT = 1 << 0, + OPEN_FLAG_OLD_FORMAT = 1 << 1, }; } // namespace librbd diff --git a/src/librbd/image/OpenRequest.cc b/src/librbd/image/OpenRequest.cc index 33fa0335768..4032f4f2577 100644 --- a/src/librbd/image/OpenRequest.cc +++ b/src/librbd/image/OpenRequest.cc @@ -30,11 +30,18 @@ OpenRequest::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 void OpenRequest::send() { - send_v2_detect_header(); + if (m_image_ctx->old_format) { + send_v1_detect_header(); + } else { + send_v2_detect_header(); + } } template diff --git a/src/librbd/image/RefreshParentRequest.cc b/src/librbd/image/RefreshParentRequest.cc index 37bfc3c1017..57d0c17655f 100644 --- a/src/librbd/image/RefreshParentRequest.cc +++ b/src/librbd/image/RefreshParentRequest.cc @@ -121,11 +121,15 @@ void RefreshParentRequest::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; Context *ctx = create_async_context_callback( m_child_image_ctx, create_context_callback< klass, &klass::handle_open_parent, false>(this)); - OpenRequest *req = OpenRequest::create(m_parent_image_ctx, 0, ctx); + OpenRequest *req = OpenRequest::create(m_parent_image_ctx, flags, ctx); req->send(); }