}
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::["