]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
Merge pull request #9334 from yangdongsheng/rbd_clone_hiberit
authorJason Dillaman <dillaman@redhat.com>
Wed, 27 Jul 2016 12:23:09 +0000 (08:23 -0400)
committerGitHub <noreply@github.com>
Wed, 27 Jul 2016 12:23:09 +0000 (08:23 -0400)
rbd: inherit the parent image features when cloning an image

Reviewed-by: Jason Dillaman <dillaman@redhat.com>
1  2 
src/include/rbd/librbd.h
src/librbd/internal.cc
src/pybind/rbd/rbd.pyx
src/tools/rbd/action/Import.cc

Simple merge
index be2423559269abccd079eb8b7a5ca4719c56dc77,f082e0839f1fc195eb91f32d07d079fd872c83d2..5e6f42c63c09e263b3195ea886496c04163a900e
@@@ -1573,23 -1504,8 +1591,23 @@@ int mirror_image_disable_internal(Image
        return -EINVAL;
      }
  
 +    if ((p_features & RBD_FEATURE_JOURNALING) != 0) {
 +      bool force_non_primary = !non_primary_global_image_id.empty();
 +      bool is_primary;
 +      int r = Journal<>::is_tag_owner(p_imctx, &is_primary);
 +      if (r < 0) {
 +      lderr(cct) << "failed to determine tag ownership: " << cpp_strerror(r)
 +                 << dendl;
 +      return r;
 +      }
 +      if (!is_primary && !force_non_primary) {
 +      lderr(cct) << "parent is non-primary mirrored image" << dendl;
 +      return -EINVAL;
 +      }
 +    }
 +
      if (use_p_features) {
-       c_opts.set(RBD_IMAGE_OPTION_FEATURES, p_features);
+       features = p_features;
      }
  
      order = p_imctx->order;
Simple merge
index c87d4021b78c756a84de03a0a2756d791883abd3,a935c38b79f878f921d7f26f04c4313339101bfc..4fd9a36eef565eb452be125f78b9c16c48dd729f
@@@ -126,33 -127,11 +127,12 @@@ static int do_import(librbd::RBD &rbd, 
        assert(bdev_size >= 0);
        size = (uint64_t) bdev_size;
      }
 -
 +#ifdef HAVE_POSIX_FADVISE
      posix_fadvise(fd, 0, 0, POSIX_FADV_SEQUENTIAL);
 +#endif
    }
  
-   uint64_t format;
-   r = opts.get(RBD_IMAGE_OPTION_FORMAT, &format);
-   assert(r == 0);
-   if (format == 1) {
-     uint64_t stripe_unit, stripe_count;
-     r = opts.get(RBD_IMAGE_OPTION_STRIPE_UNIT, &stripe_unit);
-     assert(r == 0);
-     r = opts.get(RBD_IMAGE_OPTION_STRIPE_COUNT, &stripe_count);
-     assert(r == 0);
-     // weird striping not allowed with format 1!
-     if ((stripe_unit || stripe_count) &&
-         (stripe_unit != (1ull << order) && stripe_count != 1)) {
-       std::cerr << "non-default striping not allowed with format 1; "
-                 << "use --image-format 2" << std::endl;
-       return -EINVAL;
-     }
-     int order_ = order;
-     r = rbd.create(io_ctx, imgname, size, &order_);
-   } else {
-     r = rbd.create4(io_ctx, imgname, size, opts);
-   }
+   r = rbd.create4(io_ctx, imgname, size, opts);
    if (r < 0) {
      std::cerr << "rbd: image creation failed" << std::endl;
      goto done;