]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: ssize_t return values for read, write
authorSage Weil <sage@newdream.net>
Tue, 15 Mar 2011 20:16:41 +0000 (13:16 -0700)
committerSage Weil <sage@newdream.net>
Tue, 15 Mar 2011 20:16:41 +0000 (13:16 -0700)
size_t is 32bits on 64bit archs.  Use ssize_t (long) for return values.

Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
src/include/rbd/librbd.h
src/include/rbd/librbd.hpp
src/librbd.cc
src/rbd.cc

index 8bc52b5e7453994d3d872a8374e27cff0786b76f..71858b8768994208171421534f12e39380820513 100644 (file)
@@ -81,15 +81,15 @@ int rbd_snap_set(rbd_image_t image, const char *snapname);
 /* I/O */
 typedef void *rbd_completion_t;
 typedef void (*rbd_callback_t)(rbd_completion_t cb, void *arg);
-int rbd_read(rbd_image_t image, uint64_t ofs, size_t len, char *buf);
+ssize_t rbd_read(rbd_image_t image, uint64_t ofs, size_t len, char *buf);
 int64_t rbd_read_iterate(rbd_image_t image, uint64_t ofs, size_t len,
                         int (*cb)(uint64_t, size_t, const char *, void *), void *arg);
-int rbd_write(rbd_image_t image, uint64_t ofs, size_t len, const char *buf);
+ssize_t rbd_write(rbd_image_t image, uint64_t ofs, size_t len, const char *buf);
 int rbd_aio_write(rbd_image_t image, uint64_t off, size_t len, const char *buf, rbd_completion_t c);
 int rbd_aio_read(rbd_image_t image, uint64_t off, size_t len, char *buf, rbd_completion_t c);
 int rbd_aio_create_completion(void *cb_arg, rbd_callback_t complete_cb, rbd_completion_t *c);
 int rbd_aio_wait_for_complete(rbd_completion_t c);
-int rbd_aio_get_return_value(rbd_completion_t c);
+ssize_t rbd_aio_get_return_value(rbd_completion_t c);
 void rbd_aio_release(rbd_completion_t c);
 
 #ifdef __cplusplus
index 79629da4543977f35f515c461f0fb3437b913888..74d7728b8ddd7c007e53fbb5026cecec80e4994d 100644 (file)
@@ -51,7 +51,7 @@ public:
     void *pc;
     AioCompletion(void *cb_arg, callback_t complete_cb);
     int wait_for_complete();
-    int get_return_value();
+    ssize_t get_return_value();
     void release();
   };
 
@@ -88,10 +88,10 @@ public:
   int snap_set(const char *snap_name);
 
   /* I/O */
-  int read(uint64_t ofs, size_t len, ceph::bufferlist& bl);
+  ssize_t read(uint64_t ofs, size_t len, ceph::bufferlist& bl);
   int64_t read_iterate(uint64_t ofs, size_t len,
                       int (*cb)(uint64_t, size_t, const char *, void *), void *arg);
-  int write(uint64_t ofs, size_t len, ceph::bufferlist& bl);
+  ssize_t write(uint64_t ofs, size_t len, ceph::bufferlist& bl);
 
   int aio_write(uint64_t off, size_t len, ceph::bufferlist& bl, RBD::AioCompletion *c);
   int aio_read(uint64_t off, size_t len, ceph::bufferlist& bl, RBD::AioCompletion *c);
