From: Alex Zhuravlev Date: Thu, 16 Aug 2012 08:06:07 +0000 (+0400) Subject: LU-1304 mdt: use slab for mdt_objects X-Git-Tag: 2.3.51~140 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=886de3fb6eb2d1e65c85aa13b86422dff08cf1f4 LU-1304 mdt: use slab for mdt_objects should save a bit of memory and cpu Signed-off-by: Alex Zhuravlev Change-Id: I13601aba3c2cdb5e7c0f4c3a45ff5fb6e428b38f Reviewed-on: http://review.whamcloud.com/3781 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Jinshan Xiong --- diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 11c7a76..67645f6 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -195,6 +195,20 @@ static int mdt_fid2path(const struct lu_env *env, struct mdt_device *mdt, static const struct lu_object_operations mdt_obj_ops; +/* Slab for MDT object allocation */ +static cfs_mem_cache_t *mdt_object_kmem; + +static struct lu_kmem_descr mdt_caches[] = { + { + .ckd_cache = &mdt_object_kmem, + .ckd_name = "mdt_obj", + .ckd_size = sizeof(struct mdt_object) + }, + { + .ckd_cache = NULL + } +}; + int mdt_get_disposition(struct ldlm_reply *rep, int flag) { if (!rep) @@ -5009,7 +5023,7 @@ static struct lu_object *mdt_object_alloc(const struct lu_env *env, ENTRY; - OBD_ALLOC_PTR(mo); + OBD_SLAB_ALLOC_PTR_GFP(mo, mdt_object_kmem, CFS_ALLOC_IO); if (mo != NULL) { struct lu_object *o; struct lu_object_header *h; @@ -5061,7 +5075,8 @@ static void mdt_object_free(const struct lu_env *env, struct lu_object *o) lu_object_fini(o); lu_object_header_fini(h); - OBD_FREE_PTR(mo); + OBD_SLAB_FREE_PTR(mo, mdt_object_kmem); + EXIT; } @@ -6028,6 +6043,10 @@ static int __init mdt_mod_init(void) struct lprocfs_static_vars lvars; int rc; + rc = lu_kmem_init(mdt_caches); + if (rc) + return rc; + if (mdt_num_threads != 0 && mds_num_threads == 0) { LCONSOLE_INFO("mdt_num_threads module parameter is deprecated," "use mds_num_threads instead or unset both for" @@ -6040,12 +6059,15 @@ static int __init mdt_mod_init(void) lvars.module_vars, LUSTRE_MDT_NAME, &mdt_device_type); + if (rc) + lu_kmem_fini(mdt_caches); return rc; } static void __exit mdt_mod_exit(void) { class_unregister_type(LUSTRE_MDT_NAME); + lu_kmem_fini(mdt_caches); }