]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd: import/export image stripe_unit and stripe_count.
authorDongsheng Yang <dongsheng.yang@easystack.cn>
Fri, 14 Oct 2016 02:38:30 +0000 (22:38 -0400)
committerDongsheng Yang <dongsheng.yang@easystack.cn>
Sun, 19 Feb 2017 12:42:03 +0000 (20:42 +0800)
Signed-off-by: Dongsheng Yang <dongsheng.yang@easystack.cn>
src/tools/rbd/Utils.h
src/tools/rbd/action/Export.cc
src/tools/rbd/action/Import.cc

index b885631544e7f74e310643115c4acf5f743865ef..9ecb21eecc61d813f4d93d2e16d1611ddc02d03d 100644 (file)
@@ -29,6 +29,8 @@ static const std::string RBD_DIFF_BANNER_V2 ("rbd diff v2\n");
 
 #define RBD_EXPORT_IMAGE_ORDER         'O'
 #define RBD_EXPORT_IMAGE_FEATURES      'T'
+#define RBD_EXPORT_IMAGE_STRIPEUNIT    'U'
+#define RBD_EXPORT_IMAGE_STRIPECOUNT   'C'
 #define RBD_EXPORT_IMAGE_END           'E'
 
 enum SnapshotPresence {
index bac84cf619c25f5f450dbe0fafe3fad28f25285a..7fada5442ca75deb09388f65a55df5725b7dcaa0 100644 (file)
@@ -415,6 +415,19 @@ static int do_export(librbd::Image& image, const char *path, bool no_progress, i
     ::encode(tag, bl);
     ::encode(features, bl);
 
+    // encode stripe_unit and stripe_count
+    tag = RBD_EXPORT_IMAGE_STRIPEUNIT;
+    uint64_t stripe_unit;
+    stripe_unit = image.get_stripe_unit();
+    ::encode(tag, bl);
+    ::encode(stripe_unit, bl);
+
+    tag = RBD_EXPORT_IMAGE_STRIPECOUNT;
+    uint64_t stripe_count;
+    stripe_count = image.get_stripe_count();
+    ::encode(tag, bl);
+    ::encode(stripe_count, bl);
+
     // encode end tag
     tag = RBD_EXPORT_IMAGE_END;
     ::encode(tag, bl);
index 8945bb94c00b6fa220babfa0343fa9484eb4c4ca..453bf5e35dec3f87fddbd9b00f5ad68f03ee3bdd 100644 (file)
@@ -420,6 +420,24 @@ static int do_import(librbd::RBD &rbd, librados::IoCtx& io_ctx,
        if (opts.get(RBD_IMAGE_OPTION_FEATURES, &features) != 0) {
          opts.set(RBD_IMAGE_OPTION_FEATURES, features);
        }
+      } else if (tag == RBD_EXPORT_IMAGE_STRIPEUNIT) {
+       uint64_t stripe_unit = 0;
+       r = safe_read_exact(fd, &stripe_unit, 8);
+       if (r < 0) {
+         goto done;
+       }
+       if (opts.get(RBD_IMAGE_OPTION_STRIPE_UNIT, &stripe_unit) != 0) {
+         opts.set(RBD_IMAGE_OPTION_STRIPE_UNIT, stripe_unit);
+       }
+      } else if (tag == RBD_EXPORT_IMAGE_STRIPECOUNT) {
+       uint64_t stripe_count = 0;
+       r = safe_read_exact(fd, &stripe_count, 8);
+       if (r < 0) {
+         goto done;
+       }
+       if (opts.get(RBD_IMAGE_OPTION_STRIPE_COUNT, &stripe_count) != 0) {
+         opts.set(RBD_IMAGE_OPTION_STRIPE_COUNT, stripe_count);
+       }
       } else {
        std::cerr << "rbd: invalid tag in image priority zone: " << tag << std::endl;
        r = -EINVAL;