From: Sage Weil Date: Thu, 2 Jun 2016 20:03:00 +0000 (-0400) Subject: osd: use spg_t method to hash pg to (wq) shard X-Git-Tag: v11.0.0~302^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=09c3dc95f84093214da5291ded0926221d6ede1e;p=ceph.git osd: use spg_t method to hash pg to (wq) shard Signed-off-by: Sage Weil --- diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index d3404e7a70b3..db015b0417dd 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -8805,8 +8805,8 @@ void OSD::ShardedOpWQ::_process(uint32_t thread_index, heartbeat_handle_d *hb ) } void OSD::ShardedOpWQ::_enqueue(pair item) { - - uint32_t shard_index = (((item.first)->get_pgid().ps())% shard_list.size()); + uint32_t shard_index = + (item.first)->get_pgid().hash_to_shard(shard_list.size()); ShardData* sdata = shard_list[shard_index]; assert (NULL != sdata); diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index 619a5e659f0d..fa33c9f0efbe 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -511,6 +511,10 @@ struct spg_t { ghobject_t::NO_GEN, shard); } + + unsigned hash_to_shard(unsigned num_shards) const { + return ps() % num_shards; + } }; WRITE_CLASS_ENCODER(spg_t) WRITE_EQ_OPERATORS_2(spg_t, pgid, shard)