From: Jason Dillaman Date: Wed, 16 Dec 2020 15:15:28 +0000 (-0500) Subject: librbd/api: avoid retrieving more than max mirror image info records X-Git-Tag: v16.1.0~207^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F38613%2Fhead;p=ceph.git librbd/api: avoid retrieving more than max mirror image info records 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 --- diff --git a/src/librbd/api/Mirror.cc b/src/librbd/api/Mirror.cc index 25f22f0db9b..825d430bc05 100644 --- a/src/librbd/api/Mirror.cc +++ b/src/librbd/api/Mirror.cc @@ -2001,8 +2001,13 @@ int Mirror::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; } }