]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd: fix error processing images which have non-user snapshots 23638/head
authorsongweibin <song.weibin@zte.com.cn>
Sat, 18 Aug 2018 01:05:03 +0000 (09:05 +0800)
committersongweibin <song.weibin@zte.com.cn>
Sat, 18 Aug 2018 01:05:03 +0000 (09:05 +0800)
Signed-off-by: songweibin <song.weibin@zte.com.cn>
src/tools/rbd/action/List.cc

index f6b26c032ca09be60dd028d74eb6936c4d4d296d..ce67396b6946faebeba3ba26de055a2bf258a2c9 100644 (file)
@@ -11,6 +11,7 @@
 #include "common/Formatter.h"
 #include "common/TextTable.h"
 #include <iostream>
+#include <boost/bind.hpp>
 #include <boost/program_options.hpp>
 #include "global/global_context.h"
 
@@ -101,6 +102,10 @@ int list_process_image(librados::Rados* rados, WorkerEntry* w, bool lflag, Forma
 
   std::vector<librbd::snap_info_t> snaplist;
   if (w->img.snap_list(snaplist) >= 0 && !snaplist.empty()) {
+    snaplist.erase(remove_if(snaplist.begin(),
+                             snaplist.end(),
+                             boost::bind(utils::is_not_user_snap_namespace, &w->img, _1)),
+                   snaplist.end());
     for (std::vector<librbd::snap_info_t>::iterator s = snaplist.begin();
          s != snaplist.end(); ++s) {
       bool is_protected;
@@ -245,7 +250,7 @@ int do_list(const std::string &pool_name, const std::string& namespace_name,
          }
          r = list_process_image(&rados, comp, lflag, f, tbl);
          if (r < 0) {
-             std::cerr << "rbd: error processing image  " << comp->name << ": " << cpp_strerror(r)
+             std::cerr << "rbd: error processing image " << comp->name << ": " << cpp_strerror(r)
                        << std::endl;
          }
          comp->completion = new librbd::RBD::AioCompletion(nullptr, nullptr);
@@ -300,7 +305,7 @@ int execute(const po::variables_map &vm,
               g_conf().get_val<int64_t>("rbd_concurrent_management_ops"),
               formatter.get());
   if (r < 0) {
-    std::cerr << "rbd: list: " << cpp_strerror(r) << std::endl;
+    std::cerr << "rbd: listing images failed : " << cpp_strerror(r) << std::endl;
     return r;
   }