diff options
Diffstat (limited to 'fs/ocfs2/dlm/dlmmaster.c')
-rw-r--r-- | fs/ocfs2/dlm/dlmmaster.c | 61 |
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 | 219 | static struct kmem_cache *dlm_lockres_cache = NULL; | |
220 | static struct kmem_cache *dlm_lockname_cache = NULL; | ||
220 | static struct kmem_cache *dlm_mle_cache = NULL; | 221 | static struct kmem_cache *dlm_mle_cache = NULL; |
221 | 222 | ||
222 | |||
223 | static void dlm_mle_release(struct kref *kref); | 223 | static void dlm_mle_release(struct kref *kref); |
224 | static void dlm_init_mle(struct dlm_master_list_entry *mle, | 224 | static 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 | ||
563 | int 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; | ||
578 | bail: | ||
579 | dlm_destroy_master_caches(); | ||
580 | return -ENOMEM; | ||
581 | } | ||
582 | |||
583 | void 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 | |||
563 | static void dlm_set_lockres_owner(struct dlm_ctxt *dlm, | 592 | static 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 | ||
650 | void dlm_lockres_put(struct dlm_lock_resource *res) | 679 | void 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 | |||
747 | error: | ||
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 | ||
719 | void __dlm_lockres_grab_inflight_ref(struct dlm_ctxt *dlm, | 756 | void __dlm_lockres_grab_inflight_ref(struct dlm_ctxt *dlm, |