]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rgw/dedup: Prevent the dup-counter from wrapping around after it reaches 64K of ident...
authorGabriel BenHanokh <gbenhano@redhat.com>
Tue, 18 Nov 2025 21:53:50 +0000 (23:53 +0200)
committerGabriel BenHanokh <gbenhano@redhat.com>
Tue, 18 Nov 2025 21:53:50 +0000 (23:53 +0200)
Resolves: rhbz#2415656

Signed-off-by: Gabriel BenHanokh <gbenhano@redhat.com>
src/rgw/rgw_dedup_table.cc

index 09335655df626aa225edbfd3e38258adea072389..bbaaf99c621a53a150cb75f19e32681d163f886c 100644 (file)
@@ -128,7 +128,14 @@ namespace rgw::dedup {
     }
     else {
       ceph_assert(hash_tab[idx].key == *p_key);
-      val.count ++;
+      if (val.count < std::numeric_limits<std::uint16_t>::max()) {
+       // val.count is a 16 bit integer, make sure not to wrap-around!
+       // In the extremely unlikely event that the number of identical objects exceeds 64K,
+       //  the estimate generated by the 16-bit counter will be inaccurate.
+       // However, the final, actual deduplication count will remain correct,
+       //  as it is reported using 64-bit counters.
+       val.count ++;
+      }
       if (!val.has_shared_manifest() && shared_manifest) {
         // replace value!
         ldpp_dout(dpp, 20) << __func__ << "::Replace with shared_manifest::["