From f59a49aececcf0912c5ec307d4227d8453ad5ee2 Mon Sep 17 00:00:00 2001 From: Ilya Dryomov Date: Mon, 3 Jul 2023 13:34:30 +0200 Subject: [PATCH] pybind/rbd: drop GIL when calling into librbd This was missing for rbd_mirror_peer_site_add() and rbd_get_data_pool_id(). While at it, add a test for data_pool_id(). Signed-off-by: Ilya Dryomov (cherry picked from commit 1a60f66b0a13089c789e2e056b925ac6fef75021) --- src/pybind/rbd/rbd.pyx | 12 +++++++++--- src/test/pybind/test_rbd.py | 6 +++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/pybind/rbd/rbd.pyx b/src/pybind/rbd/rbd.pyx index f2d22b4a16c..5e14e38c919 100644 --- a/src/pybind/rbd/rbd.pyx +++ b/src/pybind/rbd/rbd.pyx @@ -1397,8 +1397,10 @@ class RBD(object): char *_client_name = client_name try: _uuid = realloc_chk(_uuid, _uuid_max_length) - ret = rbd_mirror_peer_site_add(_ioctx, _uuid, _uuid_max_length, - _direction, _site_name, _client_name) + with nogil: + ret = rbd_mirror_peer_site_add(_ioctx, _uuid, _uuid_max_length, + _direction, _site_name, + _client_name) if ret != 0: raise make_ex(ret, 'error adding mirror peer') return decode_cstr(_uuid) @@ -3132,7 +3134,11 @@ cdef class Image(object): :returns: int - the pool id """ - return rbd_get_data_pool_id(self.image) + with nogil: + ret = rbd_get_data_pool_id(self.image) + if ret < 0: + raise make_ex(ret, 'error getting data pool id for image %s' % self.name) + return ret @requires_not_closed def get_parent_image_spec(self): diff --git a/src/test/pybind/test_rbd.py b/src/test/pybind/test_rbd.py index 05cb6c30509..1e07e19b86e 100644 --- a/src/test/pybind/test_rbd.py +++ b/src/test/pybind/test_rbd.py @@ -13,7 +13,8 @@ import sys from datetime import datetime, timedelta from nose import with_setup, SkipTest from nose.plugins.attrib import attr -from nose.tools import eq_ as eq, assert_raises, assert_not_equal +from nose.tools import (eq_ as eq, assert_raises, assert_not_equal, + assert_greater_equal) from rados import (Rados, LIBRADOS_OP_FLAG_FADVISE_DONTNEED, LIBRADOS_OP_FLAG_FADVISE_NOCACHE, @@ -607,6 +608,9 @@ class TestImage(object): def test_block_name_prefix(self): assert_not_equal(b'', self.image.block_name_prefix()) + def test_data_pool_id(self): + assert_greater_equal(self.image.data_pool_id(), 0) + def test_create_timestamp(self): timestamp = self.image.create_timestamp() assert_not_equal(0, timestamp.year) -- 2.39.5