From 5539309996834f761f4440f79103d1678b7d5cb0 Mon Sep 17 00:00:00 2001 From: songweibin Date: Mon, 2 Apr 2018 09:29:26 +0800 Subject: [PATCH 1/3] librbd: drop a duplicate definition function Signed-off-by: songweibin --- src/include/rbd/librbd.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/include/rbd/librbd.h b/src/include/rbd/librbd.h index 36b93972cab..a0ccb17374f 100644 --- a/src/include/rbd/librbd.h +++ b/src/include/rbd/librbd.h @@ -545,11 +545,8 @@ CEPH_RBD_API int rbd_snap_get_timestamp(rbd_image_t image, uint64_t snap_id, str CEPH_RBD_API int rbd_snap_set(rbd_image_t image, const char *snapname); CEPH_RBD_API int rbd_snap_get_namespace_type(rbd_image_t image, - uint64_t snap_id, - rbd_snap_namespace_type_t *namespace_type); -CEPH_RBD_API int rbd_snap_get_namespace_type(rbd_image_t image, - uint64_t snap_id, - rbd_snap_namespace_type_t *namespace_type); + uint64_t snap_id, + rbd_snap_namespace_type_t *namespace_type); CEPH_RBD_API int rbd_snap_get_group_namespace(rbd_image_t image, uint64_t snap_id, rbd_snap_group_namespace_t *group_snap, From 1b7d2fe64e0982b6bda927fc70ab69689b55d70a Mon Sep 17 00:00:00 2001 From: songweibin Date: Mon, 2 Apr 2018 11:09:26 +0800 Subject: [PATCH 2/3] librbd: return error when r < 0 Signed-off-by: songweibin --- src/librbd/api/Group.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/librbd/api/Group.cc b/src/librbd/api/Group.cc index 99fea4a568d..1b2d3f46cff 100644 --- a/src/librbd/api/Group.cc +++ b/src/librbd/api/Group.cc @@ -398,6 +398,10 @@ int Group::remove(librados::IoCtx& io_ctx, const char *group_name) std::vector snaps; r = group_snap_list(io_ctx, group_name, &snaps); + if (r < 0 && r != -ENOENT) { + lderr(cct) << "error listing group snapshots" << dendl; + return r; + } for (auto &snap : snaps) { r = group_snap_remove_by_record(io_ctx, snap, group_id, group_header_oid); From 74839033f31c8002ead713415b4c1fd1ea15a5cd Mon Sep 17 00:00:00 2001 From: songweibin Date: Mon, 2 Apr 2018 11:31:04 +0800 Subject: [PATCH 3/3] pybind/rbd: normalize errno exception The code meant to do so but actually it does not ... Signed-off-by: songweibin --- src/pybind/rbd/rbd.pyx | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/pybind/rbd/rbd.pyx b/src/pybind/rbd/rbd.pyx index 8da4e651457..3e74f12560d 100644 --- a/src/pybind/rbd/rbd.pyx +++ b/src/pybind/rbd/rbd.pyx @@ -538,13 +538,13 @@ class PermissionError(OSError): class ImageNotFound(OSError): pass -class ObjectNotFound(Error): +class ObjectNotFound(OSError): pass class ImageExists(OSError): pass -class ObjectExists(Error): +class ObjectExists(OSError): pass @@ -644,8 +644,8 @@ cdef make_ex(ret, msg, exception_map=errno_to_exception): :returns: a subclass of :class:`Error` """ ret = abs(ret) - if ret in errno_to_exception: - return errno_to_exception[ret](msg, errno=ret) + if ret in exception_map: + return exception_map[ret](msg, errno=ret) else: return OSError(msg, errno=ret) @@ -1610,7 +1610,6 @@ cdef class Group(object): :type name: str :raises: :class:`ObjectNotFound` - :raises: :class:`ObjectExists` :raises: :class:`InvalidArgument` :raises: :class:`FunctionNotSupported` """ @@ -1660,7 +1659,6 @@ cdef class Group(object): :type name: str :raises: :class:`ObjectNotFound` - :raises: :class:`ObjectExists` :raises: :class:`InvalidArgument` :raises: :class:`FunctionNotSupported` """