]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd: move do_export_diff out from namespace of export_diff.
authorDongsheng Yang <dongsheng.yang@easystack.cn>
Tue, 11 Oct 2016 10:30:45 +0000 (06:30 -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/action/Export.cc

index b6b02448e0f21300fdc77d748d993107384249ac..d55936ba6759a2b50bad1db72e8225a2b15a7e5a 100644 (file)
 
 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,