]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rados, rbd: off_t -> uint64_t
authorSage Weil <sage.weil@dreamhost.com>
Sun, 13 Mar 2011 17:20:15 +0000 (10:20 -0700)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Mon, 14 Mar 2011 12:48:02 +0000 (05:48 -0700)
off_t is 32-bit on 32-bit archs when compiled without _FILE_OFFSET_BITS=64.
Avoid any such ambiguity in the library interface.

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

index 8d3be57101a856574db7f07f04811b101b33676d..aca57fcf77b932c620f854286a581c5e8670db34 100644 (file)
@@ -82,7 +82,7 @@ void rados_reopen_log(rados_t cluster);
  * buffer. If len == -1, we'll call malloc() and set *buf.
  * Returns 0 on success, error code otherwise. Returns ENAMETOOLONG if the
  * buffer is too short. */
-int rados_conf_get(rados_t cluster, const char *option, char *buf, int len);
+int rados_conf_get(rados_t cluster, const char *option, char *buf, size_t len);
 
 /* pools */
 
@@ -94,7 +94,7 @@ int rados_conf_get(rados_t cluster, const char *option, char *buf, int len);
  * as much as we can.
  * Returns the length of the buffer we would need to list all pools.
  */
-int rados_pool_list(rados_t cluster, char *buf, int len);
+int rados_pool_list(rados_t cluster, char *buf, size_t len);
 
 int rados_ioctx_create(rados_t cluster, const char *pool_name, rados_ioctx_t *ioctx);
 void rados_ioctx_destroy(rados_ioctx_t io);
@@ -136,9 +136,9 @@ int rados_ioctx_snap_get_stamp(rados_ioctx_t io, rados_snap_t id, time_t *t);
 /* sync io */
 uint64_t rados_get_last_version(rados_ioctx_t io);
 
-int rados_write(rados_ioctx_t io, const char *oid, const char *buf, size_t len, off_t off);
-int rados_write_full(rados_ioctx_t io, const char *oid, const char *buf, size_t len, off_t off);
-int rados_read(rados_ioctx_t io, const char *oid, char *buf, size_t len, off_t off);
+int rados_write(rados_ioctx_t io, const char *oid, const char *buf, size_t len, uint64_t off);
+int rados_write_full(rados_ioctx_t io, const char *oid, const char *buf, size_t len, uint64_t off);
+int rados_read(rados_ioctx_t io, const char *oid, char *buf, size_t len, uint64_t off);
 int rados_remove(rados_ioctx_t io, const char *oid);
 int rados_trunc(rados_ioctx_t io, const char *oid, size_t size);
 
@@ -168,13 +168,13 @@ uint64_t rados_aio_get_obj_ver(rados_completion_t c);
 void rados_aio_release(rados_completion_t c);
 int rados_aio_write(rados_ioctx_t io, const char *oid,
                    rados_completion_t completion,
-                   const char *buf, size_t len, off_t off);
+                   const char *buf, size_t len, uint64_t off);
 int rados_aio_write_full(rados_ioctx_t io, const char *oid,
                         rados_completion_t completion,
                         const char *buf, size_t len);
 int rados_aio_read(rados_ioctx_t io, const char *oid,
                   rados_completion_t completion,
-                  char *buf, size_t len, off_t off);
+                  char *buf, size_t len, uint64_t off);
 
 /* watch/notify */
 typedef void (*rados_watchcb_t)(uint8_t opcode, uint64_t ver, void *arg);
index e9f5d7698449d3c316049f5e2bd7e74f593c7725..4a11d868abecee8dda54e8646c92f1856d8ae3ca 100644 (file)
@@ -117,13 +117,13 @@ namespace librados
     // create an object
     int create(const std::string& oid, bool exclusive);
 
-    int write(const std::string& oid, bufferlist& bl, size_t len, off_t off);
+    int write(const std::string& oid, bufferlist& bl, size_t len, uint64_t off);
     int write_full(const std::string& oid, bufferlist& bl);
-    int read(const std::string& oid, bufferlist& bl, size_t len, off_t off);
+    int read(const std::string& oid, bufferlist& bl, size_t len, uint64_t off);
     int remove(const std::string& oid);
     int trunc(const std::string& oid, size_t size);
