diff options
-rw-r--r-- | fs/ocfs2/dlm/dlmcommon.h | 7 | ||||
-rw-r--r-- | fs/ocfs2/dlm/dlmdomain.c | 26 | ||||
-rw-r--r-- | fs/ocfs2/dlm/dlmlock.c | 22 | ||||
-rw-r--r-- | fs/ocfs2/dlm/dlmmaster.c | 61 |
4 files changed, 99 insertions, 17 deletions
diff --git a/fs/ocfs2/dlm/dlmcommon.h b/fs/ocfs2/dlm/dlmcommon.h index dc8ea666efdb..7525a8ae3943 100644 --- a/fs/ocfs2/dlm/dlmcommon.h +++ b/fs/ocfs2/dlm/dlmcommon.h | |||
@@ -963,9 +963,16 @@ static inline void __dlm_wait_on_lockres(struct dlm_lock_resource *res) | |||
963 | DLM_LOCK_RES_MIGRATING)); | 963 | DLM_LOCK_RES_MIGRATING)); |
964 | } | 964 | } |
965 | 965 | ||
966 | /* create/destroy slab caches */ | ||
967 | int dlm_init_master_caches(void); | ||
968 | void dlm_destroy_master_caches(void); | ||
969 | |||
970 | int dlm_init_lock_cache(void); | ||
971 | void dlm_destroy_lock_cache(void); | ||
966 | 972 | ||
967 | int dlm_init_mle_cache(void); | 973 | int dlm_init_mle_cache(void); |
968 | void dlm_destroy_mle_cache(void); | 974 | void dlm_destroy_mle_cache(void); |
975 | |||
969 | void dlm_hb_event_notify_attached(struct dlm_ctxt *dlm, int idx, int node_up); | 976 | void dlm_hb_event_notify_attached(struct dlm_ctxt *dlm, int idx, int node_up); |
970 | int dlm_drop_lockres_ref(struct dlm_ctxt *dlm, | 977 | int dlm_drop_lockres_ref(struct dlm_ctxt *dlm, |
971 | struct dlm_lock_resource *res); | 978 | struct dlm_lock_resource *res); |
diff --git a/fs/ocfs2/dlm/dlmdomain.c b/fs/ocfs2/dlm/dlmdomain.c index 2ce620742f9e..b092364d0d52 100644 --- a/fs/ocfs2/dlm/dlmdomain.c +++ b/fs/ocfs2/dlm/dlmdomain.c | |||
@@ -1818,21 +1818,41 @@ static int __init dlm_init(void) | |||
1818 | status = dlm_init_mle_cache(); | 1818 | status = dlm_init_mle_cache(); |
1819 | if (status) { | 1819 | if (status) { |
1820 | mlog(ML_ERROR, "Could not create o2dlm_mle slabcache\n"); | 1820 | mlog(ML_ERROR, "Could not create o2dlm_mle slabcache\n"); |
1821 | return -1; | 1821 | goto error; |
1822 | } | ||
1823 | |||
1824 | status = dlm_init_master_caches(); | ||
1825 | if (status) { | ||
1826 | mlog(ML_ERROR, "Could not create o2dlm_lockres and " | ||
1827 | "o2dlm_lockname slabcaches\n"); | ||
1828 | goto error; | ||
1829 | } | ||
1830 | |||
1831 | status = dlm_init_lock_cache(); | ||
1832 | if (status) { | ||
1833 | mlog(ML_ERROR, "Count not create o2dlm_lock slabcache\n"); | ||
1834 | goto error; | ||
1822 | } | 1835 | } |
1823 | 1836 | ||
1824 | status = dlm_register_net_handlers(); | 1837 | status = dlm_register_net_handlers(); |
1825 | if (status) { | 1838 | if (status) { |
1826 | dlm_destroy_mle_cache(); | 1839 | mlog(ML_ERROR, "Unable to register network handlers\n"); |
1827 | return -1; | 1840 | goto error; |
1828 | } | 1841 | } |
1829 | 1842 | ||
1830 | return 0; | 1843 | return 0; |
1844 | error: | ||
1845 | dlm_destroy_lock_cache(); | ||
1846 | dlm_destroy_master_caches(); | ||
1847 | dlm_destroy_mle_cache(); | ||
1848 | return -1; | ||
1831 | } | 1849 | } |
1832 | 1850 | ||
1833 | static void __exit dlm_exit (void) | 1851 | static void __exit dlm_exit (void) |
1834 | { | 1852 | { |
1835 | dlm_unregister_net_handlers(); | 1853 | dlm_unregister_net_handlers(); |
1854 | dlm_destroy_lock_cache(); | ||
1855 | dlm_destroy_master_caches(); | ||
1836 | dlm_destroy_mle_cache(); | 1856 | dlm_destroy_mle_cache(); |
1837 | } | 1857 | } |
1838 | 1858 | ||
diff --git a/fs/ocfs2/dlm/dlmlock.c b/fs/ocfs2/dlm/dlmlock.c index 52578d907d9a..83a9f2972ac8 100644 --- a/fs/ocfs2/dlm/dlmlock.c +++ b/fs/ocfs2/dlm/dlmlock.c | |||
@@ -53,6 +53,8 @@ | |||
53 | #define MLOG_MASK_PREFIX ML_DLM | 53 | #define MLOG_MASK_PREFIX ML_DLM |
54 | #include "cluster/masklog.h" | 54 | #include "cluster/masklog.h" |
55 | 55 | ||
56 | static struct kmem_cache *dlm_lock_cache = NULL; | ||
57 | |||
56 | static DEFINE_SPINLOCK(dlm_cookie_lock); | 58 | static DEFINE_SPINLOCK(dlm_cookie_lock); |
57 | static u64 dlm_next_cookie = 1; | 59 | static u64 dlm_next_cookie = 1; |
58 | 60 | ||
@@ -64,6 +66,22 @@ static void dlm_init_lock(struct dlm_lock *newlock, int type, | |||
64 | static void dlm_lock_release(struct kref *kref); | 66 | static void dlm_lock_release(struct kref *kref); |
65 | static void dlm_lock_detach_lockres(struct dlm_lock *lock); | 67 | static void dlm_lock_detach_lockres(struct dlm_lock *lock); |
66 | 68 | ||
69 | int dlm_init_lock_cache(void) | ||
70 | { | ||
71 | dlm_lock_cache = kmem_cache_create("o2dlm_lock", | ||
72 | sizeof(struct dlm_lock), | ||
73 | 0, SLAB_HWCACHE_ALIGN, NULL); | ||
74 | if (dlm_lock_cache == NULL) | ||
75 | return -ENOMEM; | ||
76 | return 0; | ||
77 | } | ||
78 | |||
79 | void dlm_destroy_lock_cache(void) | ||
80 | { | ||
81 | if (dlm_lock_cache) | ||
82 | kmem_cache_destroy(dlm_lock_cache); | ||
83 | } | ||
84 | |||
67 | /* Tell us whether we can grant a new lock request. | 85 | /* Tell us whether we can grant a new lock request. |
68 | * locking: | 86 | * locking: |
69 | * caller needs: res->spinlock | 87 | * caller needs: res->spinlock |
@@ -353,7 +371,7 @@ static void dlm_lock_release(struct kref *kref) | |||
353 | mlog(0, "freeing kernel-allocated lksb\n"); | 371 | mlog(0, "freeing kernel-allocated lksb\n"); |
354 | kfree(lock->lksb); | 372 | kfree(lock->lksb); |
355 | } | 373 | } |
356 | kfree(lock); | 374 | kmem_cache_free(dlm_lock_cache, lock); |
357 | } | 375 | } |
358 | 376 | ||
359 | /* associate a lock with it's lockres, getting a ref on the lockres */ | 377 | /* associate a lock with it's lockres, getting a ref on the lockres */ |
@@ -412,7 +430,7 @@ struct dlm_lock * dlm_new_lock(int type, u8 node, u64 cookie, | |||
412 | struct dlm_lock *lock; | 430 | struct dlm_lock *lock; |
413 | int kernel_allocated = 0; | 431 | int kernel_allocated = 0; |
414 | 432 | ||
415 | lock = kzalloc(sizeof(*lock), GFP_NOFS); | 433 | lock = (struct dlm_lock *) kmem_cache_zalloc(dlm_lock_cache, GFP_NOFS); |
416 | if (!lock) | 434 | if (!lock) |
417 | return NULL; | 435 | return NULL; |
418 | 436 | ||
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, |