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),
enum {
OPEN_FLAG_SKIP_OPEN_PARENT = 1 << 0,
+ OPEN_FLAG_OLD_FORMAT = 1 << 1,
};
} // namespace librbd
: 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>
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();
}