]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd/migration: fix issue with prepare-import and native-format
authorJason Dillaman <dillaman@redhat.com>
Tue, 27 Oct 2020 01:25:02 +0000 (21:25 -0400)
committerJason Dillaman <dillaman@redhat.com>
Sun, 1 Nov 2020 14:22:38 +0000 (09:22 -0500)
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 <dillaman@redhat.com>
src/librbd/migration/NativeFormat.cc

index b6046d0d2d1465abb415ef09c931dc05ccd60a9e..cb3b5164abb2b2e07228ae0b54b2e3b193bcbaed 100644 (file)
@@ -109,11 +109,13 @@ void NativeFormat<I>::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<bool>("rbd_balance_parent_reads")) {
-    m_image_ctx->set_read_flag(librados::OPERATION_BALANCE_READS);
-  } else if (m_image_ctx->child->config.template get_val<bool>("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<bool>("rbd_balance_parent_reads")) {
+      m_image_ctx->set_read_flag(librados::OPERATION_BALANCE_READS);
+    } else if (m_image_ctx->child->config.template get_val<bool>("rbd_localize_parent_reads")) {
+      m_image_ctx->set_read_flag(librados::OPERATION_LOCALIZE_READS);
+    }
   }
 
   // open the source RBD image