From 09c741e2a585aded03732e51fad47cff3bb99367 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 (cherry picked from commit 77bc48bbadd8e8423e9342102475994632441eaa) Conflicts: src/librbd/api/Mirror.cc: conflict with new AsioEngine --- 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 0a868bf976144..9687f321b8b7b 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; } } -- 2.47.3