Commit 4198985f authored by Daniel Phillips's avatar Daniel Phillips Committed by Mark Fasheh
Browse files

[PATCH] Clean up ocfs2 hash probe and make it faster


Signed-Off-By: default avatarDaniel Phillips <phillips@google.com>
Signed-off-by: default avatarMark Fasheh <mark.fasheh@oracle.com>
parent a3d33291
...@@ -103,28 +103,27 @@ struct dlm_lock_resource * __dlm_lookup_lockres(struct dlm_ctxt *dlm, ...@@ -103,28 +103,27 @@ struct dlm_lock_resource * __dlm_lookup_lockres(struct dlm_ctxt *dlm,
unsigned int len, unsigned int len,
unsigned int hash) unsigned int hash)
{ {
struct hlist_node *iter;
struct dlm_lock_resource *tmpres=NULL;
struct hlist_head *bucket; struct hlist_head *bucket;
struct hlist_node *list;
mlog_entry("%.*s\n", len, name); mlog_entry("%.*s\n", len, name);
assert_spin_locked(&dlm->spinlock); assert_spin_locked(&dlm->spinlock);
bucket = &(dlm->lockres_hash[hash % DLM_HASH_BUCKETS]); bucket = dlm->lockres_hash + full_name_hash(name, len) % DLM_HASH_BUCKETS;
hlist_for_each(list, bucket) {
/* check for pre-existing lock */ struct dlm_lock_resource *res = hlist_entry(list,
hlist_for_each(iter, bucket) { struct dlm_lock_resource, hash_node);
tmpres = hlist_entry(iter, struct dlm_lock_resource, hash_node); if (res->lockname.name[0] != name[0])
if (tmpres->lockname.len == len && continue;
memcmp(tmpres->lockname.name, name, len) == 0) { if (unlikely(res->lockname.len != len))
dlm_lockres_get(tmpres); continue;
break; if (memcmp(res->lockname.name + 1, name + 1, len - 1))
} continue;
dlm_lockres_get(res);
tmpres = NULL; return res;
} }
return tmpres; return NULL;
} }
struct dlm_lock_resource * dlm_lookup_lockres(struct dlm_ctxt *dlm, struct dlm_lock_resource * dlm_lookup_lockres(struct dlm_ctxt *dlm,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment