mirror of
https://github.com/ceph/ceph
synced 2025-01-04 02:02:36 +00:00
pybind/rbd: optimize rbd_list2
If rbd_list2 returns ERANGE, it sets num_images to the value required. But it is better to retry with a bigger number, to avoid new retries if images are added to the pool at that time. Also the initial value for num_images looks too small. Signed-off-by: Mykola Golub <mgolub@suse.com>
This commit is contained in:
parent
af96e16271
commit
bc28c3af4d
@ -4374,7 +4374,7 @@ cdef class ImageIterator(object):
|
||||
def __init__(self, ioctx):
|
||||
self.ioctx = convert_ioctx(ioctx)
|
||||
self.images = NULL
|
||||
self.num_images = 32
|
||||
self.num_images = 1024
|
||||
while True:
|
||||
self.images = <rbd_image_spec_t*>realloc_chk(
|
||||
self.images, self.num_images * sizeof(rbd_image_spec_t))
|
||||
@ -4382,7 +4382,9 @@ cdef class ImageIterator(object):
|
||||
ret = rbd_list2(self.ioctx, self.images, &self.num_images)
|
||||
if ret >= 0:
|
||||
break
|
||||
elif ret != -errno.ERANGE:
|
||||
elif ret == -errno.ERANGE:
|
||||
self.num_images *= 2
|
||||
else:
|
||||
raise make_ex(ret, 'error listing images.')
|
||||
|
||||
def __iter__(self):
|
||||
|
Loading…
Reference in New Issue
Block a user