From: Jason Dillaman Date: Tue, 24 Mar 2015 17:50:12 +0000 (-0400) Subject: rbd: add new --object-extents option to diff / export-diff X-Git-Tag: v9.0.1~55^2~25 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=eed80f022ad1781b084c1674daabcf6f8f236400;p=ceph.git rbd: add new --object-extents option to diff / export-diff 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 --- diff --git a/doc/man/8/rbd.rst b/doc/man/8/rbd.rst index 162c6b16dda..ccef6bdcdaf 100644 --- a/doc/man/8/rbd.rst +++ b/doc/man/8/rbd.rst @@ -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 diff --git a/src/rbd.cc b/src/rbd.cc index d12dcd45715..2713a76971f 100644 --- a/src/rbd.cc +++ b/src/rbd.cc @@ -108,9 +108,10 @@ void usage() " import image from file (dest\n" " defaults as the filename part\n" " of file). \"-\" for stdin\n" -" diff [--from-snap ] print extents that differ since\n" +" diff [--from-snap ] [--object-extents] \n" +" print extents that differ since\n" " a previous snap, or image creation\n" -" export-diff [--from-snap ] \n" +" export-diff [--from-snap ] [--object-extents] \n" " export an incremental diff to\n" " path, or \"-\" for stdout\n" " merge-diff merge and 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; diff --git a/src/test/cli/rbd/help.t b/src/test/cli/rbd/help.t index b51d0137a07..37506d30ef4 100644 --- a/src/test/cli/rbd/help.t +++ b/src/test/cli/rbd/help.t @@ -21,9 +21,10 @@ import image from file (dest defaults as the filename part of file). "-" for stdin - diff [--from-snap ] print extents that differ since + diff [--from-snap ] [--object-extents] + print extents that differ since a previous snap, or image creation - export-diff [--from-snap ] + export-diff [--from-snap ] [--object-extents] export an incremental diff to path, or "-" for stdout merge-diff merge and into