From 5ed7865ae8880f47c4715d7db4f069f60544128f Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Wed, 15 Jan 2014 15:57:51 -0800 Subject: [PATCH] rgw: use configurable prime number for gc hash Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_gc.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/rgw/rgw_gc.cc b/src/rgw/rgw_gc.cc index 353afd5847a81..1b2b8ca9afb3f 100644 --- a/src/rgw/rgw_gc.cc +++ b/src/rgw/rgw_gc.cc @@ -17,11 +17,17 @@ using namespace librados; static string gc_oid_prefix = "gc"; static string gc_index_lock_name = "gc_process"; + +#define HASH_PRIME 7877 + void RGWGC::initialize(CephContext *_cct, RGWRados *_store) { cct = _cct; store = _store; max_objs = cct->_conf->rgw_gc_max_objs; + if (max_objs > HASH_PRIME) + max_objs = HASH_PRIME; + obj_names = new string[max_objs]; for (int i = 0; i < max_objs; i++) { @@ -39,7 +45,7 @@ void RGWGC::finalize() int RGWGC::tag_index(const string& tag) { - return ceph_str_hash_linux(tag.c_str(), tag.size()) % max_objs; + return ceph_str_hash_linux(tag.c_str(), tag.size()) % HASH_PRIME % max_objs; } void RGWGC::add_chain(ObjectWriteOperation& op, cls_rgw_obj_chain& chain, const string& tag) -- 2.39.5