From: Andreas Dilger Date: Wed, 27 Mar 2024 23:08:04 +0000 (-0600) Subject: LU-17680 ldlm: fix ldlm_res_hop_hash() argument X-Git-Tag: 2.15.62~15 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=7bdbe5d8e30199eb198d8136d53ffa36c5c482c8;p=fs%2Flustre-release.git LU-17680 ldlm: fix ldlm_res_hop_hash() argument Change ldlm_res_hop_hash() to use "bits" instead of "mask" as the last argument. Otherwise, this is hashing all of the LDLM resources down to very few buckets (e.g. "hash & 8" or "hash & 11") instead of the full bit range (e.g. "hash & ((1 << 8) - 1)". This is causing significant slowdowns for file creation performance, in particular sanity test_123ac was running 2x slower when creating a large number of files because of the bad hashing. Fixes: ce404bd07c ("LU-17174 misc: fix hash functions") Signed-off-by: Andreas Dilger Change-Id: I823b370bdb7fac4e673d1b479204dd1216931fb6 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/54585 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Alex Zhuravlev Reviewed-by: Oleg Drokin Reviewed-by: James Simmons Reviewed-by: Alexey Lyashkov --- diff --git a/lustre/ldlm/ldlm_resource.c b/lustre/ldlm/ldlm_resource.c index 26cf77d..46ade03 100644 --- a/lustre/ldlm/ldlm_resource.c +++ b/lustre/ldlm/ldlm_resource.c @@ -767,7 +767,7 @@ static int ldlm_namespace_debugfs_register(struct ldlm_namespace *ns) #undef MAX_STRING_SIZE static unsigned int ldlm_res_hop_hash(struct cfs_hash *hs, - const void *key, unsigned int mask) + const void *key, const unsigned int bits) { const struct ldlm_res_id *id = key; unsigned int val = 0; @@ -775,11 +775,12 @@ static unsigned int ldlm_res_hop_hash(struct cfs_hash *hs, for (i = 0; i < RES_NAME_SIZE; i++) val += id->name[i]; - return val & mask; + + return val & ((1UL << bits) - 1); } static unsigned int ldlm_res_hop_fid_hash(const struct ldlm_res_id *id, - unsigned int bits) + const unsigned int bits) { struct lu_fid fid; __u32 hash;