From: Eric Mei Date: Tue, 21 Sep 2010 18:26:38 +0000 (+0400) Subject: b=22683 fix unbalanced cl_env hash. X-Git-Tag: 2.0.53.0~42 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=56293e79aec17670718dcaf50a733ec5119210d2;hp=e0352157916b834003561ae99042ecc7f1f6d923 b=22683 fix unbalanced cl_env hash. r=andreas.dilger r=di.wang --- diff --git a/lustre/obdclass/cl_object.c b/lustre/obdclass/cl_object.c index 9616efa..1d6572d 100644 --- a/lustre/obdclass/cl_object.c +++ b/lustre/obdclass/cl_object.c @@ -536,7 +536,10 @@ struct cl_env { cfs_hlist_node_t ce_node; /** * Owner for the current cl_env, the key for cfs_hash. - * Now current thread pointer is stored. + * Now current thread pid is stored. Note using thread pointer would + * lead to unbalanced hash because of its specific allocation locality + * and could be varied for different platforms and OSes, even different + * OS versions. */ void *ce_owner; /* @@ -607,7 +610,7 @@ static cfs_hash_ops_t cl_env_hops = { static inline struct cl_env *cl_env_fetch(void) { struct cl_env *cle; - cle = cfs_hash_lookup(cl_env_hash, cfs_current()); + cle = cfs_hash_lookup(cl_env_hash, (void *) (long) cfs_current()->pid); LASSERT(ergo(cle, cle->ce_magic == &cl_env_init0)); return cle; } @@ -617,9 +620,9 @@ static inline void cl_env_attach(struct cl_env *cle) if (cle) { int rc; LASSERT(cle->ce_owner == NULL); - cle->ce_owner = cfs_current(); + cle->ce_owner = (void *) (long) cfs_current()->pid; rc = cfs_hash_add_unique(cl_env_hash, cle->ce_owner, - &cle->ce_node); + &cle->ce_node); LASSERT(rc == 0); } } @@ -630,9 +633,9 @@ static inline struct cl_env *cl_env_detach(struct cl_env *cle) cle = cl_env_fetch(); if (cle && cle->ce_owner) { void *cookie; - LASSERT(cle->ce_owner == cfs_current()); + LASSERT(cle->ce_owner == (void *) (long) cfs_current()->pid); cookie = cfs_hash_del(cl_env_hash, cle->ce_owner, - &cle->ce_node); + &cle->ce_node); cle->ce_owner = NULL; LASSERT(cookie == cle); }