Whamcloud - gitweb
LU-1304 mdd: use slab for mdd objects
authorAlex Zhuravlev <bzzz@whamcloud.com>
Mon, 3 Sep 2012 15:15:43 +0000 (19:15 +0400)
committerOleg Drokin <green@whamcloud.com>
Thu, 20 Sep 2012 02:04:01 +0000 (22:04 -0400)
taken from orion

Signed-off-by: Alex Zhuravlev <bzzz@whamcloud.com>
Change-Id: I52c415a92e271732436182f61d861467d7514dc4
Reviewed-on: http://review.whamcloud.com/3864
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Jinshan Xiong <jinshan.xiong@whamcloud.com>
lustre/mdd/mdd_device.c
lustre/mdd/mdd_object.c

index f61df7c..cda1272 100644 (file)
@@ -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. <http://www.lustre.org/>");
index e106ee9..ef9193f 100644 (file)
@@ -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,