]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd: fix error processing images which have non-user snapshots 28138/head
authorsongweibin <song.weibin@zte.com.cn>
Sat, 18 Aug 2018 01:05:03 +0000 (09:05 +0800)
committerJason Dillaman <dillaman@redhat.com>
Wed, 15 May 2019 23:54:59 +0000 (19:54 -0400)
Signed-off-by: songweibin <song.weibin@zte.com.cn>
(cherry picked from commit 91c67b2a8d12ac03173a8e060dec1278f26b338a)

src/tools/rbd/action/List.cc

index e6810b9a4c0d542230ea4a672bd29a7cdbae0b1a..2b199d8621ab3df088c4f3dddb31dd94749d1971 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;
@@ -242,7 +247,7 @@ int do_list(std::string &pool_name, bool lflag, int threads, Formatter *f) {
          }
          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);
@@ -295,7 +300,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;
   }