]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
librbd: fix broken group snapshot handling
authorJason Dillaman <dillaman@redhat.com>
Fri, 21 Feb 2020 01:43:46 +0000 (20:43 -0500)
committerJason Dillaman <dillaman@redhat.com>
Fri, 21 Feb 2020 13:22:41 +0000 (08:22 -0500)
After commit ecf71d301f, only the snapshot namespace type and snapshot
name are considered for snapshot ordering. This breaks the expectations
in the group API when searching for a newly created snapshot.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/librbd/api/Group.cc

index aa341bc25328a7de36dbb145f7520ac88529eb71..48a49cf74024ea97bcce5c8acf78f32ed5f14fbc 100644 (file)
@@ -39,9 +39,15 @@ template <typename I>
 snap_t get_group_snap_id(I* ictx,
                          const cls::rbd::SnapshotNamespace& in_snap_namespace) {
   ceph_assert(ceph_mutex_is_locked(ictx->image_lock));
-  auto it = ictx->snap_ids.lower_bound({in_snap_namespace, ""});
-  if (it != ictx->snap_ids.end() && it->first.first == in_snap_namespace) {
-    return it->second;
+  auto it = ictx->snap_ids.lower_bound({cls::rbd::GroupSnapshotNamespace{},
+                                        ""});
+  for (; it != ictx->snap_ids.end(); ++it) {
+    if (it->first.first == in_snap_namespace) {
+      return it->second;
+    } else if (boost::get<cls::rbd::GroupSnapshotNamespace>(&it->first.first) ==
+                 nullptr) {
+      break;
+    }
   }
   return CEPH_NOSNAP;
 }