]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/restore: take the hash mod HASH_PRIME when picking a shard 69373/head
authorMatthew N. Heler <matthew.heler@hotmail.com>
Tue, 9 Jun 2026 22:21:39 +0000 (17:21 -0500)
committerMatthew N. Heler <matthew.heler@hotmail.com>
Tue, 9 Jun 2026 23:34:47 +0000 (18:34 -0500)
choose_oid fed ceph_str_hash_linux straight into % max_objs, and the
low bits of that hash are weak enough that similar object names keep
landing on the same shard. LC takes the hash mod HASH_PRIME first for
exactly this reason, do the same here.

Signed-off-by: Matthew N. Heler <matthew.heler@hotmail.com>
src/rgw/rgw_restore.cc

index 0cda715e4c61b03cf7ee6801cedbea38bad7e254..a73de2a400837717574e50f96584c21c3d0d45e8 100644 (file)
@@ -266,7 +266,7 @@ std::ostream& Restore::gen_prefix(std::ostream& out) const
 int Restore::choose_oid(const RestoreEntry& e) {
   int index;
   const auto& name = e.bucket.name + e.obj_key.name + e.obj_key.instance;
-  index = ((ceph_str_hash_linux(name.data(), name.size())) % max_objs);
+  index = ((ceph_str_hash_linux(name.data(), name.size())) % HASH_PRIME % max_objs);
   return static_cast<int>(index);
 }