From a90f3dd0d57d73fdcf77eb2d074821ab62caa30b Mon Sep 17 00:00:00 2001 From: Alex Elder Date: Wed, 1 May 2013 12:43:03 -0500 Subject: [PATCH] --- yaml --- r: 373543 b: refs/heads/master c: 1c2a9dfe2107e81b9f0ee90845c687cf7ff84106 h: refs/heads/master i: 373541: c1549fea6b99ff4cf838a890d007ca3445be2e35 373539: 2afd4aac3dc11ad549d0310799b5c7df737f4437 373535: 887dbfcf2fd525c578c3ccc347f254a1ccac96a3 v: v3 --- [refs] | 2 +- trunk/drivers/block/rbd.c | 39 ++++++++++++++++++++++++++++++++++----- 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/[refs] b/[refs] index 7c088652a6b7..ecca52617140 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 30d1cff817808fca9801c743d2de4c61f3f38e15 +refs/heads/master: 1c2a9dfe2107e81b9f0ee90845c687cf7ff84106 diff --git a/trunk/drivers/block/rbd.c b/trunk/drivers/block/rbd.c index 82d9586a4172..e90abde47de0 100644 --- a/trunk/drivers/block/rbd.c +++ b/trunk/drivers/block/rbd.c @@ -40,6 +40,7 @@ #include #include #include +#include #include "rbd_types.h" @@ -344,6 +345,8 @@ static DEFINE_SPINLOCK(rbd_dev_list_lock); static LIST_HEAD(rbd_client_list); /* clients */ static DEFINE_SPINLOCK(rbd_client_list_lock); +static struct kmem_cache *rbd_img_request_cache; + static int rbd_img_request_submit(struct rbd_img_request *img_request); static void rbd_dev_device_release(struct device *dev); @@ -1821,7 +1824,7 @@ static struct rbd_img_request *rbd_img_request_create( { struct rbd_img_request *img_request; - img_request = kmalloc(sizeof (*img_request), GFP_ATOMIC); + img_request = kmem_cache_alloc(rbd_img_request_cache, GFP_ATOMIC); if (!img_request) return NULL; @@ -1884,7 +1887,7 @@ static void rbd_img_request_destroy(struct kref *kref) if (img_request_child_test(img_request)) rbd_obj_request_put(img_request->obj_request); - kfree(img_request); + kmem_cache_free(rbd_img_request_cache, img_request); } static bool rbd_img_obj_end_request(struct rbd_obj_request *obj_request) @@ -4992,6 +4995,26 @@ static void rbd_sysfs_cleanup(void) device_unregister(&rbd_root_dev); } +static int rbd_slab_init(void) +{ + rbd_assert(!rbd_img_request_cache); + rbd_img_request_cache = kmem_cache_create("rbd_img_request", + sizeof (struct rbd_img_request), + __alignof__(struct rbd_img_request), + 0, NULL); + if (rbd_img_request_cache) + return 0; + + return -ENOMEM; +} + +static void rbd_slab_exit(void) +{ + rbd_assert(rbd_img_request_cache); + kmem_cache_destroy(rbd_img_request_cache); + rbd_img_request_cache = NULL; +} + static int __init rbd_init(void) { int rc; @@ -5001,16 +5024,22 @@ static int __init rbd_init(void) return -EINVAL; } - rc = rbd_sysfs_init(); + rc = rbd_slab_init(); if (rc) return rc; - pr_info("loaded " RBD_DRV_NAME_LONG "\n"); - return 0; + rc = rbd_sysfs_init(); + if (rc) + rbd_slab_exit(); + else + pr_info("loaded " RBD_DRV_NAME_LONG "\n"); + + return rc; } static void __exit rbd_exit(void) { rbd_sysfs_cleanup(); + rbd_slab_exit(); } module_init(rbd_init);