From: Dongsheng Yang Date: Tue, 11 Oct 2016 10:30:45 +0000 (-0400) Subject: rbd: move do_export_diff out from namespace of export_diff. X-Git-Tag: v12.0.1~342^2~18 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=21be324e1178673c5b5ce947cd05b3c671573934;p=ceph.git rbd: move do_export_diff out from namespace of export_diff. Signed-off-by: Dongsheng Yang --- diff --git a/src/tools/rbd/action/Export.cc b/src/tools/rbd/action/Export.cc index b6b02448e0f2..d55936ba6759 100644 --- a/src/tools/rbd/action/Export.cc +++ b/src/tools/rbd/action/Export.cc @@ -17,10 +17,6 @@ namespace rbd { namespace action { -namespace export_diff { - -namespace at = argument_types; -namespace po = boost::program_options; struct ExportDiffContext { librbd::Image *image; @@ -111,9 +107,9 @@ private: } }; -static int do_export_diff(librbd::Image& image, const char *fromsnapname, - const char *endsnapname, bool whole_object, - const char *path, bool no_progress) +int do_export_diff(librbd::Image& image, const char *fromsnapname, + const char *endsnapname, bool whole_object, + const char *path, bool no_progress) { int r; librbd::image_info_t info; @@ -130,13 +126,6 @@ static int do_export_diff(librbd::Image& image, const char *fromsnapname, if (fd < 0) return -errno; - BOOST_SCOPE_EXIT((&r) (&fd) (&path)) { - close(fd); - if (r < 0 && fd != 1) { - remove(path); - } - } BOOST_SCOPE_EXIT_END - { // header bufferlist bl; @@ -164,6 +153,10 @@ static int do_export_diff(librbd::Image& image, const char *fromsnapname, r = bl.write_fd(fd); if (r < 0) { + close(fd); + if (fd != 1) { + remove(path); + } return r; } } @@ -187,14 +180,26 @@ static int do_export_diff(librbd::Image& image, const char *fromsnapname, r = bl.write_fd(fd); } - out: +out: if (r < 0) edc.pc.fail(); else edc.pc.finish(); + + close(fd); + if (r < 0 && fd != 1) { + remove(path); + } + return r; } + +namespace export_diff { + +namespace at = argument_types; +namespace po = boost::program_options; + void get_arguments(po::options_description *positional, po::options_description *options) { at::add_image_or_snap_spec_options(positional, options,