From: Gabriel BenHanokh Date: Tue, 18 Nov 2025 21:53:50 +0000 (+0200) Subject: rgw/dedup: Prevent the dup-counter from wrapping around after it reaches 64K of ident... X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2227ae6e5aea98e8bbdc5c504a6aaa0aace067d1;p=ceph-ci.git rgw/dedup: Prevent the dup-counter from wrapping around after it reaches 64K of identical copies. Resolves: rhbz#2415656 Signed-off-by: Gabriel BenHanokh --- diff --git a/src/rgw/rgw_dedup_table.cc b/src/rgw/rgw_dedup_table.cc index 09335655df6..bbaaf99c621 100644 --- a/src/rgw/rgw_dedup_table.cc +++ b/src/rgw/rgw_dedup_table.cc @@ -128,7 +128,14 @@ namespace rgw::dedup { } else { ceph_assert(hash_tab[idx].key == *p_key); - val.count ++; + if (val.count < std::numeric_limits::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::["