]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd/api: avoid retrieving more than max mirror image info records 38613/head
authorJason Dillaman <dillaman@redhat.com>
Wed, 16 Dec 2020 15:15:28 +0000 (10:15 -0500)
committerJason Dillaman <dillaman@redhat.com>
Thu, 17 Dec 2020 13:57:46 +0000 (08:57 -0500)
This could otherwise result in an assertion failure in the API if
it failed to retrieve the status on an image and therefore required
a second iteration through the loop.

Fixes: https://tracker.ceph.com/issues/48522
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/librbd/api/Mirror.cc

index 25f22f0db9b845eff52d1c4ec752396cfdf7c08b..825d430bc05b8d4ba1d1ef33c3afaa10bbb10956 100644 (file)
@@ -2001,8 +2001,13 @@ int Mirror<I>::image_info_list(
 
       mirror_image_info_t info;
       r = image_get_info(io_ctx, asio_engine.get_work_queue(), image_id, &info);
-      if (r >= 0) {
-        (*entries)[image_id] = std::make_pair(mode, info);
+      if (r < 0) {
+        continue;
+      }
+
+      (*entries)[image_id] = std::make_pair(mode, info);
+      if (entries->size() == max) {
+        break;
       }
     }