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: v15.2.13~2^2~12^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F39964%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 (cherry picked from commit 77bc48bbadd8e8423e9342102475994632441eaa) Conflicts: src/librbd/api/Mirror.cc: conflict with new AsioEngine --- diff --git a/src/librbd/api/Mirror.cc b/src/librbd/api/Mirror.cc index 0a868bf9761..9687f321b8b 100644 --- a/src/librbd/api/Mirror.cc +++ b/src/librbd/api/Mirror.cc @@ -1992,8 +1992,13 @@ int Mirror::image_info_list( mirror_image_info_t info; r = image_get_info(io_ctx, op_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; } }