Skip to content

Commit

Permalink
Add support for changed rados_write API.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Marco van Wieringen committed Feb 17, 2015
1 parent 9fb4af3 commit fcb5c1f
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/stored/backends/rados_device.c
Expand Up @@ -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) {
Expand All @@ -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)
{
Expand Down

0 comments on commit fcb5c1f

Please sign in to comment.