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;
/*
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;
}
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);
}
}
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);
}