aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/dlm/dlmmaster.c
diff options
context:
space:
mode:
authorSunil Mushran <sunil.mushran@oracle.com>2008-03-10 18:16:20 -0400
committerMark Fasheh <mfasheh@suse.com>2008-04-18 11:56:08 -0400
commit724bdca9b8449d9ee5f779dc27ee3d906a04508c (patch)
treec12d1028d862a58ce7a01024ba9b1f04ab157e3b /fs/ocfs2/dlm/dlmmaster.c
parent12eb0035d6f0466038ef2c6e5f6f9296b9b74d91 (diff)
ocfs2/dlm: Create slabcaches for lock and lockres
This patch makes the o2dlm allocate memory for lockres, lockname and lock structures from slabcaches rather than kmalloc. This allows us to not only make these allocs more efficient but also allows us to track the memory being consumed by these structures. Signed-off-by: Sunil Mushran <sunil.mushran@oracle.com> Signed-off-by: Joel Becker <joel.becker@oracle.com> Signed-off-by: Mark Fasheh <mfasheh@suse.com>
Diffstat (limited to 'fs/ocfs2/dlm/dlmmaster.c')
-rw-r--r--fs/ocfs2/dlm/dlmmaster.c61
1 files changed, 49 insertions, 12 deletions
diff --git a/fs/ocfs2/dlm/dlmmaster.c b/fs/ocfs2/dlm/dlmmaster.c
index 90797c591018..ac9ed31e5445 100644
--- a/fs/ocfs2/dlm/dlmmaster.c
+++ b/fs/ocfs2/dlm/dlmmaster.c
@@ -216,10 +216,10 @@ EXPORT_SYMBOL_GPL(dlm_dump_all_mles);
216 216
217#endif /* 0 */ 217#endif /* 0 */
218 218
219 219static struct kmem_cache *dlm_lockres_cache = NULL;
220static struct kmem_cache *dlm_lockname_cache = NULL;
220static struct kmem_cache *dlm_mle_cache = NULL; 221static struct kmem_cache *dlm_mle_cache = NULL;
221 222
222
223static void dlm_mle_release(struct kref *kref); 223static void dlm_mle_release(struct kref *kref);
224static void dlm_init_mle(struct dlm_master_list_entry *mle, 224static void dlm_init_mle(struct dlm_master_list_entry *mle,
225 enum dlm_mle_type type, 225 enum dlm_mle_type type,
@@ -560,6 +560,35 @@ static void dlm_mle_release(struct kref *kref)
560 * LOCK RESOURCE FUNCTIONS 560 * LOCK RESOURCE FUNCTIONS
561 */ 561 */
562 562
563int dlm_init_master_caches(void)
564{
565 dlm_lockres_cache = kmem_cache_create("o2dlm_lockres",
566 sizeof(struct dlm_lock_resource),
567 0, SLAB_HWCACHE_ALIGN, NULL);
568 if (!dlm_lockres_cache)
569 goto bail;
570
571 dlm_lockname_cache = kmem_cache_create("o2dlm_lockname",
572 DLM_LOCKID_NAME_MAX, 0,
573 SLAB_HWCACHE_ALIGN, NULL);
574 if (!dlm_lockname_cache)
575 goto bail;
576
577 return 0;
578bail:
579 dlm_destroy_master_caches();
580 return -ENOMEM;
581}
582
583void dlm_destroy_master_caches(void)
584{
585 if (dlm_lockname_cache)
586 kmem_cache_destroy(dlm_lockname_cache);
587
588 if (dlm_lockres_cache)
589 kmem_cache_destroy(dlm_lockres_cache);
590}
591
563static void dlm_set_lockres_owner(struct dlm_ctxt *dlm, 592static void dlm_set_lockres_owner(struct dlm_ctxt *dlm,
564 struct dlm_lock_resource *res, 593 struct dlm_lock_resource *res,
565 u8 owner) 594 u8 owner)
@@ -642,9 +671,9 @@ static void dlm_lockres_release(struct kref *kref)
642 BUG_ON(!list_empty(&res->recovering)); 671 BUG_ON(!list_empty(&res->recovering));
643 BUG_ON(!list_empty(&res->purge)); 672 BUG_ON(!list_empty(&res->purge));
644 673
645 kfree(res->lockname.name); 674 kmem_cache_free(dlm_lockname_cache, (void *)res->lockname.name);
646 675
647 kfree(res); 676 kmem_cache_free(dlm_lockres_cache, res);
648} 677}
649 678
650void dlm_lockres_put(struct dlm_lock_resource *res) 679void dlm_lockres_put(struct dlm_lock_resource *res)
@@ -700,20 +729,28 @@ struct dlm_lock_resource *dlm_new_lockres(struct dlm_ctxt *dlm,
700 const char *name, 729 const char *name,
701 unsigned int namelen) 730 unsigned int namelen)
702{ 731{
703 struct dlm_lock_resource *res; 732 struct dlm_lock_resource *res = NULL;
704 733
705 res = kmalloc(sizeof(struct dlm_lock_resource), GFP_NOFS); 734 res = (struct dlm_lock_resource *)
735 kmem_cache_zalloc(dlm_lockres_cache, GFP_NOFS);
706 if (!res) 736 if (!res)
707 return NULL; 737 goto error;
708 738
709 res->lockname.name = kmalloc(namelen, GFP_NOFS); 739 res->lockname.name = (char *)
710 if (!res->lockname.name) { 740 kmem_cache_zalloc(dlm_lockname_cache, GFP_NOFS);
711 kfree(res); 741 if (!res->lockname.name)
712 return NULL; 742 goto error;
713 }
714 743
715 dlm_init_lockres(dlm, res, name, namelen); 744 dlm_init_lockres(dlm, res, name, namelen);
716 return res; 745 return res;
746
747error:
748 if (res && res->lockname.name)
749 kmem_cache_free(dlm_lockname_cache, (void *)res->lockname.name);
750
751 if (res)
752 kmem_cache_free(dlm_lockres_cache, res);
753 return NULL;
717} 754}
718 755
719void __dlm_lockres_grab_inflight_ref(struct dlm_ctxt *dlm, 756void __dlm_lockres_grab_inflight_ref(struct dlm_ctxt *dlm,