From: Ilya Dryomov Date: Mon, 3 Jul 2023 11:34:30 +0000 (+0200) Subject: pybind/rbd: drop GIL when calling into librbd X-Git-Tag: v17.2.7~224^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=196006dafe71a2be2f22f9bdcfe3295f9f9dc4cc;p=ceph.git 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) Conflicts: src/test/pybind/test_rbd.py: trivial import noise --- diff --git a/src/pybind/rbd/rbd.pyx b/src/pybind/rbd/rbd.pyx index 16014f1409cfb..5a11723df0fe5 100644 --- a/src/pybind/rbd/rbd.pyx +++ b/src/pybind/rbd/rbd.pyx @@ -1396,8 +1396,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) @@ -3131,7 +3133,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 75a19381199d3..d1f4d70ecbd27 100644 --- a/src/test/pybind/test_rbd.py +++ b/src/test/pybind/test_rbd.py @@ -12,7 +12,8 @@ import sys from datetime import datetime, timedelta from nose import with_setup, SkipTest -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, @@ -604,6 +605,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)