aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKiyoshi Ueda <k-ueda@ct.jp.nec.com>2009-01-05 22:05:06 -0500
committerAlasdair G Kergon <agk@redhat.com>2009-01-05 22:05:06 -0500
commit8fbf26ad5b16ad3a826ca7fe3e86700420abed1f (patch)
tree43bc5cc2ca90ea394682daa4b665a46ebb110b97
parent23d39f63aa87e812fd879b8bc32ee6ccfe733de3 (diff)
dm request: add caches
This patch prepares some kmem_caches for request-based dm. Signed-off-by: Kiyoshi Ueda <k-ueda@ct.jp.nec.com> Signed-off-by: Jun'ichi Nomura <j-nomura@ce.jp.nec.com> Signed-off-by: Alasdair G Kergon <agk@redhat.com>
-rw-r--r--drivers/md/dm.c41
1 files changed, 40 insertions, 1 deletions
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 82371412029f..4882ce7e88a3 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -32,6 +32,7 @@ static unsigned int _major = 0;
32 32
33static DEFINE_SPINLOCK(_minor_lock); 33static DEFINE_SPINLOCK(_minor_lock);
34/* 34/*
35 * For bio-based dm.
35 * One of these is allocated per bio. 36 * One of these is allocated per bio.
36 */ 37 */
37struct dm_io { 38struct dm_io {
@@ -43,6 +44,7 @@ struct dm_io {
43}; 44};
44 45
45/* 46/*
47 * For bio-based dm.
46 * One of these is allocated per target within a bio. Hopefully 48 * One of these is allocated per target within a bio. Hopefully
47 * this will be simplified out one day. 49 * this will be simplified out one day.
48 */ 50 */
@@ -54,6 +56,27 @@ struct dm_target_io {
54 56
55DEFINE_TRACE(block_bio_complete); 57DEFINE_TRACE(block_bio_complete);
56 58
59/*
60 * For request-based dm.
61 * One of these is allocated per request.
62 */
63struct dm_rq_target_io {
64 struct mapped_device *md;
65 struct dm_target *ti;
66 struct request *orig, clone;
67 int error;
68 union map_info info;
69};
70
71/*
72 * For request-based dm.
73 * One of these is allocated per bio.
74 */
75struct dm_rq_clone_bio_info {
76 struct bio *orig;
77 struct request *rq;
78};
79
57union map_info *dm_get_mapinfo(struct bio *bio) 80union map_info *dm_get_mapinfo(struct bio *bio)
58{ 81{
59 if (bio && bio->bi_private) 82 if (bio && bio->bi_private)
@@ -149,6 +172,8 @@ struct mapped_device {
149#define MIN_IOS 256 172#define MIN_IOS 256
150static struct kmem_cache *_io_cache; 173static struct kmem_cache *_io_cache;
151static struct kmem_cache *_tio_cache; 174static struct kmem_cache *_tio_cache;
175static struct kmem_cache *_rq_tio_cache;
176static struct kmem_cache *_rq_bio_info_cache;
152 177
153static int __init local_init(void) 178static int __init local_init(void)
154{ 179{
@@ -164,9 +189,17 @@ static int __init local_init(void)
164 if (!_tio_cache) 189 if (!_tio_cache)
165 goto out_free_io_cache; 190 goto out_free_io_cache;
166 191
192 _rq_tio_cache = KMEM_CACHE(dm_rq_target_io, 0);
193 if (!_rq_tio_cache)
194 goto out_free_tio_cache;
195
196 _rq_bio_info_cache = KMEM_CACHE(dm_rq_clone_bio_info, 0);
197 if (!_rq_bio_info_cache)
198 goto out_free_rq_tio_cache;
199
167 r = dm_uevent_init(); 200 r = dm_uevent_init();
168 if (r) 201 if (r)
169 goto out_free_tio_cache; 202 goto out_free_rq_bio_info_cache;
170 203
171 _major = major; 204 _major = major;
172 r = register_blkdev(_major, _name); 205 r = register_blkdev(_major, _name);
@@ -180,6 +213,10 @@ static int __init local_init(void)
180 213
181out_uevent_exit: 214out_uevent_exit:
182 dm_uevent_exit(); 215 dm_uevent_exit();
216out_free_rq_bio_info_cache:
217 kmem_cache_destroy(_rq_bio_info_cache);
218out_free_rq_tio_cache:
219 kmem_cache_destroy(_rq_tio_cache);
183out_free_tio_cache: 220out_free_tio_cache:
184 kmem_cache_destroy(_tio_cache); 221 kmem_cache_destroy(_tio_cache);
185out_free_io_cache: 222out_free_io_cache:
@@ -190,6 +227,8 @@ out_free_io_cache:
190 227
191static void local_exit(void) 228static void local_exit(void)
192{ 229{
230 kmem_cache_destroy(_rq_bio_info_cache);
231 kmem_cache_destroy(_rq_tio_cache);
193 kmem_cache_destroy(_tio_cache); 232 kmem_cache_destroy(_tio_cache);
194 kmem_cache_destroy(_io_cache); 233 kmem_cache_destroy(_io_cache);
195 unregister_blkdev(_major, _name); 234 unregister_blkdev(_major, _name);