diff options
-rw-r--r-- | drivers/md/dm.c | 41 |
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 | ||
33 | static DEFINE_SPINLOCK(_minor_lock); | 33 | static 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 | */ |
37 | struct dm_io { | 38 | struct 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 | ||
55 | DEFINE_TRACE(block_bio_complete); | 57 | DEFINE_TRACE(block_bio_complete); |
56 | 58 | ||
59 | /* | ||
60 | * For request-based dm. | ||
61 | * One of these is allocated per request. | ||
62 | */ | ||
63 | struct 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 | */ | ||
75 | struct dm_rq_clone_bio_info { | ||
76 | struct bio *orig; | ||
77 | struct request *rq; | ||
78 | }; | ||
79 | |||
57 | union map_info *dm_get_mapinfo(struct bio *bio) | 80 | union 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 |
150 | static struct kmem_cache *_io_cache; | 173 | static struct kmem_cache *_io_cache; |
151 | static struct kmem_cache *_tio_cache; | 174 | static struct kmem_cache *_tio_cache; |
175 | static struct kmem_cache *_rq_tio_cache; | ||
176 | static struct kmem_cache *_rq_bio_info_cache; | ||
152 | 177 | ||
153 | static int __init local_init(void) | 178 | static 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 | ||
181 | out_uevent_exit: | 214 | out_uevent_exit: |
182 | dm_uevent_exit(); | 215 | dm_uevent_exit(); |
216 | out_free_rq_bio_info_cache: | ||
217 | kmem_cache_destroy(_rq_bio_info_cache); | ||
218 | out_free_rq_tio_cache: | ||
219 | kmem_cache_destroy(_rq_tio_cache); | ||
183 | out_free_tio_cache: | 220 | out_free_tio_cache: |
184 | kmem_cache_destroy(_tio_cache); | 221 | kmem_cache_destroy(_tio_cache); |
185 | out_free_io_cache: | 222 | out_free_io_cache: |
@@ -190,6 +227,8 @@ out_free_io_cache: | |||
190 | 227 | ||
191 | static void local_exit(void) | 228 | static 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); |