From: xie xingguo Date: Tue, 2 Feb 2016 07:04:04 +0000 (+0800) Subject: rados: fix result code overflow X-Git-Tag: v10.0.4~63^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=48dc0bf7aae44035c4814d43d845dfdcaeb64be2;p=ceph.git rados: fix result code overflow Signed-off-by: xie xingguo --- diff --git a/src/include/rados/librados.hpp b/src/include/rados/librados.hpp index 373c5072fe52..1287c77de9c4 100644 --- a/src/include/rados/librados.hpp +++ b/src/include/rados/librados.hpp @@ -1091,8 +1091,14 @@ namespace librados int64_t get_id(); - uint32_t get_object_hash_position(const std::string& oid); - uint32_t get_object_pg_hash_position(const std::string& oid); + // deprecated versions + uint32_t get_object_hash_position(const std::string& oid) + __attribute__ ((deprecated)); + uint32_t get_object_pg_hash_position(const std::string& oid) + __attribute__ ((deprecated)); + + int get_object_hash_position2(const std::string& oid, uint32_t *hash_position); + int get_object_pg_hash_position2(const std::string& oid, uint32_t *pg_hash_position); config_t cct(); diff --git a/src/librados/IoCtxImpl.cc b/src/librados/IoCtxImpl.cc index 24eda4f94377..9e8f424c55bb 100644 --- a/src/librados/IoCtxImpl.cc +++ b/src/librados/IoCtxImpl.cc @@ -181,14 +181,24 @@ int librados::IoCtxImpl::set_snap_write_context(snapid_t seq, vector& return 0; } -uint32_t librados::IoCtxImpl::get_object_hash_position(const std::string& oid) +int librados::IoCtxImpl::get_object_hash_position( + const std::string& oid, uint32_t *hash_position) { - return objecter->get_object_hash_position(poolid, oid, oloc.nspace); + int64_t r = objecter->get_object_hash_position(poolid, oid, oloc.nspace); + if (r < 0) + return r; + *hash_position = (uint32_t)r; + return 0; } -uint32_t librados::IoCtxImpl::get_object_pg_hash_position(const std::string& oid) +int librados::IoCtxImpl::get_object_pg_hash_position( + const std::string& oid, uint32_t *pg_hash_position) { - return objecter->get_object_pg_hash_position(poolid, oid, oloc.nspace); + int64_t r = objecter->get_object_pg_hash_position(poolid, oid, oloc.nspace); + if (r < 0) + return r; + *pg_hash_position = (uint32_t)r; + return 0; } void librados::IoCtxImpl::queue_aio_write(AioCompletionImpl *c) diff --git a/src/librados/IoCtxImpl.h b/src/librados/IoCtxImpl.h index 25166c01cf55..a890fb00da26 100644 --- a/src/librados/IoCtxImpl.h +++ b/src/librados/IoCtxImpl.h @@ -92,8 +92,8 @@ struct librados::IoCtxImpl { const string& get_cached_pool_name(); - uint32_t get_object_hash_position(const std::string& oid); - uint32_t get_object_pg_hash_position(const std::string& oid); + int get_object_hash_position(const std::string& oid, uint32_t *hash_postion); + int get_object_pg_hash_position(const std::string& oid, uint32_t *pg_hash_position); ::ObjectOperation *prepare_assert_ops(::ObjectOperation *op); diff --git a/src/librados/librados.cc b/src/librados/librados.cc index ed256dbc6497..19a4a3d3f24b 100644 --- a/src/librados/librados.cc +++ b/src/librados/librados.cc @@ -1927,12 +1927,32 @@ int64_t librados::IoCtx::get_id() uint32_t librados::IoCtx::get_object_hash_position(const std::string& oid) { - return io_ctx_impl->get_object_hash_position(oid); + uint32_t hash; + int r = io_ctx_impl->get_object_hash_position(oid, &hash); + if (r < 0) + hash = 0; + return hash; } uint32_t librados::IoCtx::get_object_pg_hash_position(const std::string& oid) { - return io_ctx_impl->get_object_pg_hash_position(oid); + uint32_t hash; + int r = io_ctx_impl->get_object_pg_hash_position(oid, &hash); + if (r < 0) + hash = 0; + return hash; +} + +int librados::IoCtx::get_object_hash_position2( + const std::string& oid, uint32_t *hash_position) +{ + return io_ctx_impl->get_object_hash_position(oid, hash_position); +} + +int librados::IoCtx::get_object_pg_hash_position2( + const std::string& oid, uint32_t *pg_hash_position) +{ + return io_ctx_impl->get_object_pg_hash_position(oid, pg_hash_position); } librados::config_t librados::IoCtx::cct()