aboutsummaryrefslogtreecommitdiffstats
path: root/net/ceph/messenger.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/ceph/messenger.c')
-rw-r--r--net/ceph/messenger.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index bc1ba4c2605d..eb0a46a49bd4 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -155,6 +155,7 @@ static bool con_flag_test_and_set(struct ceph_connection *con,
155/* Slab caches for frequently-allocated structures */ 155/* Slab caches for frequently-allocated structures */
156 156
157static struct kmem_cache *ceph_msg_cache; 157static struct kmem_cache *ceph_msg_cache;
158static struct kmem_cache *ceph_msg_data_cache;
158 159
159/* static tag bytes (protocol control messages) */ 160/* static tag bytes (protocol control messages) */
160static char tag_msg = CEPH_MSGR_TAG_MSG; 161static char tag_msg = CEPH_MSGR_TAG_MSG;
@@ -236,11 +237,30 @@ static int ceph_msgr_slab_init(void)
236 ceph_msg_cache = kmem_cache_create("ceph_msg", 237 ceph_msg_cache = kmem_cache_create("ceph_msg",
237 sizeof (struct ceph_msg), 238 sizeof (struct ceph_msg),
238 __alignof__(struct ceph_msg), 0, NULL); 239 __alignof__(struct ceph_msg), 0, NULL);
239 return ceph_msg_cache ? 0 : -ENOMEM; 240
241 if (!ceph_msg_cache)
242 return -ENOMEM;
243
244 BUG_ON(ceph_msg_data_cache);
245 ceph_msg_data_cache = kmem_cache_create("ceph_msg_data",
246 sizeof (struct ceph_msg_data),
247 __alignof__(struct ceph_msg_data),
248 0, NULL);
249 if (ceph_msg_data_cache)
250 return 0;
251
252 kmem_cache_destroy(ceph_msg_cache);
253 ceph_msg_cache = NULL;
254
255 return -ENOMEM;
240} 256}
241 257
242static void ceph_msgr_slab_exit(void) 258static void ceph_msgr_slab_exit(void)
243{ 259{
260 BUG_ON(!ceph_msg_data_cache);
261 kmem_cache_destroy(ceph_msg_data_cache);
262 ceph_msg_data_cache = NULL;
263
244 BUG_ON(!ceph_msg_cache); 264 BUG_ON(!ceph_msg_cache);
245 kmem_cache_destroy(ceph_msg_cache); 265 kmem_cache_destroy(ceph_msg_cache);
246 ceph_msg_cache = NULL; 266 ceph_msg_cache = NULL;
@@ -3008,7 +3028,7 @@ static struct ceph_msg_data *ceph_msg_data_create(enum ceph_msg_data_type type)
3008 if (WARN_ON(!ceph_msg_data_type_valid(type))) 3028 if (WARN_ON(!ceph_msg_data_type_valid(type)))
3009 return NULL; 3029 return NULL;
3010 3030
3011 data = kzalloc(sizeof (*data), GFP_NOFS); 3031 data = kmem_cache_zalloc(ceph_msg_data_cache, GFP_NOFS);
3012 if (data) 3032 if (data)
3013 data->type = type; 3033 data->type = type;
3014 INIT_LIST_HEAD(&data->links); 3034 INIT_LIST_HEAD(&data->links);
@@ -3026,7 +3046,7 @@ static void ceph_msg_data_destroy(struct ceph_msg_data *data)
3026 ceph_pagelist_release(data->pagelist); 3046 ceph_pagelist_release(data->pagelist);
3027 kfree(data->pagelist); 3047 kfree(data->pagelist);
3028 } 3048 }
3029 kfree(data); 3049 kmem_cache_free(ceph_msg_data_cache, data);
3030} 3050}
3031 3051
3032void ceph_msg_data_add_pages(struct ceph_msg *msg, struct page **pages, 3052void ceph_msg_data_add_pages(struct ceph_msg *msg, struct page **pages,