From 77bc48bbadd8e8423e9342102475994632441eaa Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Wed, 16 Dec 2020 10:15:28 -0500 Subject: [PATCH] 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 --- src/librbd/api/Mirror.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/librbd/api/Mirror.cc b/src/librbd/api/Mirror.cc index 25f22f0db9b8..825d430bc05b 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; } } -- 2.47.3