]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rbd: fix error purging non-user snapshots
authorsongweibin <song.weibin@zte.com.cn>
Sat, 18 Aug 2018 00:50:24 +0000 (08:50 +0800)
committersongweibin <song.weibin@zte.com.cn>
Sat, 18 Aug 2018 00:55:49 +0000 (08:55 +0800)
Fixes:
  [root@ ~]# rbd snap rm img1@snap1
  [root@ ~]# rbd snap ls img1 -a
  SNAPID NAME                                 SIZE    TIMESTAMP                NAMESPACE
       4 f2e82bd1-e2ff-4a6b-aaef-5a12a2b23a30 100 MiB Sat Aug 18 08:48:34 2018 trash (snap1)
  [root@ ~]# rbd snap purge img1
  Removing all snapshots: 0% complete...failed.
  rbd: removing snaps failed: (2) No such file or directory

Signed-off-by: songweibin <song.weibin@zte.com.cn>
src/tools/rbd/action/Snap.cc

index df337b66b918dbbf7ef7cc669b427a64fe5b3255..b08891908d20505f4a45c7974d517abc993219bd 100644 (file)
@@ -204,6 +204,10 @@ int do_purge_snaps(librbd::Image& image, bool no_progress)
     return 0;
   } else {
     list<std::string> 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) {