]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: Fix potential uint64_t to int conversion issue.
authorMark Nelson <mnelson@redhat.com>
Tue, 29 May 2018 19:23:41 +0000 (14:23 -0500)
committerJosh Durgin <jdurgin@redhat.com>
Tue, 27 Nov 2018 02:08:17 +0000 (21:08 -0500)
Signed-off-by: Mark Nelson <mnelson@redhat.com>
(cherry picked from commit 1d51e764500f519018f572282ef0a269914edfd4)

src/os/bluestore/BlueStore.cc

index 9335dc0daa2d34f6eba52027a4738faab49ca9bf..e3016889317c724ec1074fecaba1c0763317358c 100644 (file)
@@ -827,9 +827,10 @@ void BlueStore::LRUCache::_trim(uint64_t onode_max, uint64_t buffer_max)
   }
 
   // onodes
-  int num = onode_lru.size() - onode_max;
-  if (num <= 0)
+  if (onode_max >= onode_lru.size()) {
     return; // don't even try
+  }
+  uint64_t num = onode_lru.size() - onode_max;
 
   auto p = onode_lru.end();
   ceph_assert(p != onode_lru.begin());
@@ -1123,9 +1124,10 @@ void BlueStore::TwoQCache::_trim(uint64_t onode_max, uint64_t buffer_max)
   }
 
   // onodes
-  int num = onode_lru.size() - onode_max;
-  if (num <= 0)
+  if (onode_max >= onode_lru.size()) {
     return; // don't even try
+  }
+  uint64_t num = onode_lru.size() - onode_max;
 
   auto p = onode_lru.end();
   ceph_assert(p != onode_lru.begin());