From fcb5c1f32e0ffa4214cca86a4f062f37b14d0ba7 Mon Sep 17 00:00:00 2001 From: Marco van Wieringen Date: Fri, 12 Dec 2014 14:29:06 +0100 Subject: [PATCH] Add support for changed rados_write API. Seems from version 0.68 to 0.69 the rados_write function all of a sudden gives back 0 when succeeded and no longer the actual bytes it wrote. As we also want to support the old API it now checks the LIBRADOS_VERSION_CODE --- src/stored/backends/rados_device.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/stored/backends/rados_device.c b/src/stored/backends/rados_device.c index 94624f3ef50..c19b1f66c42 100644 --- a/src/stored/backends/rados_device.c +++ b/src/stored/backends/rados_device.c @@ -160,7 +160,10 @@ ssize_t rados_device::d_read(int fd, void *buffer, size_t count) /* * Write data to a volume using librados. + * + * Seems the API changed everything earlier then 0.69 returns bytes written. */ +#if LIBRADOS_VERSION_CODE <= 17408 ssize_t rados_device::d_write(int fd, const void *buffer, size_t count) { if (m_ctx) { @@ -179,6 +182,26 @@ ssize_t rados_device::d_write(int fd, const void *buffer, size_t count) return -1; } } +#else +ssize_t rados_device::d_write(int fd, const void *buffer, size_t count) +{ + if (m_ctx) { + int status; + + status = rados_write(m_ctx, getVolCatName(), (char *)buffer, count, m_offset); + if (status == 0) { + m_offset += count; + return count; + } else { + errno = -status; + return -1; + } + } else { + errno = EBADF; + return -1; + } +} +#endif int rados_device::d_close(int fd) {