index 7c47c45c15f40001d562bedafa65e4d88ded9e80..a6de668182ea15ebda636194c08edb58f0afc89d 100644 (file)
@@ -133,7 +133,7 @@ namespace librbd {
     Mutex lock;
     Cond cond;
     bool done;
-    int rval;
+    ssize_t rval;
     callback_t complete_cb;
     void *complete_arg;
     rbd_completion_t rbd_comp;
@@ -171,9 +171,9 @@ namespace librbd {
 
     void complete_block(AioBlockCompletion *block_completion, int r);
 
-    int get_return_value() {
+    ssize_t get_return_value() {
       lock.Lock();
-      int r = rval;
+      ssize_t r = rval;
       lock.Unlock();
       return r;
     }
@@ -251,8 +251,8 @@ namespace librbd {
   int64_t read_iterate(ImageCtx *ictx, uint64_t off, size_t len,
                       int (*cb)(uint64_t, size_t, const char *, void *),
                       void *arg);
-  int read(ImageCtx *ictx, uint64_t off, size_t len, char *buf);
-  int write(ImageCtx *ictx, uint64_t off, size_t len, const char *buf);
+  ssize_t read(ImageCtx *ictx, uint64_t off, size_t len, char *buf);
+  ssize_t write(ImageCtx *ictx, uint64_t off, size_t len, const char *buf);
   int aio_write(ImageCtx *ictx, uint64_t off, size_t len, const char *buf,
                 AioCompletion *c);
   int aio_read(ImageCtx *ictx, uint64_t off, size_t len,
@@ -1097,12 +1097,12 @@ static int simple_read_cb(uint64_t ofs, size_t len, const char *buf, void *arg)
 }
 
 
-int read(ImageCtx *ictx, uint64_t ofs, size_t len, char *buf)
+ssize_t read(ImageCtx *ictx, uint64_t ofs, size_t len, char *buf)
 {
   return read_iterate(ictx, ofs, len, simple_read_cb, buf);
 }
 
-int write(ImageCtx *ictx, uint64_t off, size_t len, const char *buf)
+ssize_t write(ImageCtx *ictx, uint64_t off, size_t len, const char *buf)
 {
   if (!len)
     return 0;
@@ -1111,7 +1111,7 @@ int write(ImageCtx *ictx, uint64_t off, size_t len, const char *buf)
   if (r < 0)
     return r;
 
-  int total_write = 0;
+  size_t total_write = 0;
   uint64_t start_block = get_block_num(&ictx->header, off);
   uint64_t end_block = get_block_num(&ictx->header, off + len - 1);
   uint64_t block_size = get_block_size(&ictx->header);
@@ -1218,7 +1218,7 @@ int aio_write(ImageCtx *ictx, uint64_t off, size_t len, const char *buf,
   if (r < 0)
     return r;
 
-  int total_write = 0;
+  size_t total_write = 0;
   uint64_t start_block = get_block_num(&ictx->header, off);
   uint64_t end_block = get_block_num(&ictx->header, off + len - 1);
   uint64_t block_size = get_block_size(&ictx->header);
@@ -1382,7 +1382,7 @@ int RBD::AioCompletion::wait_for_complete()
   return c->wait_for_complete();
 }
 
-int RBD::AioCompletion::get_return_value()
+ssize_t RBD::AioCompletion::get_return_value()
 {
   librbd::AioCompletion *c = (librbd::AioCompletion *)pc;
   return c->get_return_value();
@@ -1458,7 +1458,7 @@ int Image::snap_set(const char *snap_name)
   return librbd::snap_set(ictx, snap_name);
 }
 
-int Image::read(uint64_t ofs, size_t len, bufferlist& bl)
+ssize_t Image::read(uint64_t ofs, size_t len, bufferlist& bl)
 {
   ImageCtx *ictx = (ImageCtx *)ctx;
   bufferptr ptr(len);
@@ -1473,7 +1473,7 @@ int64_t Image::read_iterate(uint64_t ofs, size_t len,
   return librbd::read_iterate(ictx, ofs, len, cb, arg);
 }
 
-int Image::write(uint64_t ofs, size_t len, bufferlist& bl)
+ssize_t Image::write(uint64_t ofs, size_t len, bufferlist& bl)
 {
   ImageCtx *ictx = (ImageCtx *)ctx;
   if (bl.length() < len)
@@ -1671,7 +1671,7 @@ extern "C" int rbd_snap_set(rbd_image_t image, const char *snapname)
 }
 
 /* I/O */
-extern "C" int rbd_read(rbd_image_t image, uint64_t ofs, size_t len, char *buf)
+extern "C" ssize_t rbd_read(rbd_image_t image, uint64_t ofs, size_t len, char *buf)
 {
   librbd::ImageCtx *ictx = (librbd::ImageCtx *)image;
   return librbd::read(ictx, ofs, len, buf);
@@ -1684,7 +1684,7 @@ extern "C" int64_t rbd_read_iterate(rbd_image_t image, uint64_t ofs, size_t len,
   return librbd::read_iterate(ictx, ofs, len, cb, arg);
 }
 
-extern "C" int rbd_write(rbd_image_t image, uint64_t ofs, size_t len, const char *buf)
+extern "C" ssize_t rbd_write(rbd_image_t image, uint64_t ofs, size_t len, const char *buf)
 {
   librbd::ImageCtx *ictx = (librbd::ImageCtx *)image;
   return librbd::write(ictx, ofs, len, buf);
@@ -1717,7 +1717,7 @@ extern "C" int rbd_aio_wait_for_complete(rbd_completion_t c)
   return comp->wait_for_complete();
 }
 
-extern "C" int rbd_aio_get_return_value(rbd_completion_t c)
+extern "C" ssize_t rbd_aio_get_return_value(rbd_completion_t c)
 {
   librbd::RBD::AioCompletion *comp = (librbd::RBD::AioCompletion *)c;
   return comp->get_return_value();
index 0580759a5bc9d00e1de1e5f8b65a6e7f1a2aecf3..89a06064415e5dc9639e96488c87b7a642fb1349 100644 (file)
@@ -200,7 +200,7 @@ static int do_rollback_snap(librbd::Image& image, const char *snapname)
 
 static int export_read_cb(uint64_t ofs, size_t len, const char *buf, void *arg)
 {
-  int ret;
+  ssize_t ret;
   int fd = *(int *)arg;
 
   if (!buf) /* a hole */