From: Milind Changire Date: Thu, 27 Jun 2019 13:35:26 +0000 (+0530) Subject: libradosstriper: add function to read into char* X-Git-Tag: v16.2.0~36^2~15 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4baadd2faeed42ccb2d992979cb54ac17384ce17;p=ceph.git libradosstriper: add function to read into char* Signed-off-by: Milind Changire Signed-off-by: Patrick Donnelly (cherry picked from commit 02f5543c8df9e2a175ce5d9a96773b641e212c1c) --- diff --git a/src/include/radosstriper/libradosstriper.hpp b/src/include/radosstriper/libradosstriper.hpp index fb790b0d7ef1..064c7d2c3d84 100644 --- a/src/include/radosstriper/libradosstriper.hpp +++ b/src/include/radosstriper/libradosstriper.hpp @@ -168,6 +168,7 @@ namespace libradosstriper * synchronously read from the striped object at the specified offset. */ int read(const std::string& soid, ceph::bufferlist* pbl, size_t len, uint64_t off); + int read(const std::string& soid, char *buf, size_t len, uint64_t off); /** * asynchronously read from the striped object at the specified offset. diff --git a/src/libradosstriper/libradosstriper.cc b/src/libradosstriper/libradosstriper.cc index e98dfc17935a..7f23a380550e 100644 --- a/src/libradosstriper/libradosstriper.cc +++ b/src/libradosstriper/libradosstriper.cc @@ -254,6 +254,28 @@ int libradosstriper::RadosStriper::read(const std::string& soid, return rados_striper_impl->read(soid, bl, len, off); } +int libradosstriper::RadosStriper::read(const std::string& soid, + char *buf, + size_t len, + uint64_t off) +{ + bufferlist bl; + bufferptr bp = buffer::create_static(len, buf); + + bl.push_back(bp); + + int ret = rados_striper_impl->read(soid, &bl, len, off); + + if (ret >= 0) { + if (bl.length() > len) + return -ERANGE; + if (!bl.is_provided_buffer(buf)) + bl.begin().copy(bl.length(), buf); + ret = bl.length(); // hrm :/ + } + return ret; +} + int libradosstriper::RadosStriper::aio_read(const std::string& soid, librados::AioCompletion *c, bufferlist* bl,