]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd: add new --object-extents option to diff / export-diff
authorJason Dillaman <dillaman@redhat.com>
Tue, 24 Mar 2015 17:50:12 +0000 (13:50 -0400)
committerJason Dillaman <dillaman@redhat.com>
Mon, 13 Apr 2015 01:17:33 +0000 (21:17 -0400)
The rbd CLI can now use the object map to compute the diffs between
two snapshots.  This option is enabled with the new '--object-extents'
option.

Fixes: #7787
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
doc/man/8/rbd.rst
src/rbd.cc
src/test/cli/rbd/help.t

index 162c6b16dda37d510dfc454ebd124f460c6fe79e..ccef6bdcdaf743271b13f6ee3abf479f6f1b7112 100644 (file)
@@ -142,6 +142,15 @@ Parameters
    This will disable features that are dependent upon exclusive ownership
    of the image.
 
+.. option:: --object-extents
+
+   Specifies that the diff should be limited to the extents of a full object
+   instead of showing intra-object deltas. When the object map feature is
+   enabled on an image, limiting the diff to the object extents will
+   dramatically improve performance since the differences can be computed
+   by examining the in-memory object map instead of querying RADOS for each
+   object within the image.
+
 Commands
 ========
 
@@ -204,7 +213,7 @@ Commands
   The --stripe-unit and --stripe-count arguments are optional, but must be
   used together.
 
-:command:`export-diff` [*image-name*] [*dest-path*] [--from-snap *snapname*]
+:command:`export-diff` [*image-name*] [*dest-path*] [--from-snap *snapname*] [--object-extents]
   Exports an incremental diff for an image to dest path (use - for stdout).  If
   an initial snapshot is specified, only changes since that snapshot are included; otherwise,
   any regions of the image that contain data are included.  The end snapshot is specified
@@ -226,7 +235,7 @@ Commands
   continuing.  If there was an end snapshot we verify it does not already exist before
   applying the changes, and create the snapshot when we are done.
 
-:command:`diff` [*image-name*] [--from-snap *snapname*]
+:command:`diff` [*image-name*] [--from-snap *snapname*] [--object-extents]
   Dump a list of byte extents in the image that have changed since the specified start
   snapshot, or since the image was created.  Each output line includes the starting offset
   (in bytes), the length of the region (in bytes), and either 'zero' or 'data' to indicate
index d12dcd45715d79d7c069980e25b2f2cfb2fb5c0e..2713a76971fac84648ad037b8b2ea324386ef81e 100644 (file)
@@ -108,9 +108,10 @@ void usage()
 "         <path> <image-name>                  import image from file (dest\n"
 "                                              defaults as the filename part\n"
 "                                              of file). \"-\" for stdin\n"
-"  diff <image-name> [--from-snap <snap-name>] print extents that differ since\n"
+"  diff [--from-snap <snap-name>] [--object-extents] <image-name>\n"
+"                                              print extents that differ since\n"
 "                                              a previous snap, or image creation\n"
-"  export-diff <image-name> [--from-snap <snap-name>] <path>\n"
+"  export-diff [--from-snap <snap-name>] [--object-extents] <image-name> <path>\n"
 "                                              export an incremental diff to\n"
 "                                              path, or \"-\" for stdout\n"
 "  merge-diff <diff1> <diff2> <path>           merge <diff1> and <diff2> into\n"
@@ -1244,7 +1245,7 @@ static int export_diff_cb(uint64_t ofs, size_t _len, int exists, void *arg)
 }
 
 static int do_export_diff(librbd::Image& image, const char *fromsnapname,
-                         const char *endsnapname,
+                         const char *endsnapname, bool object_extents,
                          const char *path)
 {
   int r;
@@ -1295,7 +1296,8 @@ static int do_export_diff(librbd::Image& image, const char *fromsnapname,
   }
 
   ExportContext ec(&image, fd, info.size);
-  r = image.diff_iterate(fromsnapname, 0, info.size, export_diff_cb, (void *)&ec);
+  r = image.diff_iterate2(fromsnapname, 0, info.size, true, object_extents,
+                          export_diff_cb, (void *)&ec);
   if (r < 0)
     goto out;
 
@@ -1340,7 +1342,7 @@ static int diff_cb(uint64_t ofs, size_t len, int exists, void *arg)
 }
 
 static int do_diff(librbd::Image& image, const char *fromsnapname,
-                  Formatter *f)
+                   bool object_extents, Formatter *f)
 {
   int r;
   librbd::image_info_t info;
@@ -1360,7 +1362,8 @@ static int do_diff(librbd::Image& image, const char *fromsnapname,
     om.t->define_column("Type", TextTable::LEFT, TextTable::LEFT);
   }
 
-  r = image.diff_iterate(fromsnapname, 0, info.size, diff_cb, &om);
+  r = image.diff_iterate2(fromsnapname, 0, info.size, true, object_extents,
+                          diff_cb, &om);
   if (f) {
     f->close_section();
     f->flush(cout);
@@ -2762,6 +2765,7 @@ int main(int argc, const char **argv)
   long long stripe_unit = 0, stripe_count = 0;
   long long bench_io_size = 4096, bench_io_threads = 16, bench_bytes = 1 << 30;
   string bench_pattern = "seq";
+  bool diff_object_extents = false;
 
   std::string val, parse_err;
   std::ostringstream err;
@@ -2885,6 +2889,8 @@ int main(int argc, const char **argv)
        output_format = strdup(val.c_str());
        output_format_specified = true;
       }
+    } else if (ceph_argparse_flag(args, i, "--object-extents", (char *)NULL)) {
+      diff_object_extents = true;
     } else if (ceph_argparse_binary_flag(args, i, &pretty_format, NULL, "--pretty-format", (char*)NULL)) {
     } else {
       ++i;
@@ -3545,7 +3551,7 @@ if (!set_conf_param(v, p1, p2, p3)) { \
     break;
 
   case OPT_DIFF:
-    r = do_diff(image, fromsnapname, formatter.get());
+    r = do_diff(image, fromsnapname, diff_object_extents, formatter.get());
     if (r < 0) {
       cerr << "rbd: diff error: " << cpp_strerror(-r) << std::endl;
       return -r;
@@ -3557,7 +3563,7 @@ if (!set_conf_param(v, p1, p2, p3)) { \
       cerr << "rbd: export-diff requires pathname" << std::endl;
       return EINVAL;
     }
-    r = do_export_diff(image, fromsnapname, snapname, path);
+    r = do_export_diff(image, fromsnapname, snapname, diff_object_extents, path);
     if (r < 0) {
       cerr << "rbd: export-diff error: " << cpp_strerror(-r) << std::endl;
       return -r;
index b51d0137a07aade94b392b424a6af675ca7a89ce..37506d30ef4e8eba5927b1a0454bbba5cfa998db 100644 (file)
            <path> <image-name>                  import image from file (dest
                                                 defaults as the filename part
                                                 of file). "-" for stdin
-    diff <image-name> [--from-snap <snap-name>] print extents that differ since
+    diff [--from-snap <snap-name>] [--object-extents] <image-name>
+                                                print extents that differ since
                                                 a previous snap, or image creation
-    export-diff <image-name> [--from-snap <snap-name>] <path>
+    export-diff [--from-snap <snap-name>] [--object-extents] <image-name> <path>
                                                 export an incremental diff to
                                                 path, or "-" for stdout
     merge-diff <diff1> <diff2> <path>           merge <diff1> and <diff2> into