From: songweibin Date: Sat, 18 Aug 2018 01:05:03 +0000 (+0800) Subject: rbd: fix error processing images which have non-user snapshots X-Git-Tag: v14.0.1~531^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=91c67b2a8d12ac03173a8e060dec1278f26b338a;p=ceph.git rbd: fix error processing images which have non-user snapshots Signed-off-by: songweibin --- diff --git a/src/tools/rbd/action/List.cc b/src/tools/rbd/action/List.cc index f6b26c032ca0..ce67396b6946 100644 --- a/src/tools/rbd/action/List.cc +++ b/src/tools/rbd/action/List.cc @@ -11,6 +11,7 @@ #include "common/Formatter.h" #include "common/TextTable.h" #include +#include #include #include "global/global_context.h" @@ -101,6 +102,10 @@ int list_process_image(librados::Rados* rados, WorkerEntry* w, bool lflag, Forma std::vector 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::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("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; }