diff options
author | zhangjiao <zhangjiao@cmss.chinamobile.com> | 2019-12-11 09:08:03 +0100 |
---|---|---|
committer | Kefu Chai <kchai@redhat.com> | 2020-08-29 15:43:27 +0200 |
commit | 760558989916b43c417567c9b0e8bf5dc4ea1980 (patch) | |
tree | 72950c8ab3c22fcc9d0d75453c785003256b03c2 /src/pybind/rados/rados.pyx | |
parent | Merge pull request #36854 from idryomov/wip-krbd-default-pool-fix (diff) | |
download | ceph-760558989916b43c417567c9b0e8bf5dc4ea1980.tar.xz ceph-760558989916b43c417567c9b0e8bf5dc4ea1980.zip |
pybind/rados: add Iocxt::aio_cmpext()
Signed-off-by: Zhang Jiao <zhangjiao@cmss.chinamobile.com>
Diffstat (limited to 'src/pybind/rados/rados.pyx')
-rw-r--r-- | src/pybind/rados/rados.pyx | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/src/pybind/rados/rados.pyx b/src/pybind/rados/rados.pyx index 6839170ce63..38355c23bda 100644 --- a/src/pybind/rados/rados.pyx +++ b/src/pybind/rados/rados.pyx @@ -283,7 +283,8 @@ cdef extern from "rados/librados.h" nogil: int rados_aio_remove(rados_ioctx_t io, const char * oid, rados_completion_t completion) int rados_aio_read(rados_ioctx_t io, const char * oid, rados_completion_t completion, char * buf, size_t len, uint64_t off) int rados_aio_flush(rados_ioctx_t io) - + int rados_aio_cmpext(rados_ioctx_t io, const char *o, rados_completion_t completion, const char *cmp_buf, size_t cmp_len, uint64_t off) + int rados_aio_get_return_value(rados_completion_t c) int rados_aio_wait_for_complete_and_cb(rados_completion_t c) int rados_aio_wait_for_complete(rados_completion_t c) @@ -2757,6 +2758,45 @@ cdef class Ioctx(object): if ret < 0: raise make_ex(ret, "error flushing") + @requires(('object_name', str), ('cmp_buf', bytes), ('offset', int)) + def aio_cmpext(self, object_name, cmp_buf, offset=0, oncomplete=None): + """ + Asynchronously compare an on-disk object range with a buffer + :param object_name: the name of the object + :type object_name: str + :param cmp_buf: buffer containing bytes to be compared with object contents + :type cmp_buf: bytes + :param offset: object byte offset at which to start the comparison + :type offset: int + :param oncomplete: what to do when the write is safe and complete in memory + on all replicas + :type oncomplete: completion + + :raises: :class:`TypeError` + returns: 0 - on success, negative error code on failure, + (-MAX_ERRNO - mismatch_off) on mismatch + """ + object_name = cstr(object_name, 'object_name') + + cdef: + Completion completion + char* _object_name = object_name + char* _cmp_buf = cmp_buf + size_t _cmp_buf_len = len(cmp_buf) + uint64_t _offset = offset + + completion = self.__get_completion(oncomplete, None) + self.__track_completion(completion) + + with nogil: + ret = rados_aio_cmpext(self.io, _object_name, completion.rados_comp, + _cmp_buf, _cmp_buf_len, _offset) + + if ret < 0: + completion._cleanup() + raise make_ex(ret, "failed to compare %s" % object_name) + return completion + @requires(('object_name', str), ('length', int), ('offset', int), ('oncomplete', opt(Callable))) def aio_read(self, object_name, length, offset, oncomplete): |