diff --git a/src/tools/rbd/action/List.cc b/src/tools/rbd/action/List.cc index f6b26c032ca..ce67396b694 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; } diff --git a/src/tools/rbd/action/Snap.cc b/src/tools/rbd/action/Snap.cc index df337b66b91..b08891908d2 100644 --- a/src/tools/rbd/action/Snap.cc +++ b/src/tools/rbd/action/Snap.cc @@ -204,6 +204,10 @@ int do_purge_snaps(librbd::Image& image, bool no_progress) return 0; } else { list protect; + snaps.erase(remove_if(snaps.begin(), + snaps.end(), + boost::bind(utils::is_not_user_snap_namespace, &image, _1)), + snaps.end()); for (auto it = snaps.begin(); it != snaps.end();) { r = image.snap_is_protected(it->name.c_str(), &is_protected); if (r < 0) {