]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: allow to override format in clone request
authorMykola Golub <mgolub@suse.com>
Fri, 25 Oct 2019 12:59:10 +0000 (15:59 +0300)
committerMykola Golub <mgolub@suse.com>
Mon, 11 Nov 2019 09:41:39 +0000 (09:41 +0000)
Signed-off-by: Mykola Golub <mgolub@suse.com>
(cherry picked from commit 06bda36b42db59bcf64bb2072377cfac4e440df2)

Conflicts:
src/librbd/image/CloneRequest.cc (no pool config overrides in mimic)

src/librbd/image/CloneRequest.cc
src/librbd/image/CloneRequest.h
src/librbd/internal.cc

index 0fb78ec8e570ae54567157a701389de8ed96ddb8..16ae9b6f6725bf4a4c044be4909b99326b0b2555 100644 (file)
@@ -83,23 +83,25 @@ void CloneRequest<I>::validate_options() {
     m_use_p_features = false;
   }
 
-  std::string default_clone_format = m_cct->_conf->get_val<std::string>(
-    "rbd_default_clone_format");
-  if (default_clone_format == "1") {
-    m_clone_format = 1;
-  } else if (default_clone_format == "auto") {
-    librados::Rados rados(m_ioctx);
-    int8_t min_compat_client;
-    int8_t require_min_compat_client;
-    int r = rados.get_min_compatible_client(&min_compat_client,
-                                            &require_min_compat_client);
-    if (r < 0) {
-      complete(r);
-      return;
-    }
-    if (std::max(min_compat_client, require_min_compat_client) <
-          CEPH_RELEASE_MIMIC) {
+  if (m_opts.get(RBD_IMAGE_OPTION_CLONE_FORMAT, &m_clone_format) < 0) {
+    std::string default_clone_format = m_cct->_conf->get_val<std::string>(
+      "rbd_default_clone_format");
+    if (default_clone_format == "1") {
       m_clone_format = 1;
+    } else if (default_clone_format == "auto") {
+      librados::Rados rados(m_ioctx);
+      int8_t min_compat_client;
+      int8_t require_min_compat_client;
+      int r = rados.get_min_compatible_client(&min_compat_client,
+                                              &require_min_compat_client);
+      if (r < 0) {
+        complete(r);
+        return;
+      }
+      if (std::max(min_compat_client, require_min_compat_client) <
+            CEPH_RELEASE_MIMIC) {
+        m_clone_format = 1;
+      }
     }
   }
 
index 7c3d3ea44702b6a2577c58cfc442e743fe1d8eba..14dc6ec00ab21ac118dd903a999bd2c3a9bb10d1 100644 (file)
@@ -104,7 +104,7 @@ private:
   Context *m_on_finish;
 
   CephContext *m_cct;
-  uint32_t m_clone_format = 2;
+  uint64_t m_clone_format = 2;
   bool m_use_p_features;
   uint64_t m_p_features;
   uint64_t m_features;
index 9c84b6ebc16c758377318d31cc2933b7fea1d669..3ae697d580d9d191491789b67e506fdc9e00d591 100644 (file)
@@ -394,6 +394,7 @@ int enable_mirroring(IoCtx &io_ctx, const std::string &image_id) {
     {RBD_IMAGE_OPTION_FEATURES_CLEAR, UINT64},
     {RBD_IMAGE_OPTION_DATA_POOL, STR},
     {RBD_IMAGE_OPTION_FLATTEN, UINT64},
+    {RBD_IMAGE_OPTION_CLONE_FORMAT, UINT64},
   };
 
   std::string image_option_name(int optname) {
@@ -422,6 +423,8 @@ int enable_mirroring(IoCtx &io_ctx, const std::string &image_id) {
       return "data_pool";
     case RBD_IMAGE_OPTION_FLATTEN:
       return "flatten";
+    case RBD_IMAGE_OPTION_CLONE_FORMAT:
+      return "clone_format";
     default:
       return "unknown (" + stringify(optname) + ")";
     }
@@ -927,11 +930,16 @@ int enable_mirroring(IoCtx &io_ctx, const std::string &image_id) {
     }
 
     CephContext *cct = (CephContext *)io_ctx.cct();
-    uint64_t flatten;
-    if (opts.get(RBD_IMAGE_OPTION_FLATTEN, &flatten) == 0) {
+    uint64_t option;
+    if (opts.get(RBD_IMAGE_OPTION_FLATTEN, &option) == 0) {
       lderr(cct) << "create does not support 'flatten' image option" << dendl;
       return -EINVAL;
     }
+    if (opts.get(RBD_IMAGE_OPTION_CLONE_FORMAT, &option) == 0) {
+      lderr(cct) << "create does not support 'clone_format' image option"
+                 << dendl;
+      return -EINVAL;
+    }
 
     ldout(cct, 10) << __func__ << " name=" << image_name << ", "
                   << "id= " << id << ", "
@@ -1838,11 +1846,16 @@ int enable_mirroring(IoCtx &io_ctx, const std::string &image_id) {
           ImageOptions& opts, ProgressContext &prog_ctx, size_t sparse_size)
   {
     CephContext *cct = (CephContext *)dest_md_ctx.cct();
-    uint64_t flatten;
-    if (opts.get(RBD_IMAGE_OPTION_FLATTEN, &flatten) == 0) {
+    uint64_t option;
+    if (opts.get(RBD_IMAGE_OPTION_FLATTEN, &option) == 0) {
       lderr(cct) << "copy does not support 'flatten' image option" << dendl;
       return -EINVAL;
     }
+    if (opts.get(RBD_IMAGE_OPTION_CLONE_FORMAT, &option) == 0) {
+      lderr(cct) << "copy does not support 'clone_format' image option"
+                 << dendl;
+      return -EINVAL;
+    }
 
     ldout(cct, 20) << "copy " << src->name
                   << (src->snap_name.length() ? "@" + src->snap_name : "")