-    int mapext(const std::string& o, off_t off, size_t len, std::map<off_t, size_t>& m);
-    int sparse_read(const std::string& o, std::map<off_t, size_t>& m, bufferlist& bl, size_t len, off_t off);
+    int mapext(const std::string& o, uint64_t off, size_t len, std::map<uint64_t, size_t>& m);
+    int sparse_read(const std::string& o, std::map<uint64_t, size_t>& m, bufferlist& bl, size_t len, uint64_t off);
     int getxattr(const std::string& oid, const char *name, bufferlist& bl);
     int getxattrs(const std::string& oid, std::map<std::string, bufferlist>& attrset);
     int setxattr(const std::string& oid, const char *name, bufferlist& bl);
@@ -166,12 +166,12 @@ namespace librados
     uint64_t get_last_version();
 
     int aio_read(const std::string& oid, AioCompletion *c,
-                bufferlist *pbl, size_t len, off_t off);
+                bufferlist *pbl, size_t len, uint64_t off);
     int aio_sparse_read(const std::string& oid, AioCompletion *c,
-                       std::map<off_t,size_t> *m, bufferlist *data_bl,
-                       size_t len, off_t off);
+                       std::map<uint64_t,size_t> *m, bufferlist *data_bl,
+                       size_t len, uint64_t off);
     int aio_write(const std::string& oid, AioCompletion *c, const bufferlist& bl,
-                 size_t len, off_t off);
+                 size_t len, uint64_t off);
     int aio_write_full(const std::string& oid, AioCompletion *c, const bufferlist& bl);
 
     // watch/notify
index 2206648197402272ccf8676fe8c7fc5a1903eee5..56fa311e2841e139dfa13354f593dad558594ad9 100644 (file)
@@ -81,12 +81,12 @@ 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, off_t ofs, size_t len, char *buf);
-int rbd_read_iterate(rbd_image_t image, off_t ofs, size_t len,
-                    int (*cb)(off_t, size_t, const char *, void *), void *arg);
-int rbd_write(rbd_image_t image, off_t ofs, size_t len, const char *buf);
-int rbd_aio_write(rbd_image_t image, off_t off, size_t len, const char *buf, rbd_completion_t c);
-int rbd_aio_read(rbd_image_t image, off_t off, size_t len, char *buf, rbd_completion_t c);
+int rbd_read(rbd_image_t image, uint64_t ofs, size_t len, char *buf);
+int 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);
+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);
index 66a46a66d59f96c2d37d9ba0a382e973107d36d6..6b557baddc31e45c3c1cc677f3edf8025e7be0d3 100644 (file)
@@ -88,13 +88,13 @@ public:
   int snap_set(const char *snap_name);
 
   /* I/O */
-  int read(off_t ofs, size_t len, ceph::bufferlist& bl);
-  int read_iterate(off_t ofs, size_t len,
-                   int (*cb)(off_t, size_t, const char *, void *), void *arg);
-  int write(off_t ofs, size_t len, ceph::bufferlist& bl);
+  int read(uint64_t ofs, size_t len, ceph::bufferlist& bl);
+  int 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);
 
-  int aio_write(off_t off, size_t len, ceph::bufferlist& bl, RBD::AioCompletion *c);
-  int aio_read(off_t off, size_t len, ceph::bufferlist& bl, RBD::AioCompletion *c);
+  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);
 
 private:
   friend class RBD;
index 11861ec155fc204d01f065606e318df4e200729d..6544a7047f58373d1010e6b0e04290fa697fc530 100644 (file)
@@ -303,12 +303,12 @@ public:
 
   // io
   int create(IoCtxImpl& io, const object_t& oid, bool exclusive);
-  int write(IoCtxImpl& io, const object_t& oid, bufferlist& bl, size_t len, off_t off);
+  int write(IoCtxImpl& io, const object_t& oid, bufferlist& bl, size_t len, uint64_t off);
   int write_full(IoCtxImpl& io, const object_t& oid, bufferlist& bl);
