]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cls/rbd, librbd: use uint64_t for sparse_size
authorKefu Chai <kchai@redhat.com>
Tue, 27 Apr 2021 10:24:24 +0000 (18:24 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 27 Apr 2021 11:08:00 +0000 (19:08 +0800)
the size of `size_t` is varies from architecture to architecture. the
C++ standard only requires it to be able to represent the maximum possible
size of object of any type. on 32-bit architectures, it's very likely a
32-bit unsigned integer. to ensure the interoperability between the
64-bit systems and 32-bit systems, we should use a type with explicitly
defined size.

also, we don't define the dencoder for size_t. so on systems where
size_t is not backed by uint32_t or uint64_t, the tree does not compile.

in this change, use uint64_t for sparse_size. and leave
`C_SparsifyObject::m_sparse_size` intact. as the latter should be able
to be promoted to uint64_t when necessary.

this change is backward compatible on 64-bit systems.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/cls/rbd/cls_rbd.cc
src/cls/rbd/cls_rbd_client.cc
src/cls/rbd/cls_rbd_client.h
src/librbd/WatchNotifyTypes.h

index 33910b7df518282f603cb1ad5ff7e65c90e0a3df..e3e05d85ed500466f139d268532d08f7db590ed0 100644 (file)
@@ -7996,7 +7996,7 @@ int namespace_list(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
  */
 int sparsify(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
 {
-  size_t sparse_size;
+  uint64_t sparse_size;
   bool remove_empty;
   try {
     auto iter = in->cbegin();
index cefa1fed79391c3fbbc0196a976ba8a6d04760e9..fee3ac8923cc356e388345da84f5c31bea3a73a3 100644 (file)
@@ -2974,7 +2974,7 @@ int namespace_list(librados::IoCtx *ioctx,
   return namespace_list_finish(&iter, entries);
 }
 
-void sparsify(librados::ObjectWriteOperation *op, size_t sparse_size,
+void sparsify(librados::ObjectWriteOperation *op, uint64_t sparse_size,
               bool remove_empty)
 {
   bufferlist bl;
@@ -2983,7 +2983,7 @@ void sparsify(librados::ObjectWriteOperation *op, size_t sparse_size,
   op->exec("rbd", "sparsify", bl);
 }
 
-int sparsify(librados::IoCtx *ioctx, const std::string &oid, size_t sparse_size,
+int sparsify(librados::IoCtx *ioctx, const std::string &oid, uint64_t sparse_size,
              bool remove_empty)
 {
   librados::ObjectWriteOperation op;
index 12b34c48327087e9d2531d6c4227a349ad93c862..ef2b05fd8449e816eead0f98f13a999451e138ec 100644 (file)
@@ -652,9 +652,9 @@ int sparse_copyup(librados::IoCtx *ioctx, const std::string &oid,
                   const std::map<uint64_t, uint64_t> &extent_map,
                   ceph::buffer::list data);
 
-void sparsify(librados::ObjectWriteOperation *op, size_t sparse_size,
+void sparsify(librados::ObjectWriteOperation *op, uint64_t sparse_size,
               bool remove_empty);
-int sparsify(librados::IoCtx *ioctx, const std::string &oid, size_t sparse_size,
+int sparsify(librados::IoCtx *ioctx, const std::string &oid, uint64_t sparse_size,
              bool remove_empty);
 
 } // namespace cls_client
index ca0b40f28f0c80df39e065b7fe806880496b479e..4fad31ffac93d87ebac883657fcf0339e7471e91 100644 (file)
@@ -410,10 +410,10 @@ struct MigratePayload : public AsyncRequestPayloadBase {
 };
 
 struct SparsifyPayload : public AsyncRequestPayloadBase {
-  size_t sparse_size = 0;
+  uint64_t sparse_size = 0;
 
   SparsifyPayload() {}
-  SparsifyPayload(const AsyncRequestId &id, size_t sparse_size)
+  SparsifyPayload(const AsyncRequestId &id, uint64_t sparse_size)
     : AsyncRequestPayloadBase(id), sparse_size(sparse_size) {
   }