]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/rbd: drop GIL when calling into librbd 52323/head
authorIlya Dryomov <idryomov@gmail.com>
Mon, 3 Jul 2023 11:34:30 +0000 (13:34 +0200)
committerPatrick Donnelly <pdonnell@redhat.com>
Wed, 5 Jul 2023 17:37:10 +0000 (13:37 -0400)
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 <idryomov@gmail.com>
(cherry picked from commit 1a60f66b0a13089c789e2e056b925ac6fef75021)

Conflicts:
src/test/pybind/test_rbd.py: trivial import conflict

src/pybind/rbd/rbd.pyx
src/test/pybind/test_rbd.py

index 16014f1409cfb52f691b1ba05fb260e0bc59645a..5a11723df0fe52d58e02f733d9071d56e99b4c5e 100644 (file)
@@ -1396,8 +1396,10 @@ class RBD(object):
             char *_client_name = client_name
         try:
             _uuid = <char *>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):
index 75a19381199d38d342f66e07630700f87f867176..d1f4d70ecbd2777950b7f0fbbaa53235fa122832 100644 (file)
@@ -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)