-  int read(IoCtxImpl& io, const object_t& oid, bufferlist& bl, size_t len, off_t off);
-  int mapext(IoCtxImpl& io, const object_t& oid, off_t off, size_t len, std::map<off_t,size_t>& m);
-  int sparse_read(IoCtxImpl& io, const object_t& oid, std::map<off_t,size_t>& m, bufferlist& bl,
-                 size_t len, off_t off);
+  int read(IoCtxImpl& io, const object_t& oid, bufferlist& bl, size_t len, uint64_t off);
+  int mapext(IoCtxImpl& io, const object_t& oid, uint64_t off, size_t len, std::map<uint64_t,size_t>& m);
+  int sparse_read(IoCtxImpl& io, const object_t& oid, std::map<uint64_t,size_t>& m, bufferlist& bl,
+                 size_t len, uint64_t off);
   int remove(IoCtxImpl& io, const object_t& oid);
   int stat(IoCtxImpl& io, const object_t& oid, uint64_t *psize, time_t *pmtime);
   int trunc(IoCtxImpl& io, const object_t& oid, size_t size);
@@ -366,7 +366,7 @@ public:
   struct C_aio_sparse_read_Ack : public Context {
     AioCompletionImpl *c;
     bufferlist *data_bl;
-    std::map<off_t,size_t> *m;
+    std::map<uint64_t,size_t> *m;
 
     void finish(int r) {
       c->lock.Lock();
@@ -422,14 +422,14 @@ public:
   };
 
   int aio_read(IoCtxImpl& io, const object_t oid, AioCompletionImpl *c,
-                         bufferlist *pbl, size_t len, off_t off);
+                         bufferlist *pbl, size_t len, uint64_t off);
   int aio_read(IoCtxImpl& io, object_t oid, AioCompletionImpl *c,
-              char *buf, size_t len, off_t off);
+              char *buf, size_t len, uint64_t off);
   int aio_sparse_read(IoCtxImpl& io, const object_t oid,
-                   AioCompletionImpl *c, std::map<off_t,size_t> *m,
-                   bufferlist *data_bl, size_t len, off_t off);
+                   AioCompletionImpl *c, std::map<uint64_t,size_t> *m,
+                   bufferlist *data_bl, size_t len, uint64_t off);
   int aio_write(IoCtxImpl& io, const object_t &oid, AioCompletionImpl *c,
-               const bufferlist& bl, size_t len, off_t off);
+               const bufferlist& bl, size_t len, uint64_t off);
   int aio_write_full(IoCtxImpl& io, const object_t &oid, AioCompletionImpl *c,
                     const bufferlist& bl);
 
@@ -1058,7 +1058,7 @@ create(IoCtxImpl& io, const object_t& oid, bool exclusive)
 }
 
 int librados::RadosClient::
