Whamcloud - gitweb
LU-17680 ldlm: fix ldlm_res_hop_hash() argument 85/54585/5
authorAndreas Dilger <adilger@whamcloud.com>
Wed, 27 Mar 2024 23:08:04 +0000 (17:08 -0600)
committerOleg Drokin <green@whamcloud.com>
Mon, 8 Apr 2024 15:36:41 +0000 (15:36 +0000)
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 <adilger@whamcloud.com>
Change-Id: I823b370bdb7fac4e673d1b479204dd1216931fb6
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/54585
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Alexey Lyashkov <alexey.lyashkov@hpe.com>
lustre/ldlm/ldlm_resource.c

index 26cf77d..46ade03 100644 (file)
@@ -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;