X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Fobdclass%2Fcl_object.c;h=9e65b3a1a4bd80001bdda3e376f5280523d1e174;hp=eefba725dd203b3a5f896a1f43f843acdaa7af39;hb=9f55850b884cac1c7bbde6d3b02764b712a2921f;hpb=e409c8d33474dd4dc1ae1200bfc94207b2a33093 diff --git a/lustre/obdclass/cl_object.c b/lustre/obdclass/cl_object.c index eefba72..9e65b3a 100644 --- a/lustre/obdclass/cl_object.c +++ b/lustre/obdclass/cl_object.c @@ -76,6 +76,8 @@ static cfs_lock_class_key_t cl_lock_guard_class; /** Lock class of cl_object_header::coh_attr_guard */ static cfs_lock_class_key_t cl_attr_guard_class; +static __u32 cl_ctx_tags; +static __u32 cl_ses_tags; /** * Initialize cl_object_header. */ @@ -613,7 +615,8 @@ static void cl_env_init0(struct cl_env *cle, void *debug) static cfs_hash_t *cl_env_hash; -static unsigned cl_env_hops_hash(cfs_hash_t *lh, void *key, unsigned mask) +static unsigned cl_env_hops_hash(cfs_hash_t *lh, + const void *key, unsigned mask) { #if BITS_PER_LONG == 64 return cfs_hash_u64_hash((__u64)key, mask); @@ -629,7 +632,7 @@ static void *cl_env_hops_obj(cfs_hlist_node_t *hn) return (void *)cle; } -static int cl_env_hops_compare(void *key, cfs_hlist_node_t *hn) +static int cl_env_hops_keycmp(const void *key, cfs_hlist_node_t *hn) { struct cl_env *cle = cl_env_hops_obj(hn); @@ -637,12 +640,19 @@ static int cl_env_hops_compare(void *key, cfs_hlist_node_t *hn) return (key == cle->ce_owner); } +static void cl_env_hops_noop(cfs_hash_t *hs, cfs_hlist_node_t *hn) +{ + struct cl_env *cle = cfs_hlist_entry(hn, struct cl_env, ce_node); + LASSERT(cle->ce_magic == &cl_env_init0); +} + static cfs_hash_ops_t cl_env_hops = { - .hs_hash = cl_env_hops_hash, - .hs_compare = cl_env_hops_compare, - .hs_key = cl_env_hops_obj, - .hs_get = cl_env_hops_obj, - .hs_put = cl_env_hops_obj, + .hs_hash = cl_env_hops_hash, + .hs_key = cl_env_hops_obj, + .hs_keycmp = cl_env_hops_keycmp, + .hs_object = cl_env_hops_obj, + .hs_get = cl_env_hops_noop, + .hs_put_locked = cl_env_hops_noop, }; static inline struct cl_env *cl_env_fetch(void) @@ -679,8 +689,13 @@ static inline void cl_env_do_detach(struct cl_env *cle) } static int cl_env_store_init(void) { - cl_env_hash = cfs_hash_create("cl_env", 8, 10, &cl_env_hops, - CFS_HASH_REHASH); + cl_env_hash = cfs_hash_create("cl_env", + HASH_CL_ENV_BITS, HASH_CL_ENV_BITS, + HASH_CL_ENV_BKT_BITS, 0, + CFS_HASH_MIN_THETA, + CFS_HASH_MAX_THETA, + &cl_env_hops, + CFS_HASH_RW_BKTLOCK); return cl_env_hash != NULL ? 0 :-ENOMEM; } @@ -737,7 +752,7 @@ static inline struct cl_env *cl_env_detach(struct cl_env *cle) return cle; } -static struct lu_env *cl_env_new(__u32 tags, void *debug) +static struct lu_env *cl_env_new(__u32 ctx_tags, __u32 ses_tags, void *debug) { struct lu_env *env; struct cl_env *cle; @@ -749,9 +764,10 @@ static struct lu_env *cl_env_new(__u32 tags, void *debug) CFS_INIT_LIST_HEAD(&cle->ce_linkage); cle->ce_magic = &cl_env_init0; env = &cle->ce_lu; - rc = lu_env_init(env, LCT_CL_THREAD|tags); + rc = lu_env_init(env, LCT_CL_THREAD|ctx_tags); if (rc == 0) { - rc = lu_context_init(&cle->ce_ses, LCT_SESSION|tags); + rc = lu_context_init(&cle->ce_ses, + LCT_SESSION | ses_tags); if (rc == 0) { lu_context_enter(&cle->ce_ses); env->le_ses = &cle->ce_ses; @@ -779,6 +795,18 @@ static void cl_env_fini(struct cl_env *cle) OBD_SLAB_FREE_PTR(cle, cl_env_kmem); } +void cl_set_ctx_tags(__u32 tags) +{ + cl_ctx_tags = tags; +} +EXPORT_SYMBOL(cl_set_ctx_tags); + +void cl_set_ses_tags(__u32 tags) +{ + cl_ses_tags = tags; +} +EXPORT_SYMBOL(cl_set_ses_tags); + static struct lu_env *cl_env_obtain(void *debug) { struct cl_env *cle; @@ -807,7 +835,7 @@ static struct lu_env *cl_env_obtain(void *debug) } } else { cfs_spin_unlock(&cl_envs_guard); - env = cl_env_new(0, debug); + env = cl_env_new(cl_ctx_tags, cl_ses_tags, debug); } RETURN(env); } @@ -882,7 +910,7 @@ struct lu_env *cl_env_alloc(int *refcheck, __u32 tags) struct lu_env *env; LASSERT(cl_env_peek(refcheck) == NULL); - env = cl_env_new(tags, __builtin_return_address(0)); + env = cl_env_new(tags, tags, __builtin_return_address(0)); if (!IS_ERR(env)) { struct cl_env *cle; @@ -1230,17 +1258,31 @@ int cl_global_init(void) return result; result = lu_kmem_init(cl_object_caches); - if (result == 0) { - LU_CONTEXT_KEY_INIT(&cl_key); - result = lu_context_key_register(&cl_key); - if (result == 0) { - result = cl_lock_init(); - if (result == 0) - result = cl_page_init(); - } - } if (result) - cl_env_store_fini(); + goto out_store; + + LU_CONTEXT_KEY_INIT(&cl_key); + result = lu_context_key_register(&cl_key); + if (result) + goto out_kmem; + + result = cl_lock_init(); + if (result) + goto out_context; + + result = cl_page_init(); + if (result) + goto out_lock; + + return 0; +out_lock: + cl_lock_fini(); +out_context: + lu_context_key_degister(&cl_key); +out_kmem: + lu_kmem_fini(cl_object_caches); +out_store: + cl_env_store_fini(); return result; }