diff options
author | Mikulas Patocka <mpatocka@redhat.com> | 2009-12-10 18:51:57 -0500 |
---|---|---|
committer | Alasdair G Kergon <agk@redhat.com> | 2009-12-10 18:51:57 -0500 |
commit | 952b355760c196ec014dd0b6878f85a11496e3da (patch) | |
tree | 0a6907fa6dce2bac8afdc2efea774f19bdbb9a17 | |
parent | 542da317668c35036e8471822a564b609d05af66 (diff) |
dm io: use slab for struct io
Allocate "struct io" from a slab.
This patch changes dm-io, so that "struct io" is allocated from a slab cache.
It used to be allocated with kmalloc. Allocating from a slab will be needed
for the next patch, because it requires a special alignment of "struct io"
and kmalloc cannot meet this alignment.
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
-rw-r--r-- | drivers/md/dm-io.c | 21 | ||||
-rw-r--r-- | drivers/md/dm.c | 2 | ||||
-rw-r--r-- | drivers/md/dm.h | 3 |
3 files changed, 25 insertions, 1 deletions
diff --git a/drivers/md/dm-io.c b/drivers/md/dm-io.c index 3a2e6a2f8bdd..b0d264e684fd 100644 --- a/drivers/md/dm-io.c +++ b/drivers/md/dm-io.c | |||
@@ -5,6 +5,8 @@ | |||
5 | * This file is released under the GPL. | 5 | * This file is released under the GPL. |
6 | */ | 6 | */ |
7 | 7 | ||
8 | #include "dm.h" | ||
9 | |||
8 | #include <linux/device-mapper.h> | 10 | #include <linux/device-mapper.h> |
9 | 11 | ||
10 | #include <linux/bio.h> | 12 | #include <linux/bio.h> |
@@ -30,6 +32,8 @@ struct io { | |||
30 | void *context; | 32 | void *context; |
31 | }; | 33 | }; |
32 | 34 | ||
35 | static struct kmem_cache *_dm_io_cache; | ||
36 | |||
33 | /* | 37 | /* |
34 | * io contexts are only dynamically allocated for asynchronous | 38 | * io contexts are only dynamically allocated for asynchronous |
35 | * io. Since async io is likely to be the majority of io we'll | 39 | * io. Since async io is likely to be the majority of io we'll |
@@ -53,7 +57,7 @@ struct dm_io_client *dm_io_client_create(unsigned num_pages) | |||
53 | if (!client) | 57 | if (!client) |
54 | return ERR_PTR(-ENOMEM); | 58 | return ERR_PTR(-ENOMEM); |
55 | 59 | ||
56 | client->pool = mempool_create_kmalloc_pool(ios, sizeof(struct io)); | 60 | client->pool = mempool_create_slab_pool(ios, _dm_io_cache); |
57 | if (!client->pool) | 61 | if (!client->pool) |
58 | goto bad; | 62 | goto bad; |
59 | 63 | ||
@@ -472,3 +476,18 @@ int dm_io(struct dm_io_request *io_req, unsigned num_regions, | |||
472 | &dp, io_req->notify.fn, io_req->notify.context); | 476 | &dp, io_req->notify.fn, io_req->notify.context); |
473 | } | 477 | } |
474 | EXPORT_SYMBOL(dm_io); | 478 | EXPORT_SYMBOL(dm_io); |
479 | |||
480 | int __init dm_io_init(void) | ||
481 | { | ||
482 | _dm_io_cache = KMEM_CACHE(io, 0); | ||
483 | if (!_dm_io_cache) | ||
484 | return -ENOMEM; | ||
485 | |||
486 | return 0; | ||
487 | } | ||
488 | |||
489 | void dm_io_exit(void) | ||
490 | { | ||
491 | kmem_cache_destroy(_dm_io_cache); | ||
492 | _dm_io_cache = NULL; | ||
493 | } | ||
diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 724efc63904d..473f0c3c0192 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c | |||
@@ -275,6 +275,7 @@ static int (*_inits[])(void) __initdata = { | |||
275 | dm_target_init, | 275 | dm_target_init, |
276 | dm_linear_init, | 276 | dm_linear_init, |
277 | dm_stripe_init, | 277 | dm_stripe_init, |
278 | dm_io_init, | ||
278 | dm_kcopyd_init, | 279 | dm_kcopyd_init, |
279 | dm_interface_init, | 280 | dm_interface_init, |
280 | }; | 281 | }; |
@@ -284,6 +285,7 @@ static void (*_exits[])(void) = { | |||
284 | dm_target_exit, | 285 | dm_target_exit, |
285 | dm_linear_exit, | 286 | dm_linear_exit, |
286 | dm_stripe_exit, | 287 | dm_stripe_exit, |
288 | dm_io_exit, | ||
287 | dm_kcopyd_exit, | 289 | dm_kcopyd_exit, |
288 | dm_interface_exit, | 290 | dm_interface_exit, |
289 | }; | 291 | }; |
diff --git a/drivers/md/dm.h b/drivers/md/dm.h index a7663eba17e2..4a95e8fa3607 100644 --- a/drivers/md/dm.h +++ b/drivers/md/dm.h | |||
@@ -118,6 +118,9 @@ int dm_lock_for_deletion(struct mapped_device *md); | |||
118 | void dm_kobject_uevent(struct mapped_device *md, enum kobject_action action, | 118 | void dm_kobject_uevent(struct mapped_device *md, enum kobject_action action, |
119 | unsigned cookie); | 119 | unsigned cookie); |
120 | 120 | ||
121 | int dm_io_init(void); | ||
122 | void dm_io_exit(void); | ||
123 | |||
121 | int dm_kcopyd_init(void); | 124 | int dm_kcopyd_init(void); |
122 | void dm_kcopyd_exit(void); | 125 | void dm_kcopyd_exit(void); |
123 | 126 | ||