From 9742069c1e8d73042fc735ac42e31d5fdb369b29 Mon Sep 17 00:00:00 2001 From: Alex Zhuravlev Date: Mon, 3 Sep 2012 19:15:43 +0400 Subject: [PATCH] LU-1304 mdd: use slab for mdd objects taken from orion Signed-off-by: Alex Zhuravlev Change-Id: I52c415a92e271732436182f61d861467d7514dc4 Reviewed-on: http://review.whamcloud.com/3864 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Jinshan Xiong --- lustre/mdd/mdd_device.c | 28 ++++++++++++++++++++++++++-- lustre/mdd/mdd_object.c | 5 +++-- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/lustre/mdd/mdd_device.c b/lustre/mdd/mdd_device.c index f61df7c..cda1272 100644 --- a/lustre/mdd/mdd_device.c +++ b/lustre/mdd/mdd_device.c @@ -66,6 +66,20 @@ static struct lu_device_type mdd_device_type; static const char mdd_root_dir_name[] = "ROOT"; static const char mdd_obf_dir_name[] = "fid"; +/* Slab for MDD object allocation */ +cfs_mem_cache_t *mdd_object_kmem; + +static struct lu_kmem_descr mdd_caches[] = { + { + .ckd_cache = &mdd_object_kmem, + .ckd_name = "mdd_obj", + .ckd_size = sizeof(struct mdd_object) + }, + { + .ckd_cache = NULL + } +}; + static int mdd_device_init(const struct lu_env *env, struct lu_device *d, const char *name, struct lu_device *next) { @@ -1749,15 +1763,24 @@ static struct lu_local_obj_desc llod_lfsck_bookmark = { static int __init mdd_mod_init(void) { struct lprocfs_static_vars lvars; + int rc; + lprocfs_mdd_init_vars(&lvars); + rc = lu_kmem_init(mdd_caches); + if (rc) + return rc; + llo_local_obj_register(&llod_capa_key); llo_local_obj_register(&llod_mdd_orphan); llo_local_obj_register(&llod_mdd_root); llo_local_obj_register(&llod_lfsck_bookmark); - return class_register_type(&mdd_obd_device_ops, NULL, lvars.module_vars, - LUSTRE_MDD_NAME, &mdd_device_type); + rc = class_register_type(&mdd_obd_device_ops, NULL, lvars.module_vars, + LUSTRE_MDD_NAME, &mdd_device_type); + if (rc) + lu_kmem_fini(mdd_caches); + return rc; } static void __exit mdd_mod_exit(void) @@ -1768,6 +1791,7 @@ static void __exit mdd_mod_exit(void) llo_local_obj_unregister(&llod_lfsck_bookmark); class_unregister_type(LUSTRE_MDD_NAME); + lu_kmem_fini(mdd_caches); } MODULE_AUTHOR("Sun Microsystems, Inc. "); diff --git a/lustre/mdd/mdd_object.c b/lustre/mdd/mdd_object.c index e106ee9..ef9193f 100644 --- a/lustre/mdd/mdd_object.c +++ b/lustre/mdd/mdd_object.c @@ -58,6 +58,7 @@ #include "mdd_internal.h" static const struct lu_object_operations mdd_lu_obj_ops; +extern cfs_mem_cache_t *mdd_object_kmem; static int mdd_xattr_get(const struct lu_env *env, struct md_object *obj, struct lu_buf *buf, @@ -240,7 +241,7 @@ struct lu_object *mdd_object_alloc(const struct lu_env *env, { struct mdd_object *mdd_obj; - OBD_ALLOC_PTR(mdd_obj); + OBD_SLAB_ALLOC_PTR_GFP(mdd_obj, mdd_object_kmem, CFS_ALLOC_IO); if (mdd_obj != NULL) { struct lu_object *o; @@ -290,7 +291,7 @@ static void mdd_object_free(const struct lu_env *env, struct lu_object *o) struct mdd_object *mdd = lu2mdd_obj(o); lu_object_fini(o); - OBD_FREE_PTR(mdd); + OBD_SLAB_FREE_PTR(mdd, mdd_object_kmem); } static int mdd_object_print(const struct lu_env *env, void *cookie, -- 1.8.3.1