[PATCH] os/bluestore/BlueFS: use uint64_t for `len`
authorKefu Chai <kchai@redhat.com>
Fri, 28 Jun 2019 03:35:54 +0000 (11:35 +0800)
committerThomas Goirand <zigo@debian.org>
Fri, 15 Jan 2021 11:26:14 +0000 (11:26 +0000)
change the type of parameter `len` of `BlueFS::_read_random()` from
`size_t` to `uint64_t`.

i think the type of `size_t` comes from
`rocksdb::RandomAccessFile::Read(uint64_t offset, size_t n,
rocksdb::Slice* result, char* scratch)`. and when we implement this
method, we continued using `n`'s type. but, we are using it with
`std::min()`, for instance, where the template parameter type deduction
fails if the lhs and rhs parameters' types are different. so probaly the
better solution is to use `uint64_t` directly to avoid the the cast and
specializing the template.

Signed-off-by: Kefu Chai <kchai@redhat.com>
Gbp-Pq: Name bluefs-use-uint64_t-for-len.patch

src/os/bluestore/BlueFS.cc
src/os/bluestore/BlueFS.h

index f7a6292318f5fd32eb8e901fd2f9cde9f176f7c0..eaff6a29c3c101f0285a49a4f55d2ef26465e354 100644 (file)
@@ -1526,7 +1526,7 @@ void BlueFS::_drop_link(FileRef file)
 int BlueFS::_read_random(
   FileReader *h,         ///< [in] read from here
   uint64_t off,          ///< [in] offset
-  size_t len,            ///< [in] this many bytes
+  uint64_t len,          ///< [in] this many bytes
   char *out)             ///< [out] optional: or copy it here
 {
   auto* buf = &h->buf;
@@ -1556,7 +1556,7 @@ int BlueFS::_read_random(
       s_lock.unlock();
       uint64_t x_off = 0;
       auto p = h->file->fnode.seek(off, &x_off);
-      uint64_t l = std::min(p->length - x_off, static_cast<uint64_t>(len));
+      uint64_t l = std::min(p->length - x_off, len);
       dout(20) << __func__ << " read random 0x"
               << std::hex << x_off << "~" << l << std::dec
               << " of " << *p << dendl;
index f51312395ccce2b4cfb509691294dd07bc0501c7..2861d25d6e0511ae05beed42ac11d31d51bb78b7 100644 (file)
@@ -412,7 +412,7 @@ private:
   int _read_random(
     FileReader *h,   ///< [in] read from here
     uint64_t offset, ///< [in] offset
-    size_t len,      ///< [in] this many bytes
+    uint64_t len,    ///< [in] this many bytes
     char *out);      ///< [out] optional: or copy it here
 
   void _invalidate_cache(FileRef f, uint64_t offset, uint64_t length);