]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: allow striping to be specified for clones
authorSage Weil <sage@inktank.com>
Sat, 6 Oct 2012 00:59:09 +0000 (17:59 -0700)
committerSage Weil <sage@inktank.com>
Mon, 15 Oct 2012 22:34:06 +0000 (15:34 -0700)
Signed-off-by: Sage Weil <sage@inktank.com>
src/include/rbd/librbd.h
src/include/rbd/librbd.hpp
src/librbd/internal.cc
src/librbd/internal.h
src/librbd/librbd.cc

index 551184d4c4f0a859ecd5d566e4c8dbad02541a2b..732c25682de1cec9ec0966e1161d2b84ad3b2f2d 100644 (file)
@@ -93,6 +93,10 @@ int rbd_create3(rados_ioctx_t io, const char *name, uint64_t size,
 int rbd_clone(rados_ioctx_t p_ioctx, const char *p_name,
              const char *p_snapname, rados_ioctx_t c_ioctx,
              const char *c_name, uint64_t features, int *c_order);
+int rbd_clone2(rados_ioctx_t p_ioctx, const char *p_name,
+              const char *p_snapname, rados_ioctx_t c_ioctx,
+              const char *c_name, uint64_t features, int *c_order,
+              uint64_t stripe_unit, int stripe_count);
 int rbd_remove(rados_ioctx_t io, const char *name);
 int rbd_remove_with_progress(rados_ioctx_t io, const char *name,
                             librbd_progress_fn_t cb, void *cbdata);
index fe6bd92d44282641ab51bc44142cef58f6b9fc36..202ed628a38b308564c41111431653debe10aa7a 100644 (file)
@@ -82,6 +82,9 @@ public:
   int clone(IoCtx& p_ioctx, const char *p_name, const char *p_snapname,
               IoCtx& c_ioctx, const char *c_name, uint64_t features,
               int *c_order);
+  int clone2(IoCtx& p_ioctx, const char *p_name, const char *p_snapname,
+            IoCtx& c_ioctx, const char *c_name, uint64_t features,
+            int *c_order, uint64_t stripe_unit, int stripe_count);
   int remove(IoCtx& io_ctx, const char *name);
   int remove_with_progress(IoCtx& io_ctx, const char *name, ProgressContext& pctx);
   int rename(IoCtx& src_io_ctx, const char *srcname, const char *destname);
index c97eeac0a8d04cb7839342631672f8f03b0b71f2..7dc55e837c4a9d9f65a01df754474f2d4165567e 100644 (file)
@@ -777,13 +777,17 @@ reprotect_and_return_err:
    */
   int clone(IoCtx& p_ioctx, const char *p_name, const char *p_snap_name,
            IoCtx& c_ioctx, const char *c_name,
-           uint64_t features, int *c_order)
+           uint64_t features, int *c_order,
+           uint64_t stripe_unit, int stripe_count)
   {
     CephContext *cct = (CephContext *)p_ioctx.cct();
     ldout(cct, 20) << "clone " << &p_ioctx << " name " << p_name << " snap "
                   << p_snap_name << "to child " << &c_ioctx << " name "
                   << c_name << " features = " << features << " order = "
-                  << *c_order << dendl;
+                  << *c_order
+                  << " stripe_unit = " << stripe_unit
+                  << " stripe_count = " << stripe_count
+                  << dendl;
 
     if (features & ~RBD_FEATURES_ALL) {
       lderr(cct) << "librbd does not support requested features" << dendl;
@@ -851,7 +855,7 @@ reprotect_and_return_err:
     if (!order)
       order = p_imctx->order;
 
-    r = create(c_ioctx, c_name, size, false, features, &order, p_imctx->stripe_unit, p_imctx->stripe_count);
+    r = create(c_ioctx, c_name, size, false, features, &order, stripe_unit, stripe_count);
     if (r < 0) {
       lderr(cct) << "error creating child: " << cpp_strerror(r) << dendl;
       goto err_close_parent;
index 51a76a4fa267bb280776822212aee3382ea7ce27..55f6dfb2e8f2edc2ece46d4daffc64a6ffc6374f 100644 (file)
@@ -83,7 +83,8 @@ namespace librbd {
             uint64_t stripe_unit, uint64_t stripe_count);
   int clone(IoCtx& p_ioctx, const char *p_name, const char *p_snap_name,
            IoCtx& c_ioctx, const char *c_name,
-           uint64_t features, int *c_order);
+           uint64_t features, int *c_order,
+           uint64_t stripe_unit, int stripe_count);
   int rename(librados::IoCtx& io_ctx, const char *srcname, const char *dstname);
   int info(ImageCtx *ictx, image_info_t& info, size_t image_size);
   int get_old_format(ImageCtx *ictx, uint8_t *old);
index f37eadfea400e068cc8d25bd96e5086bd24d78f5..46b29ad5cdb245b8bc1dcae1f64350343ca3d080 100644 (file)
@@ -123,7 +123,15 @@ namespace librbd {
                 int *c_order)
   {
     return librbd::clone(p_ioctx, p_name, p_snap_name, c_ioctx, c_name,
-                        features, c_order);
+                        features, c_order, 0, 0);
+  }
+
+  int RBD::clone2(IoCtx& p_ioctx, const char *p_name, const char *p_snap_name,
+                 IoCtx& c_ioctx, const char *c_name, uint64_t features,
+                 int *c_order, uint64_t stripe_unit, int stripe_count)
+  {
+    return librbd::clone(p_ioctx, p_name, p_snap_name, c_ioctx, c_name,
+                        features, c_order, stripe_unit, stripe_count);
   }
 
   int RBD::remove(IoCtx& io_ctx, const char *name)
@@ -515,7 +523,19 @@ extern "C" int rbd_clone(rados_ioctx_t p_ioctx, const char *p_name,
   librados::IoCtx::from_rados_ioctx_t(p_ioctx, p_ioc);
   librados::IoCtx::from_rados_ioctx_t(c_ioctx, c_ioc);
   return librbd::clone(p_ioc, p_name, p_snap_name, c_ioc, c_name,
-                      features, c_order);
+                      features, c_order, 0, 0);
+}
+
+extern "C" int rbd_clone2(rados_ioctx_t p_ioctx, const char *p_name,
+                         const char *p_snap_name, rados_ioctx_t c_ioctx,
+                         const char *c_name, uint64_t features, int *c_order,
+                         uint64_t stripe_unit, int stripe_count)
+{
+  librados::IoCtx p_ioc, c_ioc;
+  librados::IoCtx::from_rados_ioctx_t(p_ioctx, p_ioc);
+  librados::IoCtx::from_rados_ioctx_t(c_ioctx, c_ioc);
+  return librbd::clone(p_ioc, p_name, p_snap_name, c_ioc, c_name,
+                      features, c_order, stripe_unit, stripe_count);
 }
 
 extern "C" int rbd_remove(rados_ioctx_t p, const char *name)