Skip to content

Commit 1a60f66

Browse files
committed
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 <[email protected]>
1 parent 5d249a4 commit 1a60f66

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/pybind/rbd/rbd.pyx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1397,8 +1397,10 @@ class RBD(object):
13971397
char *_client_name = client_name
13981398
try:
13991399
_uuid = <char *>realloc_chk(_uuid, _uuid_max_length)
1400-
ret = rbd_mirror_peer_site_add(_ioctx, _uuid, _uuid_max_length,
1401-
_direction, _site_name, _client_name)
1400+
with nogil:
1401+
ret = rbd_mirror_peer_site_add(_ioctx, _uuid, _uuid_max_length,
1402+
_direction, _site_name,
1403+
_client_name)
14021404
if ret != 0:
14031405
raise make_ex(ret, 'error adding mirror peer')
14041406
return decode_cstr(_uuid)
@@ -3132,7 +3134,11 @@ cdef class Image(object):
31323134
31333135
:returns: int - the pool id
31343136
"""
3135-
return rbd_get_data_pool_id(self.image)
3137+
with nogil:
3138+
ret = rbd_get_data_pool_id(self.image)
3139+
if ret < 0:
3140+
raise make_ex(ret, 'error getting data pool id for image %s' % self.name)
3141+
return ret
31363142

31373143
@requires_not_closed
31383144
def get_parent_image_spec(self):

src/test/pybind/test_rbd.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
from datetime import datetime, timedelta
1414
from nose import with_setup, SkipTest
1515
from nose.plugins.attrib import attr
16-
from nose.tools import eq_ as eq, assert_raises, assert_not_equal
16+
from nose.tools import (eq_ as eq, assert_raises, assert_not_equal,
17+
assert_greater_equal)
1718
from rados import (Rados,
1819
LIBRADOS_OP_FLAG_FADVISE_DONTNEED,
1920
LIBRADOS_OP_FLAG_FADVISE_NOCACHE,
@@ -607,6 +608,9 @@ def test_id(self):
607608
def test_block_name_prefix(self):
608609
assert_not_equal(b'', self.image.block_name_prefix())
609610

611+
def test_data_pool_id(self):
612+
assert_greater_equal(self.image.data_pool_id(), 0)
613+
610614
def test_create_timestamp(self):
611615
timestamp = self.image.create_timestamp()
612616
assert_not_equal(0, timestamp.year)

0 commit comments

Comments
 (0)