]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
d4n/policy: Change `size_t` argument type and add error checking to
authorSamarah <samarah.uriarte@ibm.com>
Fri, 5 Jan 2024 19:51:36 +0000 (19:51 +0000)
committerPritha Srivastava <prsrivas@redhat.com>
Tue, 2 Apr 2024 15:54:52 +0000 (21:24 +0530)
`set_local_weight_sum` method

Signed-off-by: Samarah <samarah.uriarte@ibm.com>
src/rgw/driver/d4n/d4n_policy.cc
src/rgw/driver/d4n/d4n_policy.h

index 7b17c4477e74431505091628d2115738fbaf3e7b..f53aafc445ebda3766058b60a6e067a88087ad5f 100644 (file)
@@ -104,7 +104,9 @@ int LFUDAPolicy::get_age(optional_yield y) {
   }
 }
 
-int LFUDAPolicy::set_local_weight_sum(size_t weight, optional_yield y) {
+int LFUDAPolicy::set_local_weight_sum(int weight, optional_yield y) {
+  weight = weight > 0 ? weight : 0;
+
   try {
     boost::system::error_code ec;
     response<int> resp;
@@ -320,7 +322,7 @@ int LFUDAPolicy::eviction(const DoutPrefixProvider* dpp, uint64_t size, optional
     ldpp_dout(dpp, 10) << "LFUDAPolicy::" << __func__ << "(): Block " << key << " has been evicted." << dendl;
 
     int weight = (avgWeight * entries_map.size()) - it->second->localWeight;
-    if (int ret = set_local_weight_sum((weight > 0) ? weight : 0, y) < 0)
+    if (int ret = set_local_weight_sum(weight, y) < 0)
       return ret;
 
     int age = get_age(y);
index a9181bdb24fd22dee2abbc987d6d5da6446294a1..e7c7781efcadd3ac55ec1a422b1c8b1ed4ff3de3 100644 (file)
@@ -72,7 +72,7 @@ class LFUDAPolicy : public CachePolicy {
 
     int set_age(int age, optional_yield y);
     int get_age(optional_yield y);
-    int set_local_weight_sum(size_t weight, optional_yield y);
+    int set_local_weight_sum(int weight, optional_yield y);
     int get_local_weight_sum(optional_yield y);
     CacheBlock* get_victim_block(const DoutPrefixProvider* dpp, optional_yield y);