]> git.apps.os.sepia.ceph.com Git - ceph.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)
committerJason Dillaman <dillaman@redhat.com>
Wed, 15 May 2019 23:54:50 +0000 (19:54 -0400)
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>
(cherry picked from commit 2c79a4939090d445a8172dbbe4d4072a4851ddcf)

src/tools/rbd/action/Snap.cc

index 84bbeee65fdc044430dfbda5896bd30e8a5ea475..4de016cfd344253a4925096e3174a5e5f789a7bd 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) {