From: Jason Dillaman Date: Tue, 27 Oct 2020 01:25:02 +0000 (-0400) Subject: librbd/migration: fix issue with prepare-import and native-format X-Git-Tag: v16.1.0~702^2~13 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9ad4d7936afcc1da3d032f5486b856e932d04a4d;p=ceph.git librbd/migration: fix issue with prepare-import and native-format When preparing an import, the native format can not expect to have the child image opened since it hasn't been created yet. Signed-off-by: Jason Dillaman --- diff --git a/src/librbd/migration/NativeFormat.cc b/src/librbd/migration/NativeFormat.cc index b6046d0d2d14..cb3b5164abb2 100644 --- a/src/librbd/migration/NativeFormat.cc +++ b/src/librbd/migration/NativeFormat.cc @@ -109,11 +109,13 @@ void NativeFormat::open(Context* on_finish) { m_image_ctx->id = m_image_id; } - // set rados flags for reading the parent image - if (m_image_ctx->child->config.template get_val("rbd_balance_parent_reads")) { - m_image_ctx->set_read_flag(librados::OPERATION_BALANCE_READS); - } else if (m_image_ctx->child->config.template get_val("rbd_localize_parent_reads")) { - m_image_ctx->set_read_flag(librados::OPERATION_LOCALIZE_READS); + if (m_image_ctx->child != nullptr) { + // set rados flags for reading the parent image + if (m_image_ctx->child->config.template get_val("rbd_balance_parent_reads")) { + m_image_ctx->set_read_flag(librados::OPERATION_BALANCE_READS); + } else if (m_image_ctx->child->config.template get_val("rbd_localize_parent_reads")) { + m_image_ctx->set_read_flag(librados::OPERATION_LOCALIZE_READS); + } } // open the source RBD image