-write(IoCtxImpl& io, const object_t& oid, bufferlist& bl, size_t len, off_t off)
+write(IoCtxImpl& io, const object_t& oid, bufferlist& bl, size_t len, uint64_t off)
 {
   utime_t ut = g_clock.now();
 
@@ -1142,7 +1142,7 @@ write_full(IoCtxImpl& io, const object_t& oid, bufferlist& bl)
 
 int librados::RadosClient::
 aio_read(IoCtxImpl& io, const object_t oid, AioCompletionImpl *c,
-         bufferlist *pbl, size_t len, off_t off)
+         bufferlist *pbl, size_t len, uint64_t off)
 {
 
   Context *onack = new C_aio_Ack(c);
@@ -1159,7 +1159,7 @@ aio_read(IoCtxImpl& io, const object_t oid, AioCompletionImpl *c,
 
 int librados::RadosClient::
 aio_read(IoCtxImpl& io, const object_t oid, AioCompletionImpl *c,
-         char *buf, size_t len, off_t off)
+         char *buf, size_t len, uint64_t off)
 {
   Context *onack = new C_aio_Ack(c);
 
@@ -1176,8 +1176,8 @@ aio_read(IoCtxImpl& io, const object_t oid, AioCompletionImpl *c,
 
 int librados::RadosClient::
 aio_sparse_read(IoCtxImpl& io, const object_t oid,
-                AioCompletionImpl *c, std::map<off_t,size_t> *m,
-                bufferlist *data_bl, size_t len, off_t off)
+                AioCompletionImpl *c, std::map<uint64_t,size_t> *m,
+                bufferlist *data_bl, size_t len, uint64_t off)
 {
 
   C_aio_sparse_read_Ack *onack = new C_aio_sparse_read_Ack(c);
@@ -1196,7 +1196,7 @@ aio_sparse_read(IoCtxImpl& io, const object_t oid,
 
 int librados::RadosClient::
 aio_write(IoCtxImpl& io, const object_t &oid, AioCompletionImpl *c,
-          const bufferlist& bl, size_t len, off_t off)
+          const bufferlist& bl, size_t len, uint64_t off)
 {
   utime_t ut = g_clock.now();
 
@@ -1377,7 +1377,7 @@ exec(IoCtxImpl& io, const object_t& oid, const char *cls, const char *method,
 
 int librados::
 RadosClient::read(IoCtxImpl& io, const object_t& oid,
-                  bufferlist& bl, size_t len, off_t off)
+                  bufferlist& bl, size_t len, uint64_t off)
 {
   Mutex mylock("RadosClient::read::mylock");
   Cond cond;
@@ -1418,7 +1418,7 @@ RadosClient::read(IoCtxImpl& io, const object_t& oid,
 }
 
 int librados::RadosClient::
-mapext(IoCtxImpl& io, const object_t& oid, off_t off, size_t len, std::map<off_t,size_t>& m)
+mapext(IoCtxImpl& io, const object_t& oid, uint64_t off, size_t len, std::map<uint64_t,size_t>& m)
 {
   bufferlist bl;
 
@@ -1451,7 +1451,7 @@ mapext(IoCtxImpl& io, const object_t& oid, off_t off, size_t len, std::map<off_t
 
 int librados::RadosClient::
 sparse_read(IoCtxImpl& io, const object_t& oid,
-         std::map<off_t,size_t>& m, bufferlist& data_bl, size_t len, off_t off)
+         std::map<uint64_t,size_t>& m, bufferlist& data_bl, size_t len, uint64_t off)
 {
   bufferlist bl;
 
@@ -2056,7 +2056,7 @@ create(const std::string& oid, bool exclusive)
 }
 
 int librados::IoCtx::
-write(const std::string& oid, bufferlist& bl, size_t len, off_t off)
+write(const std::string& oid, bufferlist& bl, size_t len, uint64_t off)
 {
   object_t obj(oid);
   return io_ctx_impl->client->write(*io_ctx_impl, obj, bl, len, off);
@@ -2070,7 +2070,7 @@ write_full(const std::string& oid, bufferlist& bl)
 }
 
 int librados::IoCtx::
-read(const std::string& oid, bufferlist& bl, size_t len, off_t off)
+read(const std::string& oid, bufferlist& bl, size_t len, uint64_t off)
 {
   object_t obj(oid);
   return io_ctx_impl->client->read(*io_ctx_impl, obj, bl, len, off);
@@ -2091,15 +2091,15 @@ trunc(const std::string& oid, size_t size)
 }
 
 int librados::IoCtx::
-mapext(const std::string& oid, off_t off, size_t len, std::map<off_t, size_t>& m)
+mapext(const std::string& oid, uint64_t off, size_t len, std::map<uint64_t, size_t>& m)
 {
   object_t obj(oid);
   return io_ctx_impl->client->mapext(*io_ctx_impl, oid, off, len, m);
 }
 
 int librados::IoCtx::
-sparse_read(const std::string& oid, std::map<off_t, size_t>& m,
-           bufferlist& bl, size_t len, off_t off)
+sparse_read(const std::string& oid, std::map<uint64_t, size_t>& m,
+           bufferlist& bl, size_t len, uint64_t off)
 {
   object_t obj(oid);
   return io_ctx_impl->client->sparse_read(*io_ctx_impl, oid, m, bl, len, off);
@@ -2250,15 +2250,15 @@ get_last_version()
 
 int librados::IoCtx::
 aio_read(const std::string& oid, librados::AioCompletion *c,
-        bufferlist *pbl, size_t len, off_t off)
+        bufferlist *pbl, size_t len, uint64_t off)
 {
   return io_ctx_impl->client->aio_read(*io_ctx_impl, oid, c->pc, pbl, len, off);
 }
 
 int librados::IoCtx::
 aio_sparse_read(const std::string& oid, librados::AioCompletion *c,
-               std::map<off_t,size_t> *m, bufferlist *data_bl,
-               size_t len, off_t off)
+               std::map<uint64_t,size_t> *m, bufferlist *data_bl,
+               size_t len, uint64_t off)
 {
   return io_ctx_impl->client->aio_sparse_read(*io_ctx_impl, oid, c->pc,
                                           m, data_bl, len, off);
@@ -2266,7 +2266,7 @@ aio_sparse_read(const std::string& oid, librados::AioCompletion *c,
 
 int librados::IoCtx::
 aio_write(const std::string& oid, librados::AioCompletion *c, const bufferlist& bl,
-         size_t len, off_t off)
+         size_t len, uint64_t off)
 {
   return io_ctx_impl->client->aio_write(*io_ctx_impl, oid, c->pc, bl, len, off );
 }
@@ -2599,11 +2599,9 @@ extern "C" void rados_reopen_log(rados_t cluster)
   sighup_handler(SIGHUP);
 }
 
-extern "C" int rados_conf_get(rados_t cluster, const char *option, char *buf, int len)
+extern "C" int rados_conf_get(rados_t cluster, const char *option, char *buf, size_t len)
 {
   char *tmp = buf;
-  if (len <= 0)
-    return -EINVAL;
   return g_conf.get_val(option, &tmp, len);
 }
 
@@ -2613,7 +2611,7 @@ extern "C" int rados_ioctx_lookup(rados_t cluster, const char *name)
   return radosp->lookup_pool(name);
 }
 
-extern "C" int rados_pool_list(rados_t cluster, char *buf, int len)
+extern "C" int rados_pool_list(rados_t cluster, char *buf, size_t len)
 {
   librados::RadosClient *client = (librados::RadosClient *)cluster;
   std::list<std::string> pools;
@@ -2707,7 +2705,7 @@ extern "C" int rados_snap_set_write_context(rados_ioctx_t io, rados_snap_t seq,
   return ctx->set_snap_write_context((snapid_t)seq, snv);
 }
 
-extern "C" int rados_write(rados_ioctx_t io, const char *o, const char *buf, size_t len, off_t off)
+extern "C" int rados_write(rados_ioctx_t io, const char *o, const char *buf, size_t len, uint64_t off)
 {
   librados::IoCtxImpl *ctx = (librados::IoCtxImpl *)io;
   object_t oid(o);
@@ -2739,7 +2737,7 @@ extern "C" int rados_remove(rados_ioctx_t io, const char *o)
   return ctx->client->remove(*ctx, oid);
 }
 
-extern "C" int rados_read(rados_ioctx_t io, const char *o, char *buf, size_t len, off_t off)
+extern "C" int rados_read(rados_ioctx_t io, const char *o, char *buf, size_t len, uint64_t off)
 {
   librados::IoCtxImpl *ctx = (librados::IoCtxImpl *)io;
   int ret;
@@ -3055,7 +3053,7 @@ extern "C" void rados_aio_release(rados_completion_t c)
 
 extern "C" int rados_aio_read(rados_ioctx_t io, const char *o,
                               rados_completion_t completion,
-                              char *buf, size_t len, off_t off)
+                              char *buf, size_t len, uint64_t off)
 {
   librados::IoCtxImpl *ctx = (librados::IoCtxImpl *)io;
   object_t oid(o);
@@ -3065,7 +3063,7 @@ extern "C" int rados_aio_read(rados_ioctx_t io, const char *o,
 
 extern "C" int rados_aio_write(rados_ioctx_t io, const char *o,
                                rados_completion_t completion,
-                               const char *buf, size_t len, off_t off)
+                               const char *buf, size_t len, uint64_t off)
 {
   librados::IoCtxImpl *ctx = (librados::IoCtxImpl *)io;
   object_t oid(o);
index 89991869000f72c43eb69027fcf1e102512f494e..7f57d25c10545ff862150aa3004b943fd2f34a86 100644 (file)
@@ -121,7 +121,7 @@ namespace librbd {
     off_t ofs;
     size_t len;
     char *buf;
-    map<off_t, size_t> m;
+    map<uint64_t, size_t> m;
     bufferlist data_bl;
 
     AioBlockCompletion(AioCompletion *aio_completion, off_t _ofs, size_t _len, char *_buf) :
@@ -938,8 +938,8 @@ int copy(IoCtx& src_md_ctx, const char *srcname, IoCtx& dest_md_ctx, const char
     bufferlist bl;
     string oid = get_block_oid(&header, i);
     string dest_oid = get_block_oid(&dest_header, i);
-    map<off_t, size_t> m;
-    map<off_t, size_t>::iterator iter;
+    map<uint64_t, size_t> m;
+    map<uint64_t, size_t>::iterator iter;
     r = src_data_ctx.sparse_read(oid, m, bl, block_size, 0);
     if (r < 0 && r == -ENOENT)
       r = 0;
@@ -948,7 +948,7 @@ int copy(IoCtx& src_md_ctx, const char *srcname, IoCtx& dest_md_ctx, const char
 
 
     for (iter = m.begin(); iter != m.end(); ++iter) {
-      off_t extent_ofs = iter->first;
+      uint64_t extent_ofs = iter->first;
       size_t extent_len = iter->second;
       bufferlist wrbl;
       if (extent_ofs + extent_len > bl.length()) {
@@ -1017,8 +1017,8 @@ void close_image(ImageCtx *ictx)
   ictx = NULL;
 }
 
-int read_iterate(ImageCtx *ictx, off_t off, size_t len,
-                int (*cb)(off_t, size_t, const char *, void *),
+int read_iterate(ImageCtx *ictx, uint64_t off, size_t len,
+                int (*cb)(uint64_t, size_t, const char *, void *),
                 void *arg)
 {
   int r = ictx_check(ictx);
@@ -1038,9 +1038,9 @@ int read_iterate(ImageCtx *ictx, off_t off, size_t len,
     uint64_t block_ofs = get_block_ofs(&ictx->header, off + total_read);
     uint64_t read_len = min(block_size - block_ofs, left);
 
-    map<off_t, size_t> m;
-    map<off_t, size_t>::iterator iter;
-    off_t bl_ofs = 0, buf_bl_pos = 0;
+    map<uint64_t, size_t> m;
+    map<uint64_t, size_t>::iterator iter;
+    uint64_t bl_ofs = 0, buf_bl_pos = 0;
     r = ictx->data_ctx.sparse_read(oid, m, bl, read_len, block_ofs);
     if (r < 0 && r == -ENOENT)
       r = 0;
@@ -1049,7 +1049,7 @@ int read_iterate(ImageCtx *ictx, off_t off, size_t len,
       goto done;
     }
     for (iter = m.begin(); iter != m.end(); ++iter) {
-      off_t extent_ofs = iter->first;
+      uint64_t extent_ofs = iter->first;
       size_t extent_len = iter->second;
       /* a hole? */
       if (extent_ofs - block_ofs) {
@@ -1085,7 +1085,7 @@ done:
   return ret;
 }
 
-static int simple_read_cb(off_t ofs, size_t len, const char *buf, void *arg)
+static int simple_read_cb(uint64_t ofs, size_t len, const char *buf, void *arg)
 {
   char *dest_buf = (char *)arg;
   if (buf)
@@ -1097,12 +1097,12 @@ static int simple_read_cb(off_t ofs, size_t len, const char *buf, void *arg)
 }
 
 
-int read(ImageCtx *ictx, off_t ofs, size_t len, char *buf)
+int 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, off_t off, size_t len, const char *buf)
+int write(ImageCtx *ictx, uint64_t off, size_t len, const char *buf)
 {
   if (!len)
     return 0;
@@ -1138,11 +1138,11 @@ void AioBlockCompletion::complete(int r)
 {
   dout(10) << "AioBlockCompletion::complete()" << dendl;
   if ((r >= 0 || r == -ENOENT) && buf) { // this was a sparse_read operation
-    map<off_t, size_t>::iterator iter;
-    off_t bl_ofs = 0, buf_bl_pos = 0;
+    map<uint64_t, size_t>::iterator iter;
+    uint64_t bl_ofs = 0, buf_bl_pos = 0;
     dout(10) << "ofs=" << ofs << " len=" << len << dendl;
     for (iter = m.begin(); iter != m.end(); ++iter) {
-      off_t extent_ofs = iter->first;
+      uint64_t extent_ofs = iter->first;
       size_t extent_len = iter->second;
 
       dout(10) << "extent_ofs=" << extent_ofs << " extent_len=" << extent_len << dendl;
@@ -1208,7 +1208,7 @@ void rados_cb(rados_completion_t c, void *arg)
   block_completion->complete(rados_aio_get_return_value(c));
 }
 
-int aio_write(ImageCtx *ictx, off_t off, size_t len, const char *buf,
+int aio_write(ImageCtx *ictx, uint64_t off, size_t len, const char *buf,
                                 AioCompletion *c)
 {
   if (!len)
@@ -1256,7 +1256,7 @@ void rados_aio_sparse_read_cb(rados_completion_t c, void *arg)
   block_completion->complete(rados_aio_get_return_value(c));
 }
 
-int aio_read(ImageCtx *ictx, off_t off, size_t len,
+int aio_read(ImageCtx *ictx, uint64_t off, size_t len,
                                char *buf,
                                 AioCompletion *c)
 {
@@ -1277,8 +1277,8 @@ int aio_read(ImageCtx *ictx, off_t off, size_t len,
     uint64_t block_ofs = get_block_ofs(&ictx->header, off + total_read);
     uint64_t read_len = min(block_size - block_ofs, left);
 
-    map<off_t, size_t> m;
-    map<off_t, size_t>::iterator iter;
+    map<uint64_t, size_t> m;
+    map<uint64_t, size_t>::iterator iter;
 
     AioBlockCompletion *block_completion = new AioBlockCompletion(c, block_ofs, read_len, buf + total_read);
     c->add_block_completion(block_completion);
@@ -1458,7 +1458,7 @@ int Image::snap_set(const char *snap_name)
   return librbd::snap_set(ictx, snap_name);
 }
 
-int Image::read(off_t ofs, size_t len, bufferlist& bl)
+int Image::read(uint64_t ofs, size_t len, bufferlist& bl)
 {
   ImageCtx *ictx = (ImageCtx *)ctx;
   bufferptr ptr(len);
@@ -1466,14 +1466,14 @@ int Image::read(off_t ofs, size_t len, bufferlist& bl)
   return librbd::read(ictx, ofs, len, bl.c_str());
 }
 
-int Image::read_iterate(off_t ofs, size_t len,
-                   int (*cb)(off_t, size_t, const char *, void *), void *arg)
+int Image::read_iterate(uint64_t ofs, size_t len,
+                   int (*cb)(uint64_t, size_t, const char *, void *), void *arg)
 {
   ImageCtx *ictx = (ImageCtx *)ctx;
   return librbd::read_iterate(ictx, ofs, len, cb, arg);
 }
 
-int Image::write(off_t ofs, size_t len, bufferlist& bl)
+int Image::write(uint64_t ofs, size_t len, bufferlist& bl)
 {
   ImageCtx *ictx = (ImageCtx *)ctx;
   if (bl.length() < len)
@@ -1481,7 +1481,7 @@ int Image::write(off_t ofs, size_t len, bufferlist& bl)
   return librbd::write(ictx, ofs, len, bl.c_str());
 }
 
-int Image::aio_write(off_t off, size_t len, bufferlist& bl, RBD::AioCompletion *c)
+int Image::aio_write(uint64_t off, size_t len, bufferlist& bl, RBD::AioCompletion *c)
 {
   ImageCtx *ictx = (ImageCtx *)ctx;
   if (bl.length() < len)
@@ -1489,7 +1489,7 @@ int Image::aio_write(off_t off, size_t len, bufferlist& bl, RBD::AioCompletion *
   return librbd::aio_write(ictx, off, len, bl.c_str(), (librbd::AioCompletion *)c->pc);
 }
 
-int Image::aio_read(off_t off, size_t len, bufferlist& bl, RBD::AioCompletion *c)
+int Image::aio_read(uint64_t off, size_t len, bufferlist& bl, RBD::AioCompletion *c)
 {
   ImageCtx *ictx = (ImageCtx *)ctx;
   bufferptr ptr(len);
@@ -1671,20 +1671,20 @@ extern "C" int rbd_snap_set(rbd_image_t image, const char *snapname)
 }
 
 /* I/O */
-extern "C" int rbd_read(rbd_image_t image, off_t ofs, size_t len, char *buf)
+extern "C" int 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);
 }
 
-extern "C" int rbd_read_iterate(rbd_image_t image, off_t ofs, size_t len,
-                               int (*cb)(off_t, size_t, const char *, void *), void *arg)
+extern "C" int rbd_read_iterate(rbd_image_t image, uint64_t ofs, size_t len,
+                               int (*cb)(uint64_t, size_t, const char *, void *), void *arg)
 {
   librbd::ImageCtx *ictx = (librbd::ImageCtx *)image;
   return librbd::read_iterate(ictx, ofs, len, cb, arg);
 }
 
-extern "C" int rbd_write(rbd_image_t image, off_t ofs, size_t len, const char *buf)
+extern "C" int 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);
@@ -1697,14 +1697,14 @@ extern "C" int rbd_aio_create_completion(void *cb_arg, rbd_callback_t complete_c
   return 0;
 }
 
-extern "C" int rbd_aio_write(rbd_image_t image, off_t off, size_t len, const char *buf, rbd_completion_t c)
+extern "C" int rbd_aio_write(rbd_image_t image, uint64_t off, size_t len, const char *buf, rbd_completion_t c)
 {
   librbd::ImageCtx *ictx = (librbd::ImageCtx *)image;
   librbd::RBD::AioCompletion *comp = (librbd::RBD::AioCompletion *)c;
   return librbd::aio_write(ictx, off, len, buf, (librbd::AioCompletion *)comp->pc);
 }
 
-extern "C" int rbd_aio_read(rbd_image_t image, off_t off, size_t len, char *buf, rbd_completion_t c)
+extern "C" int rbd_aio_read(rbd_image_t image, uint64_t off, size_t len, char *buf, rbd_completion_t c)
 {
   librbd::ImageCtx *ictx = (librbd::ImageCtx *)image;
   librbd::RBD::AioCompletion *comp = (librbd::RBD::AioCompletion *)c;
index b50af0bcd942c4cdf956ea33a85284f40e78a7ac..bd56effd743e8a7d7a9a77e2d08dcbca73a72a0b 100644 (file)
@@ -263,13 +263,13 @@ int main(int argc, const char **argv)
     if (!pool_name || nargs.size() < 2)
       usage();
     string oid(nargs[1]);
-    std::map<off_t, size_t> m;
+    std::map<uint64_t, size_t> m;
     ret = io_ctx.mapext(oid, 0, -1, m);
     if (ret < 0) {
       cerr << "mapext error on " << pool_name << "/" << oid << ": " << strerror_r(-ret, buf, sizeof(buf)) << std::endl;
       return 1;
     }
-    std::map<off_t, size_t>::iterator iter;
+    std::map<uint64_t, size_t>::iterator iter;
     for (iter = m.begin(); iter != m.end(); ++iter) {
       cout << hex << iter->first << "\t" << iter->second << dec << std::endl;
     }
index 1e5531bf1d98ca2b5b5903c4d04054f31b4a5679..5fd428bffe2b7cabed38e7944b322736d665390d 100644 (file)
@@ -198,7 +198,7 @@ static int do_rollback_snap(librbd::Image& image, const char *snapname)
   return 0;
 }
 
-static int export_read_cb(off_t ofs, size_t len, const char *buf, void *arg)
+static int export_read_cb(uint64_t ofs, size_t len, const char *buf, void *arg)
 {
   int ret;
   int fd = *(int *)arg;